Andreas Posted March 13 Share Posted March 13 Dear Vectorworks forum I'm trying to create a script to insert a symbol in a wall. After both object have been selected, then I'm trying using vs.CreateDuplicateObject() or vs.SetParent() to fit the symbol in the wall but, without result. Thanks in advance. Quote Link to comment
Andreas Posted March 13 Author Share Posted March 13 vs.AddSymToWallEdge(inWall, offset, height, flip, right, symName, mode) I suppose.. Quote Link to comment
MullinRJ Posted March 14 Share Posted March 14 (edited) Hi @Andreas, Yes, that is the call to insert a symbol/pio into a wall. Using VW to help reverse engineer the code, I placed a Window in Wall and exported the VW file to a script file that defines the geometry. Use menu File>Export>Export Script... This doesn't always work for complicated files, but for simple things it's a great way to see what calls are used and how they are arranged. Here's a small script I built by copying the Wall and Window from the text dump (Export Script...). I found the relevant calls in the middle of the file and copied them to a new file, then rearranged a few calls and renamed the temp handles to make it easier to follow. Comments were also added for readability. To see what this represents, copy and paste this code into a script resource and run it. Then change some number, rerun, and notice the effects of the changes. It's a great learning tool for new commands. PROCEDURE xxx; { Sample script to insert a Window into a Wall. The units are in mm. } VAR WallHandle, WindowHandle :Handle; boolResult :Boolean; BEGIN { set pen and fill attributes } PenSize(1); PenPatN(2); FillPat(1); PenFore(0, 0, 0); PenBack(65535, 65535, 65535); FillFore(0, 0, 0); FillBack(65535, 65535, 65535); NameClass('None'); { set class to use } Wall(-5400, 2000, 5000, 2000); { create a wall } SetObjectVariableReal(LNewObj, 604, 3048); { Wall Start Height Top } SetObjectVariableReal(LNewObj, 605, 0); { Wall Start Height Bottom } SetObjectVariableReal(LNewObj, 606, 3048); { Wall End Height Top } SetObjectVariableReal(LNewObj, 607, 0); { Wall End Height Bottom } SetObjectVariableReal(LNewObj, 621, 3048); { Wall Overall Height Top } SetObjectVariableReal(LNewObj, 622, 0); { Wall Overall Height Bottom } SetObjectVariableReal(LNewObj, 618, 152.4); { Set Wall Width } DoubLines(152.4); ClearCavities; { start with an empty wall } WallHandle := LNewObj; { save handle to the Wall } WallCap(FALSE, TRUE, FALSE, 0, 0); AddSymToWallEdge(LNewObj, 5300, 0, FALSE, FALSE, 'Window', 0); { insert object into wall } boolResult := SetObjWallInsLocOff(LNewObj, WallHandle, 0); { shifts object to inside/outside of wall } WallCap(TRUE, TRUE, FALSE, 0, 0); ResetObject(WallHandle); { reset the Wall object } WindowHandle := LNewObj; { save handle to the Window - not used, but could be used later } SysBeep; { make noise when done } END; Run(xxx); Here's the same thing in Python. Again, the code was gathered from text dump from the program using Export Script. import vs # Sample Python script to insert a Window into a Wall. The units are in mm. # set pen and fill attributes vs.PenSize(1) vs.PenPatN(2) vs.FillPat(1) vs.PenFore((0, 0, 0)) vs.PenBack((65535, 65535, 65535)) vs.FillFore((0, 0, 0)) vs.FillBack((65535, 65535, 65535)) vs.NameClass('None') # set class to use vs.Wall(-5400, 2000, 5000, 2000) # create a wall vs.SetObjectVariableReal(vs.LNewObj(), 604, 3048) # WallStartHeightTop vs.SetObjectVariableReal(vs.LNewObj(), 605, 0) # WallStartHeightBottom vs.SetObjectVariableReal(vs.LNewObj(), 606, 3048) # WallEndHeightTop vs.SetObjectVariableReal(vs.LNewObj(), 607, 0) # WallEndHeightBottom vs.SetObjectVariableReal(vs.LNewObj(), 621, 3048) # WallOverallHeightTop vs.SetObjectVariableReal(vs.LNewObj(), 622, 0) # WallOverallHeightBottom vs.SetObjectVariableReal(vs.LNewObj(), 618, 152.4) # SetWallWidth vs.DoubLines(152.4) vs.ClearCavities() # start with an empty Wall WallHandle = vs.LNewObj() # save handle to the Wall vs.WallCap(False, True, False, 0, 0) vs.AddSymToWallEdge(vs.LNewObj(), 5300, 0, False, False, 'Window', 0) # insert object into wall boolResult = vs.SetObjWallInsLocOff(vs.LNewObj(), WallHandle, 0) # shifts object to inside/outside of wall vs.WallCap(True, True, False, 0, 0) vs.ResetObject(WallHandle) # reset the Wall object WindowHandle = vs.LNewObj() # save handle to the Window - not used, but could be used later vs.SysBeep() # make noise when done One caveat to keep in mind, LNewObj is a function that returns a handle to the last object created (usually — but Groups don't follow this rule when they get created.) Think of LNewObj as a temporary handle. If you want to save a handle for use later in the script, assign LNewObj to a program variable and keep on drawing. Notice "WallHandle" is used this way. HTH, Raymond Edited March 18 by MullinRJ added Python 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.