Jump to content

The Hamma

Member
  • Content Count

    162
  • Joined

  • Last visited

Everything posted by The Hamma

  1. Raymond: I think you are right. I guess there is no way to run a script that calls another script and lets it finish then finishes the script that called it. The only other option I suppose is to have three scripts. One to turn off Auto DC, this script, and one script to turn it back on. It wouldn't be a problem if it was just the confirmation message you get at the end of the script. The issue is that some of the labels do not display correctly after modifying the number and you have to edit the annotations and move them so they refresh. And since the issue arises after the script I can't fix them in the script. I could possibly right a script to refresh the Drawing labels that could be run after this script.
  2. In this instance 1=true and 0=false. This simple script will turn if off the Automatic Drawing Coordination. vs.SetPref(544, 0) This one will turn it on. vs.SetPref(544, 1) If I run the first script prior to running the script mentioned in the previous post I have no issue but if I try to disable it during the script it does not register as being off.
  3. Thanks that was it but for some reason when I turn it off in the script it still acts like it is on. I checked and it is setting the preference off and then back to the prescript state at the end. #script to renumber drawing labels contained within VP annotations in order picked by mouse. autocoord = vs.GetPref(544) vs.SetPref(544, 0) hVP = [] numberStr = vs.StrDialog('Enter and INTEGER to start numbering:','1') vs.Message('Click in empty space to end Label Numbering') h = 1 while h != 0: click = False while not(click): click, pt = vs.MouseDown() h = vs.PickObject(pt) anno = vs.GetVPGroup(h, 2) h1 = vs.FInGroup(anno) objs = [h1] h1 = vs.NextObj(h1) while h1 != vs.Handle(0): if vs.GetObjectVariableString(h1, 1166) == 'Drawing Label': hVP.append(h1) h1 = vs.NextObj(h1) for DL in hVP: vs.SetRField(DL,'Drawing Label','Drawing',numberStr) vpNumber = vs.Str2Num(numberStr) # {convert number string to number} numberStr = vs.Num2Str(0, vpNumber + 1) #{increment number then convert number to string} vs.SetPref(544, autocoord) vs.ClrMessage()
  4. Does anyone know what the Pref # is for Automatic Drawing Coordination? I can't seem to find it in the appendix.
  5. Yes, I was aware but in this case I don't need to test for objects in a VP because It's not intended to initiate a global change based on type only on specifically selected objects. Thanks again for the great advice.
  6. Great Idea. Now I can isolate it and now I can get it to run in sheet layers or veiwport annotations if they are the active layer. """ This script assigns selected objects to class "1_Exist-(original class)" and set Construction Phase to 'EXISTING TO REMAIN'. If a in wall object is selected without selecting the wall the script will only change those in wall objects. If a wall is selected it will change the wall and all objects inserted in that wall. If New class does not exist objects original class is duplicated to retain class attributes. To take full advantage of this script use "Data Visualization" to display the "Construction Phase" record objects as desired. 1. Set "Data Visualization" to modify drawings per "Construction Phase" record 2. To make a "Construction Phase" invisible set the attributes of that phase to: Line settings to Fill "Solid White" and Line weight "0" This Python Script may be freely distributed. No warranty provided. Use at your own risk. Vectorworks bug does not show changes to symbols inserted in wall until either: Drawing is saved and reopened. Setting in Data Visualization dialog is changed. Symbol is removed from wall, can then be reinserted David Hamer, 2020 """ # Modifications to any objects happen here def assign(h): CName = vs.GetClass(h) CLen = vs.Len(CName) CNameE = vs.Copy(CName, 1, 8) # Grab First 8 letters of handle's class CNameD = vs.Copy(CName, 1, 7) # Grab First 7 letters of handle's class if CNameD == '2_Demo-': # Check if first 7 letters equal '2_Demo-' CName = vs.Copy(CName, 8, CLen) # if true grab root name of class # check if the class is new, if so delete new class and duplicate objects class and rename. if CNameE == '1_Exist-': CNameN = CName else: CNameN = vs.Concat('1_Exist-', CName) # If not add '1_Exist-' to name ClassCount = vs.ClassNum() # determine number of classes in drawing vs.NameClass(CNameN) # set the name of the class to be applied to handle if new class will be created if ClassCount + 1 == vs.ClassNum(): # check if the class is new and if delete new class and duplicate source vs.ReDraw() vs.DelClass(CNameN) # Delete new class CHandle = vs.GetObject(CName) # get handle to source class NDCHandle = vs.CreateDuplicateObject(CHandle, vs.GetParent(CHandle)) # duplicate source class vs.SetName(NDCHandle, CNameN) # rename duplicate class to name to be applied to handle vs.ResetObject(NDCHandle) vs.ResetObject(h) vs.SetClass(h, CNameN) # name handle's class vs.SetRecord(h, 'Construction Phase') # add record to inserted object vs.SetRField(h, 'Construction Phase', 'Phase', 'EXISTING TO REMAIN') # modify record to inserted object # Passes Handle to "def assign(h):" of PIO or Symbol selected def pio_processing(h): global container # declare global variable to be retained if vs.GetObjectVariableInt(vs.GetLayer(h), 154) == activetype: assign(h) # Runs "def assign(h):" hParent = vs.GetParent(h) # Get Parent handle itParent = vs.GetTypeN(hParent) # Get Parent type if itParent != []: if itParent == 68: # If Parent type is a wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' if itParent == 89: # If Parent type is a round wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' # Passes Handle to "def assign(h):" of every object except PIO and Symbols outside walls selected def object_processing(h): if vs.GetObjectVariableInt(vs.GetLayer(h), 154) == activetype: assign(h) # Runs "def assign(h):" h1 = vs.FIn3D(h) while h1 != []: if vs.GetObjectVariableInt(vs.GetLayer(h1), 154) == activetype: if vs.GetTypeN(h1) == 15: assign(h1) # Runs "def assign(h):" on symbol inserted if vs.GetTypeN(h1) == 86: assign(h1) # Runs "def assign(h):" on PIO inserted h1 = vs.NextObj(h1) def sl_processing(h): # Omit's Viewports in Sheet Layers if vs.GetTypeN(h) != 122: assign(h) activetype = 1 container = 'none' # Declare container var ACName = vs.ActiveClass() # Record name of active class if vs.GetObject('Construction Phase') == (): # Creates "Construction Phase" record if not present vs.NewField('Construction Phase', 'Phase', '<none>', 4, 0) if vs.GetObjectVariableInt(vs.ActLayer(), 154) == 2: activetype = 2 vs.ForEachObjectInLayer(sl_processing, 2, 0, 0) else: # Passes Handle to "def pio_processing(h):" of PIO and Symbols selected vs.ForEachObject(pio_processing, "((((T=PLUGINOBJECT)|(T=SYMBOL)) & (V) & (SEL=TRUE)))") # Passes Handle to "def object_processing(h):" of objects selected except PIO and Symbols outside walls selected # Skipped if PIO or Symbol selected was in wall if container != 'PIOinwallwasdetected': vs.ForEachObject(object_processing, "(((T<>PLUGINOBJECT)&(T<>SYMBOL)&(T<>VIEWPORT) & (V) & (VSEL=TRUE)))") vs.NameClass(ACName) # Return active class
  7. I need some help. Apparently this script is editing objects that are selected on sheet layers even though the sheet layer is not active. Does anyone know how to limit the selection to just the viewable and editable layers. I thought about using ForEachObjectInLayer but it does not work for symbols and PIO in walls. """ This script assigns selected objects to class "1_Exist-(original class)" and set Construction Phase to 'EXISTING TO REMAIN'. If a in wall object is selected without selecting the wall the script will only change those in wall objects. If a wall is selected it will change the wall and all objects inserted in that wall. If New class does not exist objects original class is duplicated to retain class attributes. To take full advantage of this script use "Data Visualization" to display the "Construction Phase" record objects as desired. 1. Set "Data Visualization" to modify drawings per "Construction Phase" record 2. To make a "Construction Phase" invisible set the attributes of that phase to: Line settings to Fill "Solid White" and Line weight "0" This Python Script may be freely distributed. No warranty provided. Use at your own risk. Vectorworks bug does not show changes to symbols inserted in wall until either: Drawing is saved and reopened. Setting in Data Visualization dialog is changed. Symbol is removed from wall, can then be reinserted David Hamer, 2020 """ # Modifications to any objects happen here def assign(h): CName = vs.GetClass(h) CLen = vs.Len(CName) CNameE = vs.Copy(CName, 1, 8) # Grab First 8 letters of handle's class CNameD = vs.Copy(CName, 1, 7) # Grab First 7 letters of handle's class if CNameD == '2_Demo-': # Check if first 7 letters equal '2_Demo-' CName = vs.Copy(CName, 8, CLen) # if true grab root name of class # check if the class is new, if so delete new class and duplicate objects class and rename. if CNameE == '1_Exist-': CNameN = CName else: CNameN = vs.Concat('1_Exist-', CName) # If not add '1_Exist-' to name ClassCount = vs.ClassNum() # determine number of classes in drawing vs.NameClass(CNameN) # set the name of the class to be applied to handle if new class will be created if ClassCount + 1 == vs.ClassNum(): # check if the class is new and if delete new class and duplicate source vs.ReDraw() vs.DelClass(CNameN) # Delete new class CHandle = vs.GetObject(CName) # get handle to source class NDCHandle = vs.CreateDuplicateObject(CHandle, vs.GetParent(CHandle)) # duplicate source class vs.SetName(NDCHandle, CNameN) # rename duplicate class to name to be applied to handle vs.ResetObject(NDCHandle) vs.ResetObject(h) vs.SetClass(h, CNameN) # name handle's class vs.SetRecord(h, 'Construction Phase') # add record to inserted object vs.SetRField(h, 'Construction Phase', 'Phase', 'EXISTING TO REMAIN') # modify record to inserted object # Passes Handle to "def assign(h):" of PIO or Symbol selected def pio_processing(h): global container # declare global variable to be retained assign(h) # Runs "def assign(h):" hParent = vs.GetParent(h) # Get Parent handle itParent = vs.GetTypeN(hParent) # Get Parent type if itParent != []: if itParent == 68: # If Parent type is a wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' if itParent == 89: # If Parent type is a round wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' # Passes Handle to "def assign(h):" of every object except PIO and Symbols outside walls selected def object_processing(h): assign(h) # Runs "def assign(h):" h1 = vs.FIn3D(h) while h1 != []: if vs.GetTypeN(h1) == 15: assign(h1) # Runs "def assign(h):" on symbol inserted if vs.GetTypeN(h1) == 86: assign(h1) # Runs "def assign(h):" on PIO inserted h1 = vs.NextObj(h1) container = 'none' # Declare container var ACName = vs.ActiveClass() # Record name of active class if vs.GetObject('Construction Phase') == (): # Creates "Construction Phase" record if not present vs.NewField('Construction Phase', 'Phase', '<none>', 4, 0) # Passes Handle to "def pio_processing(h):" of PIO and Symbols selected vs.ForEachObject(pio_processing, "((((T=PLUGINOBJECT)|(T=SYMBOL)) & (V) & (SEL=TRUE)))") # Passes Handle to "def object_processing(h):" of objects selected except PIO and Symbols outside walls selected # Skipped if PIO or Symbol selected was in wall if container != 'PIOinwallwasdetected': vs.ForEachObject(object_processing, "(((T<>PLUGINOBJECT)&(T<>SYMBOL) & (V) & (VSEL=TRUE)))") vs.NameClass(ACName) # Return active class
  8. Script has been modified to detect if Design Layers or Sheet Layer is active and Isolate modifications to the active layer type. Also added the ability to modify objects within a Sheet Layer or Sheet Layer VP annotations. Note that classes will need to be enabled in VP dialog after running script in VP annotations otherwise they may be hidden. Only works on objects inserted in walls when design layer is active. """ This script assigns selected objects to class "1_Exist-(original class)" and set Construction Phase to 'EXISTING TO REMAIN'. If a in wall object is selected without selecting the wall the script will only change those in wall objects. If a wall is selected it will change the wall and all objects inserted in that wall. If New class does not exist objects original class is duplicated to retain class attributes. To take full advantage of this script use "Data Visualization" to display the "Construction Phase" record objects as desired. 1. Set "Data Visualization" to modify drawings per "Construction Phase" record 2. To make a "Construction Phase" invisible set the attributes of that phase to: Line settings to Fill "Solid White" and Line weight "0" This Python Script may be freely distributed. No warranty provided. Use at your own risk. Vectorworks bug does not show changes to symbols inserted in wall until either: Drawing is saved and reopened. Setting in Data Visualization dialog is changed. Symbol is removed from wall, can then be reinserted David Hamer, 2020 revision 07-15-2020 """ # Modifications to any objects happen here def assign(h): CName = vs.GetClass(h) CLen = vs.Len(CName) CNameE = vs.Copy(CName, 1, 8) # Grab First 8 letters of handle's class CNameD = vs.Copy(CName, 1, 7) # Grab First 7 letters of handle's class if CNameD == '2_Demo-': # Check if first 7 letters equal '2_Demo-' CName = vs.Copy(CName, 8, CLen) # if true grab root name of class # check if the class is new, if so delete new class and duplicate objects class and rename. if CNameE == '1_Exist-': CNameN = CName else: CNameN = vs.Concat('1_Exist-', CName) # If not add '1_Exist-' to name ClassCount = vs.ClassNum() # determine number of classes in drawing vs.NameClass(CNameN) # set the name of the class to be applied to handle if new class will be created if ClassCount + 1 == vs.ClassNum(): # check if the class is new and if delete new class and duplicate source vs.ReDraw() vs.DelClass(CNameN) # Delete new class CHandle = vs.GetObject(CName) # get handle to source class NDCHandle = vs.CreateDuplicateObject(CHandle, vs.GetParent(CHandle)) # duplicate source class vs.SetName(NDCHandle, CNameN) # rename duplicate class to name to be applied to handle vs.ResetObject(NDCHandle) vs.ResetObject(h) vs.SetClass(h, CNameN) # name handle's class vs.SetRecord(h, 'Construction Phase') # add record to inserted object vs.SetRField(h, 'Construction Phase', 'Phase', 'EXISTING TO REMAIN') # modify record to inserted object # Passes Handle to "def assign(h):" of PIO or Symbol selected def pio_processing(h): global container # declare global variable to be retained if vs.GetObjectVariableInt(vs.GetLayer(h), 154) == activetype: assign(h) # Runs "def assign(h):" hParent = vs.GetParent(h) # Get Parent handle itParent = vs.GetTypeN(hParent) # Get Parent type if itParent != []: if itParent == 68: # If Parent type is a wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' if itParent == 89: # If Parent type is a round wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' # Passes Handle to "def assign(h):" of every object except PIO and Symbols outside walls selected def object_processing(h): if vs.GetObjectVariableInt(vs.GetLayer(h), 154) == activetype: assign(h) # Runs "def assign(h):" h1 = vs.FIn3D(h) while h1 != []: if vs.GetObjectVariableInt(vs.GetLayer(h1), 154) == activetype: if vs.GetTypeN(h1) == 15: assign(h1) # Runs "def assign(h):" on symbol inserted if vs.GetTypeN(h1) == 86: assign(h1) # Runs "def assign(h):" on PIO inserted h1 = vs.NextObj(h1) def sl_processing(h): # Omit's Viewports in Sheet Layers if vs.GetTypeN(h) != 122: assign(h) activetype = 1 container = 'none' # Declare container var ACName = vs.ActiveClass() # Record name of active class if vs.GetObject('Construction Phase') == (): # Creates "Construction Phase" record if not present vs.NewField('Construction Phase', 'Phase', '<none>', 4, 0) if vs.GetObjectVariableInt(vs.ActLayer(), 154) == 2: activetype = 2 vs.ForEachObjectInLayer(sl_processing, 2, 0, 0) else: # Passes Handle to "def pio_processing(h):" of PIO and Symbols selected vs.ForEachObject(pio_processing, "((((T=PLUGINOBJECT)|(T=SYMBOL)) & (V) & (SEL=TRUE)))") # Passes Handle to "def object_processing(h):" of objects selected except PIO and Symbols outside walls selected # Skipped if PIO or Symbol selected was in wall if container != 'PIOinwallwasdetected': vs.ForEachObject(object_processing, "(((T<>PLUGINOBJECT)&(T<>SYMBOL)&(T<>VIEWPORT) & (V) & (VSEL=TRUE)))") vs.NameClass(ACName) # Return active class
  9. Where you able to write a script to accomplish this?
  10. """ This script identifies the name of a texture in the drawing and creates a new class with identified texture assigned to the newly created class. This is useful so that objects can be textured by assigning them to the appropriate class. This Python Script may be freely distributed. No warranty provided. Use at your own risk. If the name of the texture and the prefix exceeds 63 characters the class name will be shortened to 63 characters. This is a Vectorworks class name limitation. David Hamer, 2020 """ ClassPrefix ='I-FNSH-' #Newly created classes prefix TextureList, NumItems = vs.BuildResourceList(97, 0, '') while NumItems != 0: TextureName = vs.GetNameFromResourceList(TextureList, NumItems) TextureClassNameW = vs.Concat(ClassPrefix,TextureName) TextureClassName = vs.Copy(TextureClassNameW, 1, 63) vs.NameClass(TextureClassName) vs.SetClFillFore(TextureClassName,0,0,0) vs.SetClFillBack(TextureClassName,0,0,0) vs.SetClPenFore(TextureClassName,65535,65535,65535) vs.SetClPenBack(TextureClassName,65535,65535,65535) vs.SetClFPat(TextureClassName,1) vs.SetClLSN(TextureClassName,2) vs.SetClLW(TextureClassName,10) vs.EnableCLDropShadow(TextureClassName,False) vs.SetClUseGraphic(TextureClassName,True) TextureIndex = vs.Name2Index(TextureName) vs.SetClTextureC(TextureClassName, TextureIndex) vs.SetClTextureD(TextureClassName, TextureIndex) vs.SetClTextureG(TextureClassName, TextureIndex) vs.SetClTextureL(TextureClassName, TextureIndex) vs.SetClTextureR(TextureClassName, TextureIndex) vs.SetClTextureT(TextureClassName, TextureIndex) vs.SetClUseTexture(TextureClassName, True) NumItems = NumItems -1
  11. Revised 08-13-2020 See revision note in new comments Attached are scripts that I wrote to help with renovation projects. These scripts edit the classing and add a construction phase record to every item selected. PIO's that are inserted in walls can be selected with out selecting the containing wall and the script will only affect those PIO's selected. If the wall is selected it will modify the wall and the PIO's that are contained with in that wall. SCRIPT CLASS MODIFICATION CONSTRUCTION PHASE RECORD 1 Existing Object 1_Exist- (Prefix) EXISTING TO REMAIN 2 Demo Object 2_Demo- (Prefix) DEMOLISH EXISTING 3 New Object No change or return to original Class NEW CONSTRUCTION 4 NIC Object No change or return to original Class NOT IN CONTRACT 5 Remove Phase Record No change or return to original Class REMOVES RECORD FROM SELECTED OBJECTS (ADDED) With the use of the scripts and data visualization you can create viewports that show the construction phases as desired. Attached to this post is a demonstration Video, the two files used in that video, and the four scripts. I added the script to my selected object context menu so when I right click on an object I can access the scripts from there. 2020-05-16 16-42-33.mp4 Construction Phase Demo Unmodified Plan.vwx Construction Phase Demo.vwx 1 Existing Object.vsm 2 Demo Object.vsm 3 New Object.vsm 4 NIC Object.vsm 5 Remove Phase Record.vsm
  12. Is there an equivalent way to achieve this in vectoworks worksheets? I would like to just display the finish material code and not the material in the finish schedule. In excel I would create a blank column to the right column C and add this formula =LEFT(C5,FIND("]",C5)+1) See attached image
  13. Is there a vectorscript command to create new space style from current space handle?
  14. The current options in "Draw All Other Objects" are "Normally" and "Grayed". I would like "Hidden" to be added to those options so that objects not modified by Data Visualization properties would not display in the selected Data Visualization.
  15. I would like to request that a "Hidden" option is added to "Data Visualization" to the "Draw All Other Objects" Options
  16. I am looking for the files to modify for Standard Naming. For example the User 3 profile. Does anyone know where they are located or what the name of the file is?
  17. Marissa: I understand why you collected the handles of the Viewports before processing the actions but I was wondering why you collected the handles of the drawing labels before not deleting them. Would it be more efficient code to delete objects as you detect them?
  18. Does anyone know if it is possible to define a class tag using vectorscript?
  19. Below are the final results: Three scripts to assigns selected objects to class "1_Exist-(original class)", "2_Demo-(original class)" , or original class and set Construction Phase Existing, Demo, or New """ This script assigns selected objects to class "1_Exist-(original class)" and set Construction Phase to Existing. If a in wall object is selected without selecting the wall the script will only change those in wall objects. If a wall is selected it will change the wall and all objects inserted in that wall. If New class does not exist objects original class is duplicated to retain class attributes. To take full advantage of this script use "Data Visualization" to display the "Construction Phase" record objects as desired. 1. Set "Data Visualization" to modify drawings per "Construction Phase" record 2. To make a "Construction Phase" invisible set the attributes of that phase to: Line settings to Fill "Solid White" and Line weight "0" This Python Script may be freely distributed. No warranty provided. Use at your own risk. Vectorworks bug does not show changes to symbols inserted in wall until either: Drawing is saved and reopened. Setting in Data Visualization dialog is changed. Symbol is removed from wall, can then be reinserted David Hamer, 2020 """ # Modifications to any objects happen here def assign(h): CName = vs.GetClass(h) CLen = vs.Len(CName) CNameE = vs.Copy(CName, 1, 8) # Grab First 8 letters of handle's class CNameD = vs.Copy(CName, 1, 7) # Grab First 7 letters of handle's class if CNameD == '2_Demo-': # Check if first 7 letters equal '2_Demo-' CName = vs.Copy(CName, 8, CLen) # if true grab root name of class # check if the class is new, if so delete new class and duplicate objects class and rename. if CNameE == '1_Exist-': CNameN = CName else: CNameN = vs.Concat('1_Exist-', CName) # If not add '1_Exist-' to name ClassCount = vs.ClassNum() # determine number of classes in drawing vs.NameClass(CNameN) # set the name of the class to be applied to handle if new class will be created if ClassCount + 1 == vs.ClassNum(): # check if the class is new and if delete new class and duplicate source vs.ReDraw() vs.DelClass(CNameN) # Delete new class CHandle = vs.GetObject(CName) # get handle to source class NDCHandle = vs.CreateDuplicateObject(CHandle, vs.GetParent(CHandle)) # duplicate source class vs.SetName(NDCHandle, CNameN) # rename duplicate class to name to be applied to handle vs.ResetObject(NDCHandle) vs.ResetObject(h) vs.SetClass(h, CNameN) # name handle's class vs.SetRecord(h, 'Construction Phase') # add record to inserted object vs.SetRField(h, 'Construction Phase', 'Phase', 'Existing') # modify record to inserted object # Passes Handle to "def assign(h):" of PIO or Symbol selected def pio_processing(h): global container # declare global variable to be retained assign(h) # Runs "def assign(h):" hParent = vs.GetParent(h) # Get Parent handle itParent = vs.GetTypeN(hParent) # Get Parent type if itParent != (): if itParent == 68: # If Parent type is a wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' if itParent == 89: # If Parent type is a round wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' # Passes Handle to "def assign(h):" of every object except PIO and Symbols outside walls selected def object_processing(h): assign(h) # Runs "def assign(h):" h1 = vs.FIn3D(h) while h1 != (): if vs.GetTypeN(h1) == 15: assign(h1) # Runs "def assign(h):" on symbol inserted if vs.GetTypeN(h1) == 86: assign(h1) # Runs "def assign(h):" on PIO inserted h1 = vs.NextObj(h1) container = 'none' # Declare container var ACName = vs.ActiveClass() # Record name of active class if vs.GetObject('Construction Phase') == (): # Creates "Construction Phase" record if not present vs.NewField('Construction Phase', 'Phase', '<none>', 4, 0) # Passes Handle to "def pio_processing(h):" of PIO and Symbols selected vs.ForEachObject(pio_processing, "((((T=PLUGINOBJECT)|(T=SYMBOL)) & (V) & (SEL=TRUE)))") # Passes Handle to "def object_processing(h):" of objects selected except PIO and Symbols outside walls selected # Skipped if PIO or Symbol selected was in wall if container != 'PIOinwallwasdetected': vs.ForEachObject(object_processing, "(((T<>PLUGINOBJECT)&(T<>SYMBOL) & (V) & (SEL=TRUE)))") vs.NameClass(ACName) # Return active class """ This script assigns selected objects to class "2_Demo-(original class)" and set Construction Phase to Demo. If a in wall object is selected without selecting the wall the script will only change those in wall objects. If a wall is selected it will change the wall and all objects inserted in that wall. If New class does not exist objects original class is duplicated to retain class attributes. To take full advantage of this script use "Data Visualization" to display the "Construction Phase" record objects as desired. 1. Set "Data Visualization" to modify drawings per "Construction Phase" record 2. To make a "Construction Phase" invisible set the attributes of that phase to: Line settings to Fill "Solid White" and Line weight "0" This Python Script may be freely distributed. No warranty provided. Use at your own risk. Vectorworks bug does not show changes to symbols inserted in wall until either: Drawing is saved and reopened. Setting in Data Visualization dialog is changed. Symbol is removed from wall, can then be reinserted David Hamer, 2020 """ # Modifications to any objects happen here def assign(h): CName = vs.GetClass(h) CLen = vs.Len(CName) CNameE = vs.Copy(CName, 1, 8) # Grab First 8 letters of handle's class CNameD = vs.Copy(CName, 1, 7) # Grab First 7 letters of handle's class if CNameE == '1_Exist-': # Check if first 8 letters equal '1_Exist-' CName = vs.Copy(CName, 9, CLen) # if true grab root name of class if CNameD == '2_Demo-': # Check if first 7 letters equal '2_Demo-' if so retain name CNameN = CName else: CNameN = vs.Concat('2_Demo-', CName) # If not add '2_Demo-' to name ClassCount = vs.ClassNum() # determine number of classes in drawing vs.NameClass(CNameN) # set the name of the class to be applied to handle if new class will be created if ClassCount + 1 == vs.ClassNum(): # check if the class is new and if delete new class and duplicate source vs.ReDraw() vs.DelClass(CNameN) # Delete new class CHandle = vs.GetObject(CName) # get handle to source class NDCHandle = vs.CreateDuplicateObject(CHandle, vs.GetParent(CHandle)) # duplicate source class vs.SetName(NDCHandle, CNameN) # rename duplicate class to name to be applied to handle vs.ResetObject(NDCHandle) vs.ResetObject(h) vs.SetClass(h, CNameN); # name handle's class vs.SetRecord(h, 'Construction Phase') # add record to inserted object vs.SetRField(h, 'Construction Phase', 'Phase', 'Demo') # modify record to inserted object # Passes Handle to "def assign(h):" of PIO or Symbol selected def pio_processing(h): global container # declare global variable to be retained assign(h) # Runs "def assign(h):" hParent = vs.GetParent(h) # Get Parent handle itParent = vs.GetTypeN(hParent) # Get Parent type if itParent != (): if itParent == 68: # If Parent type is a wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' if itParent == 89: # If Parent type is a round wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' # Passes Handle to "def assign(h):" of every object except PIO and Symbols outside walls selected def object_processing(h): assign(h) # Runs "def assign(h):" h1 = vs.FIn3D(h) while h1 != (): if vs.GetTypeN(h1) == 15: assign(h1) # Runs "def assign(h):" on symbol inserted if vs.GetTypeN(h1) == 86: assign(h1) # Runs "def assign(h):" on PIO inserted h1 = vs.NextObj(h1) container = 'none' # Declare container var ACName = vs.ActiveClass() # Record name of active class if vs.GetObject('Construction Phase') == (): # Creates "Construction Phase" record if not present vs.NewField('Construction Phase', 'Phase', '<none>', 4, 0) # Passes Handle to "def pio_processing(h):" of PIO and Symbols selected vs.ForEachObject(pio_processing, "((((T=PLUGINOBJECT)|(T=SYMBOL)) & (V) & (SEL=TRUE)))") # Passes Handle to "def object_processing(h):" of objects selected except PIO and Symbols outside walls selected # Skipped if PIO or Symbol selected was in wall if container != 'PIOinwallwasdetected': vs.ForEachObject(object_processing, "(((T<>PLUGINOBJECT)&(T<>SYMBOL) & (V) & (SEL=TRUE)))") vs.NameClass(ACName) # Return active class """ This script assigns selected objects to class "(original class)" and set Construction Phase to New If a in wall object is selected without selecting the wall the script will only change those in wall objects. If a wall is selected it will change the wall and all objects inserted in that wall. If New class does not exist objects original class is duplicated to retain class attributes. To take full advantage of this script use "Data Visualization" to display the "Construction Phase" record objects as desired. 1. Set "Data Visualization" to modify drawings per "Construction Phase" record 2. To make a "Construction Phase" invisible set the attributes of that phase to: Line settings to Fill "Solid White" and Line weight "0" This Python Script may be freely distributed. No warranty provided. Use at your own risk. Vectorworks bug does not show changes to symbols inserted in wall until either: Drawing is saved and reopened. Setting in Data Visualization dialog is changed. Symbol is removed from wall, can then be reinserted David Hamer, 2020 """ #Modifications to any objects happen here def assign(h): CName=vs.GetClass(h) CLen=vs.Len(CName) CNameN = CName CNameE=vs.Copy(CName,1,8) #Grab First 8 letters of handle's class CNameD=vs.Copy(CName,1,7) #Grab First 7 letters of handle's class if CNameD=='2_Demo-': #Check if first 7 letters equal '2_Demo-' CNameN=vs.Copy(CName,8,CLen) # if true grab root name of class if CNameE=='1_Exist-': #Check if first 8 letters equal '1_Exist-' CNameN=vs.Copy(CName,9,CLen) # if true grab root name of class ClassCount = vs.ClassNum() #determine number of classes in drawing vs.NameClass(CNameN) #set the name of the class to be applied to handle if new class will be created if ClassCount+1 == vs.ClassNum(): # check if the class is new and if delete new class and duplicate source vs.ReDraw() vs.DelClass(CNameN) #Delete new class CHandle = vs.GetObject(CName) #get handle to source class NDCHandle = vs.CreateDuplicateObject(CHandle,vs.GetParent(CHandle)) #duplicate source class vs.SetName(NDCHandle,CNameN) #rename duplicate class to name to be applied to handle vs.ResetObject(NDCHandle) vs.ResetObject(h) vs.SetClass(h,CNameN) #name handle's class vs.SetRecord(h,'Construction Phase') #add record to inserted object vs.SetRField(h,'Construction Phase','Phase', 'New') #modify record to inserted object # Passes Handle to "def assign(h):" of PIO or Symbol selected def pio_processing(h): global container # declare global variable to be retained assign(h) # Runs "def assign(h):" hParent = vs.GetParent(h) # Get Parent handle itParent = vs.GetTypeN(hParent) # Get Parent type if itParent != (): if itParent == 68: # If Parent type is a wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' if itParent == 89: # If Parent type is a round wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' # Passes Handle to "def assign(h):" of every object except PIO and Symbols outside walls selected def object_processing(h): assign(h) # Runs "def assign(h):" h1 = vs.FIn3D(h) while h1 != (): if vs.GetTypeN(h1) == 15: assign(h1) # Runs "def assign(h):" on symbol inserted if vs.GetTypeN(h1) == 86: assign(h1) # Runs "def assign(h):" on PIO inserted h1 = vs.NextObj(h1) container = 'none' # Declare container var ACName = vs.ActiveClass() # Record name of active class if vs.GetObject('Construction Phase') == (): # Creates "Construction Phase" record if not present vs.NewField('Construction Phase', 'Phase', '<none>', 4, 0) # Passes Handle to "def pio_processing(h):" of PIO and Symbols selected vs.ForEachObject(pio_processing, "((((T=PLUGINOBJECT)|(T=SYMBOL)) & (V) & (SEL=TRUE)))") # Passes Handle to "def object_processing(h):" of objects selected except PIO and Symbols outside walls selected # Skipped if PIO or Symbol selected was in wall if container != 'PIOinwallwasdetected': vs.ForEachObject(object_processing, "(((T<>PLUGINOBJECT)&(T<>SYMBOL) & (V) & (SEL=TRUE)))") vs.NameClass(ACName) # Return active class DataVisualizationsInfo.vwx 1 Existing Object.vsm 2 Demo Object.vsm 3 New Object.vsm
  20. LOL or just change FSActLayer to h. I didn't even stop to think about that. I was assuming that FSActLayer was passing the handle from : def SetAttribute(h): container = 'none' #set global variable phase = 'Demo' def SetPIOAttribute(h): global container #declare global variable to be retained vs.SetRecord(h,'Construction Phase') #add record to inserted object vs.SetRField(h,'Construction Phase','Phase', phase) #modify record to inserted object itChild = vs.GetTypeN(h) #Get Child type (not necessary) hParent = vs.GetParent(h) #Get Parent handle itParent = vs.GetTypeN(hParent) #Get Parent type #If Parent type is a wall set container to state PIOinwallwasdetected if itParent == 68: container = 'PIOinwallwasdetected' #Add and change record of wall and PIO or symbols inserted in wall def SetAttribute(h): vs.SetRecord(h,'Construction Phase') vs.SetRField(h,'Construction Phase','Phase', phase) h1 = vs.FIn3D(h) while h1 != (): if vs.GetTypeN(h1) == 15: vs.SetRecord(h1,'Construction Phase') vs.SetRField(h1,'Construction Phase','Phase', phase) if vs.GetTypeN(h1) == 86: vs.SetRecord(h1,'Construction Phase') vs.SetRField(h1,'Construction Phase','Phase', phase) h1=vs.NextObj(h1) vs.ForEachObject(SetPIOAttribute, "((NOTINDLVP & NOTINREFDLVP & ((PON='Door')|(T=SYMBOL)|(PON='Window')) & (V) & (SEL=TRUE)))") #If PIO was selected and wall was not then container var PIOinwallwasdetected is true then script will end if not then wall was selected and script will continue to def SetAttribute if container != 'PIOinwallwasdetected': vs.ForEachObject(SetAttribute, "((NOTINDLVP & NOTINREFDLVP & (V) & (SEL=TRUE)))")
  21. I thought it was working perfectly but it does if I select one wall at a time. In that instance it will change the wall and all the PIO objects within but If I select several walls it does not edit all of the PIO objects, it only edits the PIO in the first item selected. container = 'none' #set global variable phase = 'Existing' def SetPIOAttribute(h): global container #declare global variable to be retained vs.SetRecord(h,'Construction Phase') #add record to inserted object vs.SetRField(h,'Construction Phase','Phase', phase) #modify record to inserted object itChild = vs.GetTypeN(h) #Get Child type (not necessary) hParent = vs.GetParent(h) #Get Parent handle itParent = vs.GetTypeN(hParent) #Get Parent type #If Parent type is a wall set container to state PIOinwallwasdetected if itParent == 68: container = 'PIOinwallwasdetected' #Add and change record of wall and inserted items (only changes wall at this time) def SetAttribute(h): vs.SetRecord(h,'Construction Phase') vs.SetRField(h,'Construction Phase','Phase', phase) h1 = vs.FIn3D(vs.FSActLayer()) while h1 != (): vs.SetRecord(h1,'Construction Phase') vs.SetRField(h1,'Construction Phase','Phase', phase) h1=vs.NextObj(h1) vs.ForEachObject(SetPIOAttribute, "((NOTINDLVP & NOTINREFDLVP & ((PON='Door')|(T=SYMBOL)|(PON='Window')) & (V) & (SEL=TRUE)))") #If PIO was selected and wall was not then container var PIOinwallwasdetected is true then script will end if not then wall was selected and script will continue to def SetAttribute if container != 'PIOinwallwasdetected': vs.ForEachObject(SetAttribute, "((NOTINDLVP & NOTINREFDLVP & (V) & (SEL=TRUE)))")
  22. Not inserting the symbol in the wall or using PIO seems to be the best course of action. The symbols visualization works fine if is not nested in a wall. If it is nested I can remove it and re-nest it and the visualization works fine. I still think this is a glitch since it just takes some sort of refresh to make it work. That being said vs.redrawall() does not work (it actually causes every item changed not to refresh). For the most part I think I can work around it but it a bit aggravating.
  23. I added your script to mine and it works great but I think I found a Vectorworks bug. This is a view of a wall with objects after running the script on the symbol in the wall. As you can see in the record the phase has been changed to Existing but the appearance still shows as New. Now if I change the Object Criteria in the Data Visualization or close and reopen the drawing the symbol in wall will appear correctly. I have set my graphic settings up and down with no change. PIO object change fine, I only have this issue with symbols in wall and the issue is not isolated to the script. If I change the phase manually I have the same issue. container = 'none' #set global variable phase = 'Existing' def SetPIOAttribute(h): global container #declare global variable to be retained vs.SetRecord(h,'Construction Phase') #add record to inserted object vs.SetRField(h,'Construction Phase','Phase', phase) #modify record to inserted object itChild = vs.GetTypeN(h) #Get Child type (not necessary) hParent = vs.GetParent(h) #Get Parent handle itParent = vs.GetTypeN(hParent) #Get Parent type #If Parent type is a wall set container to state PIOinwallwasdetected if itParent == 68: container = 'PIOinwallwasdetected' #Add and change record of wall and inserted items (only changes wall at this time) def SetAttribute(h): vs.SetRecord(h,'Construction Phase') vs.SetRField(h,'Construction Phase','Phase', phase) vs.ForEachObject(SetPIOAttribute, "((NOTINDLVP & NOTINREFDLVP & ((PON='Door')|(T=SYMBOL)|(PON='Window')) & (V) & (SEL=TRUE)))") #If PIO was selected and wall was not then container var PIOinwallwasdetected is true then script will end if not then wall was selected and script will continue to def SetAttribute if container != 'PIOinwallwasdetected': h1 = vs.FIn3D(vs.FSActLayer()) while h1 != (): if vs.GetTypeN(h1) == 15: vs.SetRecord(h1,'Construction Phase') vs.SetRField(h1,'Construction Phase','Phase', phase) if vs.GetTypeN(h1) == 86: vs.SetRecord(h1,'Construction Phase') vs.SetRField(h1,'Construction Phase','Phase', phase) h1=vs.NextObj(h1) vs.ForEachObject(SetAttribute, "((NOTINDLVP & NOTINREFDLVP & (V) & (SEL=TRUE)))")
  24. I made this script to apply a record to items selected. The goal is the following: If object in wall is selected add and change record to the object in the wall only. (works as designed) If wall is selected add and change record to the wall and all objects inserted in the wall. (Only changes the wall not the inserted objects) #set global variable container = 'none' def SetPIOAttribute(h): global container #declare global variable to be retained vs.SetRecord(h,'Construction Phase') #add record to inserted object vs.SetRField(h,'Construction Phase','Phase','New') #modify record to inserted object itChild = vs.GetTypeN(h) #Get Child type (not necessary) hParent = vs.GetParent(h) #Get Parent handle itParent = vs.GetTypeN(hParent)#Get Parent type if itParent == 68: #If Parent type is a wall set container to state PIOinwallwasdetected container = 'PIOinwallwasdetected' #Add and change record of wall and inserted items (only changes wall at this time) def SetAttribute(h): vs.SetRecord(h,'Construction Phase') vs.SetRField(h,'Construction Phase','Phase','New') vs.ForEachObject(SetPIOAttribute, "((NOTINDLVP & NOTINREFDLVP & ((PON='Door')|(T=SYMBOL)|(PON='Window')) & (V) & (SEL=TRUE)))") #If PIO was selected and wall was not then container var PIOinwallwasdetected is true then script will end if not then wall was selected and script will continue to def SetAttribute if container != 'PIOinwallwasdetected': vs.ForEachObject(SetAttribute, "((NOTINDLVP & NOTINREFDLVP & (V) & (SEL=TRUE)))")

 

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.

×
×
  • Create New...