Jump to content

Takeshi_Kimura

Distributor
  • Content Count

    51
  • Joined

  • Last visited

Community Reputation

27 Great

1 Follower

About Takeshi_Kimura

  • Rank
    Apprentice

Personal Information

  • Location
    Tokyo, Japan

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Takeshi_Kimura

    Python installation issue

    I found the following files in the user library folder. The contents are: I guess the links to the wheel files in the Marionette node is outdated. However, I could download the following wheel file indicated in the script from Safari. I haven't checked other links, but the server might not be accepting access from Vectorworks software?
  2. Takeshi_Kimura

    Marionette Node List

    Hi Cris, I'm glad you liked it! I am not sure what is happening, but can you try changing the font? In line 57, there is "vs.SetTextFont" and the name of the font is indicated in the parameter of vs.GetFontID. You can change the font used by setting the font name where a Japanese font is set currently. Also, maybe you can delete this line to have document font used. Regards, Takeshi
  3. Takeshi_Kimura

    Marionette Node List

    Hi Everyone, My colleague here at A&A had created a Python script to list the nodes of Marionette. It should create a document with all the nodes ready for printing, like the attached files. We tested with page set to A3 portrait on a Japanese version, but it should work with other formats too. Please tell us what you find! I hope this will encourage more people to learn Marionette. It was ready a few months ago, but took so long to post it here... Regards, Takeshi Kimura@A&A CreateNodeList.py page = 0 class Unit(): def __init__(self): self.fraction = 0 self.display = 0 self.format = 0 self.upi = 0 self.name = '' self.squareName = '' class PrimaryUnit(): def __init__(self): self.style = 0 self.prec = 0 self.dimPrec = 0 self.format = 0 self.angPrec = 0 self.showMark = 0 self.dispFrac = 0 class NodeDefinication(): def __init__(self): self.name = '' self.symname = '' self.obj = vs.Handle(0) self.category = '' self.description = '' self.OIP = [] self.ports = [] # Push document units and set to millimeters / 書類の単位を退避、mmに設定 def PushUnits(u, pu): u.fraction, u.display, u.format, u.upi, u.name, u.squareName = vs.GetUnits() pu.style, pu.prec, pu.dimPrec, pu.format, pu.angPrec, pu.showMark, pu.dispFrac = vs.GetPrimaryUnitInfo() vs.SetUnits(0,0,0,25.4,'mm',' sq mm') vs.PrimaryUnits(0,0,0,2,6,0,0) return( u, pu ) # Pop document units / 書類の単位を元に戻す def PopUnits(u, pu): vs.SetUnits(u.fraction, u.display, u.format, u.upi, u.name, u.squareName) vs.PrimaryUnits(pu.style, pu.prec, pu.dimPrec, pu.format, pu.angPrec, pu.showMark, pu.dispFrac) def rgb65535(rgb255): return tuple(map(lambda x: x*257, rgb255)) def CreateText_Node( text, txtsize=8, fillcolor=(65535,65535,65535) ): vs.CreateText( text ) textobj = vs.LNewObj() vs.SetFillBack( textobj, fillcolor ) start = 0 count = vs.GetTextLength( textobj ) vs.SetTextSize(textobj, start, count, txtsize) vs.SetTextFont(textobj, start, count, vs.GetFontID('ヒラギノ角ゴ Pro W3')) return textobj def GetPageWH(): vs.DrwSize(1, 1) pt1,pt2 = vs.GetDrawingSizeRect() return pt2[0]-pt1[0], pt1[1] - pt2[1] def GetMarionetteRec(objH): MarionetteRecs = ['MarionetteNode'] kNodeNameFld = 'NodeType' kNodeDescFld = 'NodeHelp' KNodeOIPFld = 'NodeDef_OIPControls' KNodePortsFld = 'NodeDef_DataPorts' node = NodeDefinication() numR = vs.NumRecords(objH) if numR < 0: return False, node for ii in range(1,numR+1): recH = vs.GetRecord(objH, ii) # print(recH.name) if recH.name in MarionetteRecs: node.obj = objH node.category = vs.GetClass(objH).replace( 'マリオネット-', '' ).replace( 'Marionette-', '' ).strip() numF = vs.NumFields(recH) for jj in range(1,numF): nameF = vs.GetFldName(recH, jj) typeF = vs.GetFldType(recH, jj) valueF = vs.GetRField(objH, recH.name, nameF) # print(' - ',nameF,'(',typeF,') : ',valueF) if nameF == kNodeNameFld: node.name = valueF elif nameF == kNodeDescFld: node.description = valueF elif nameF == KNodeOIPFld: valueF = valueF.replace( chr(165)+chr(34), '”' ) node.OIP = eval(str(valueF))['data'] elif nameF == KNodePortsFld: valueF = valueF.replace( chr(165)+chr(34), '”' ) node.ports = eval(valueF)['data'] return True, node def PlotNodeParams(node,gPoint,rowhmax,sheetsize,sheetend,margin): def SetLocalPoint(_ptr,content_w,content_h,m_top,m_lower,m_left,m_right): xptr,yptr = _ptr bottom_x = xptr bottom_y = yptr + m_top + content_h + m_lower rightend = xptr + m_left + content_w + m_right if xmax > rightend: rightend = xmax return ( bottom_x, bottom_y ), rightend, bottom_y def CreateTextObj(titleText,mainText,limit): if not mainText == '': vs.BeginGroupN( vs.Handle(0) ) titleh = CreateText_Node(titleText,fillcolor=rgb65535((200,200,200))) desch = CreateText_Node(mainText) vs.SetTextWidth(desch, limit) vs.SetTextWidth(titleh, limit) vs.SetTextOrientation(desch, (0,(0-vs.HHeight( titleh ))), 0, False) vs.EndGroup( ) return vs.LNewObj() else: return vs.Handle(0) def CreateText_description(titleText,description,limit): if not description == '': return CreateTextObj( titleText, description, limit ) else: return vs.Handle(0) def CreateText_Items(titleText,itemsText,idText,limit): text = '' for param in itemsText: if 'description' in param: itemtext = param[idText] + ' : ' + param['description'] else: itemtext = param[idText] + ' : ' + ' - ' text = text + itemtext + chr(13) if not text == '': return CreateTextObj(titleText,text[:-1],limit) else: return vs.Handle(0) # Current Coordinate / 現在の座標 ptr = (0,0) xmax = 0 ymax = 0 # Node Image Coordinate / ノードイメージの座標 ptLT,ptRB = vs.GetBBox( node.obj ) imgw = ptRB[0] - ptLT[0] imgh = ptLT[1] - ptRB[1] ptr,xmax,ymax = SetLocalPoint(ptr,imgw,imgh,5,5,5,5) imgp = ( ptr[0], ptr[1] ) # Node Description Coordinate / ノード説明文の座標 limit = max( (5+imgw+5), 55 ) # descobj = CreateText_description( 'ノードの説明', node.description, limit ) descobj = CreateText_description( 'Description', node.description, limit ) if not descobj == vs.Handle(0): descw = vs.HWidth( descobj ) desch = vs.HHeight( descobj ) descp = ( ptr[0], ptr[1]+2 ) ptr,xmax,ymax = SetLocalPoint(ptr,descw,desch,2,2,0,2) # Node Control Description Coordinate / コントロール説明の座標 # oipobj = CreateText_Items( 'コントロールの説明', node.OIP, 'text', limit ) oipobj = CreateText_Items( 'Controls', node.OIP, 'text', limit ) if not oipobj == vs.Handle(0): oipw = vs.HWidth( oipobj ) oiph = vs.HHeight( oipobj ) oipp = ( ptr[0], ptr[1]+2 ) ptr,xmax,ymax = SetLocalPoint(ptr,oipw,oiph,2,2,0,2) # Node Port Description Coordinate / ポート説明の座標 # portobj = CreateText_Items( 'ポートの説明', node.ports, 'name', limit ) portobj = CreateText_Items( 'Ports', node.ports, 'name', limit ) if not portobj == vs.Handle(0): portw = vs.HWidth( portobj ) porth = vs.HHeight( portobj ) portp = ( ptr[0], ptr[1]+2 ) ptr,xmax,ymax = SetLocalPoint(ptr,portw,porth,2,2,0,2) # New Line Coordinate / 座標の折り返し if gPoint[0]+xmax > sheetend[2]-margin[2]: gPoint = ( sheetend[0]+margin[0], gPoint[1] - rowhmax) rowhmax = ymax if gPoint[1]-ymax < sheetend[3]+margin[3]: sheetend = ( sheetend[0]+sheetsize[0], sheetend[1], sheetend[2]+sheetsize[0], sheetend[3] ) gPoint = ( sheetend[0]+margin[0], sheetend[1]-margin[1] ) rowhmax = ymax global page page += 1 if ymax > rowhmax: rowhmax = ymax # Plot Each Object / 各図形のプロット imgp = ( imgp[0] + (xmax-imgw)/2, imgp[1]-5 ) vs.Symbol(node.symname, (gPoint[0]+imgp[0], gPoint[1]-imgp[1]), 0) symHandle = vs.LNewObj() vs.SymbolToGroup(symHandle, 0) if not descobj == vs.Handle(0): vs.HMove(descobj, gPoint[0]+descp[0], gPoint[1]-descp[1]) if not oipobj == vs.Handle(0): vs.HMove(oipobj, gPoint[0]+oipp[0], gPoint[1]-oipp[1]) if not portobj == vs.Handle(0): #vs.SetTextOrientation(portobj, (gPoint[0]+portp[0], gPoint[1]-portp[1]), 0, False) vs.HMove(portobj, gPoint[0]+portp[0], gPoint[1]-portp[1]) gPoint = (gPoint[0]+xmax, gPoint[1]) return gPoint, rowhmax, sheetsize, sheetend, margin # main def main(): kSymbol = 16 kDefFolder = 14 kSubFolder = 'Marionette' listID, numItems = vs.BuildResourceList(kSymbol, kDefFolder, kSubFolder) u, pu = PushUnits(Unit(), PrimaryUnit()) def overlap(resH): pass allNode = [] for i in range(1,numItems+1): resH = vs.ImportResToCurFileN(listID, i, overlap) if resH == vs.Handle(0): #print( i ) continue pio = vs.FInSymDef( resH ) while not pio == vs.Handle(0): isNodeDef,NodeDef = GetMarionetteRec( pio ) if isNodeDef: NodeDef.symname = resH.name #NodeDef.category = vs.GetResourceTags(resH) allNode.append( NodeDef ) pio = vs.Handle(0) else: pio = pio.next() #break # debug categoryNode = {} for node in allNode: if not node.category in categoryNode: categoryNode[ node.category ] = [] categoryNode[ node.category ].append( node ) sheetSize = GetPageWH() sheetLTRB = ( 0, sheetSize[1], sheetSize[0], 0 ) marginLTRB = ( 20, 20, 20, 20 ) gpoint = ( marginLTRB[0], sheetSize[1]-marginLTRB[1] ) numberOfNodes = 0 vs.BeginGroupN( vs.Handle(0) ) for categoryname, nodes in sorted( categoryNode.items() ): global page page += 1 #vs.Layer( categoryname ) rowHMax = 0 categoryobj = CreateText_Node( categoryname, txtsize=18 ) vs.HMove(categoryobj, gpoint[0], gpoint[1]) gpoint = (gpoint[0], gpoint[1]-vs.HHeight( categoryobj )-5) for node in nodes: gpoint,rowHMax,sheetSize,sheetLTRB,marginLTRB = PlotNodeParams(node,gpoint,rowHMax,sheetSize,sheetLTRB,marginLTRB) numberOfNodes += 1 #break #debug sheetLTRB = ( sheetLTRB[0]+sheetSize[0], sheetLTRB[1], sheetLTRB[2]+sheetSize[0], sheetLTRB[3] ) gpoint = ( sheetLTRB[0]+marginLTRB[0], sheetLTRB[1]-marginLTRB[1] ) vs.EndGroup() vs.HMove(vs.LNewObj(), -sheetSize[0]*page/2, -sheetSize[1]/2) vs.DrwSize(1, page) PopUnits(u, pu) #vs.AlrtDialog( str( page ) + ' ' + str( numberOfNodes ) ) main() TEST05_paged.pdf TEST05.vwx

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×