The Hamma Posted August 1, 2020 Share Posted August 1, 2020 (edited) """ This a global script that affects all sheet layers. It classes all objects on sheet layers as follows. Viewport Drawing labels to class = Sheet-Label Viewport Annoatations to class = Sheet-Anno Viewports and sheet items = Sheet-Main Redlines remain on Notes-Redlines or A-ANNO-REDL All classes listed above are turned on on all viewports. This Python Script may be freely distributed. No warranty provided. Use at your own risk. David Hamer, 2020 revision 07-31-2020 """ # collect handles of selected VPs on active layer def GetHandle(h): if vs.GetObjectVariableInt(vs.GetLayer(h), 154) == 2: if vs.GetObjectVariableString(h, 1166) != 'Redline Object': vs.SetClass(h, 'Sheet-Main') if vs.GetTypeN(h) == 122: hVP.append(h) ACName = vs.ActiveClass() # Record name of active class ClassCount = vs.ClassNum() # determine number of classes in drawing vs.NameClass('Sheet-Main') # Creates class if it does not exist and sets properties if ClassCount + 1 == vs.ClassNum(): vs.NameClass('Sheet-Main') vs.SetClFillFore('Sheet-Main',0,0,0) vs.SetClFillBack('Sheet-Main',0,0,0) vs.SetClPenFore('Sheet-Main',65535,65535,65535) vs.SetClPenBack('Sheet-Main',65535,65535,65535) vs.SetClFPat('Sheet-Main',1) vs.SetClLSN('Sheet-Main',2) vs.SetClLW('Sheet-Main',10) vs.EnableCLDropShadow('Sheet-Main',False) vs.SetClUseGraphic('Sheet-Main',True) ClassCount = vs.ClassNum() # determine number of classes in drawing vs.NameClass('Sheet-Label') # Creates class if it does not exist and sets properties if ClassCount + 1 == vs.ClassNum(): vs.NameClass('Sheet-Label') vs.ShowClass('Sheet-Label') vs.SetClFillFore('Sheet-Label',0,0,0) vs.SetClFillBack('Sheet-Label',0,0,0) vs.SetClPenFore('Sheet-Label',65535,65535,65535) vs.SetClPenBack('Sheet-Label',65535,65535,65535) vs.SetClFPat('Sheet-Label',1) vs.SetClLSN('Sheet-Label',2) vs.SetClLW('Sheet-Label',28) vs.EnableCLDropShadow('Sheet-Label',False) vs.SetClUseGraphic('Sheet-Label',True) ClassCount = vs.ClassNum() # determine number of classes in drawing vs.NameClass('Sheet-Anno') # Creates class if it does not exist and sets properties if ClassCount + 1 == vs.ClassNum(): vs.NameClass('Sheet-Anno') vs.ShowClass('Sheet-Anno') vs.SetClFillFore('Sheet-Anno',0,0,0) vs.SetClFillBack('Sheet-Anno',0,0,0) vs.SetClPenFore('Sheet-Anno',65535,65535,65535) vs.SetClPenBack('Sheet-Anno',65535,65535,65535) vs.SetClFPat('Sheet-Anno',1) vs.SetClLSN('Sheet-Anno',2) vs.SetClLW('Sheet-Anno',10) vs.EnableCLDropShadow('Sheet-Anno',False) vs.SetClUseGraphic('Sheet-Anno',True) vs.NameClass(ACName) # Return active class hVP = [] vs.ForEachObjectInLayer(GetHandle, 0, 2, 1) # Traverse into the annotations group of selected VPs and set classes for VP in hVP: vs.SetVPClassVisibility(VP,'Sheet-Anno',0) vs.SetVPClassVisibility(VP,'Sheet-Label',0) vs.SetVPClassVisibility(VP,'Sheet-Main',0) vs.SetVPClassVisibility(VP,'Notes-Redlines',0) vs.SetVPClassVisibility(VP,'A-ANNO-REDL',0) anno = vs.GetVPGroup(VP, 2) h = vs.FInGroup(anno) objs = [h] h = vs.NextObj(h) while h != vs.Handle(0): if vs.GetObjectVariableString(h, 1166) == 'Drawing Label': vs.SetClass(h, 'Sheet-Label') vs.SetLWByClass(h) vs.SetFPatByClass(h) vs.SetLSByClass(h) vs.SetFillColorByClass(h) vs.SetOpacityByClass(h) vs.SetPenColorByClass(h) else: if vs.GetObjectVariableString(h, 1166) != 'Redline Object': vs.SetClass(h, 'Sheet-Anno') if vs.GetTypeN(h) == 11: gobj = vs.FInGroup(h) while gobj != []: vs.SetClass(gobj, 'Sheet-Anno') gobj = vs.NextObj(gobj) h = vs.NextObj(h) Edited August 1, 2020 by The Hamma 1 Quote Link to comment
Jiajing Posted January 3, 2023 Share Posted January 3, 2023 @The Hamma Thank you for the code, it is very helpful. Circling back to it, I am having hard to find those INDEXes from Appendix, for instance, not sure 1166 means in GetObjectVariableString, is there a doc with full list of index. Quote Link to comment
The Hamma Posted January 3, 2023 Author Share Posted January 3, 2023 4 minutes ago, Jiajing said: Circling back to it, I am having hard to find those INDEXes from Appendix, for instance, not sure 1166 means in GetObjectVariableString, is there a doc with full list of index. Find it here https://developer.vectorworks.net/index.php/VS:Function_Reference_Appendix_F or the root https://developer.vectorworks.net/index.php/VS:Function_Reference_Appendix 1 Quote Link to comment
Jiajing Posted January 3, 2023 Share Posted January 3, 2023 (edited) 11 minutes ago, The Hamma said: Find it here https://developer.vectorworks.net/index.php/VS:Function_Reference_Appendix_F or the root https://developer.vectorworks.net/index.php/VS:Function_Reference_Appendix The first link is what I was missing. Thank you Edit: I still can not find what is 1166 for in both links @The Hamma Edited January 3, 2023 by Jiajing Quote Link to comment
Jesse Cogswell Posted January 3, 2023 Share Posted January 3, 2023 It would appear that the online function reference is out of date and incomplete. Looking at the local function reference (found in the Vectorworks application folder in a folder called "VWHelp"), it lists 1166 as Parametric Localized Name. It looks like the online appendix is missing a bunch of these. Quote Link to comment
Jiajing Posted January 3, 2023 Share Posted January 3, 2023 @Jesse Cogswell I even didn't know it exsits locally. Thank you for the info Quote Link to comment
Pat Stanford Posted January 3, 2023 Share Posted January 3, 2023 I have submitted the difference between the two appendices as a Bug. VB-192538. 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.