Jump to content

The Hamma

Member
  • Posts

    360
  • Joined

  • Last visited

Posts posted by The Hamma

  1. Since we a group in an office we have created a workgroup folder to keep our libraries common among all users.   This works great except when it comes to Custom callout libraries.  As you see I have a custom library chosen in by callout dialog named VA_Keynotes.txt. 

    image.thumb.png.82d16150a6a9d3c483b137436f4d4a0d.png

    And the next slide shows what I see when I press the Choose button.  (the typical windows explorer window) This is my personal Notes folder contained within my personal user folder. 

    If I want to choose the database that is in my workgroup folder I have to navigate to the server and down into the workgroup library to choose the database. 

    image.thumb.png.acc7264cd201c955ca02ac6610300cdd.png

       In my opinion this should show me library similar to the one below so that I can quickly choose the database that is the workgroup folder instead of having to navigate to it every time I start a new drawing

    image.thumb.png.b632ba8ba401011e127728cfae0fe8c1.png

  2. On 12/1/2020 at 11:11 PM, michaelk said:

    Is that a screen shot of VW or a PDF?  

     

    The original image I posted was from a PDF and the resolution in the worksheet preferences was set at 600 dpi

    On 12/1/2020 at 11:24 PM, Pat Stanford said:

    In the Worksheet menu, check the preferences and see what you have the Images DPI set to. It appears to be broken. on my machine 72 DPI looks pretty close to what is on the layer while 300 DPI has all of the lines very thin and washed out.

    This one is at 72 dpi.  I agree this must be broken.  I will try to submit it as a bug. 

    image.thumb.png.d3432f08f1b874b255527bbc5b4fd3e7.png

    • Like 1
  3. I requested the feature be added to Vectorworks but I have also created a script, record and data tag workaround.  I have attached the sample vectorworks file.

     

    Only works or roof faces so you have to ungroup your roof to use this. 

    Next you need to run the script included to assign the pitch to a record that is attached to each face.  

    Then you can use the tag to tag the roof faces in plan.  

     

    Note: this is been customized for inch pitches on a 12" run.  The script would have to be modified if you want to use it for a different run dimension. 

     

    image.thumb.png.e3f95ec48c73624edcb94b93090cbf91.png

     

     

    Roof Pitches on Plan.vwx

  4. Ha!  I knew I could drag them up and down but I did not realize pressing the bar at the top would sort them.   Weird thing is that they are still out of order in your example.  Pressing the sort button on the number column does not work but it does work when I press the Description column.  Thank you so much for the insight. 

     

    I did create a worksheet to display and sort my keynotes because I could not get this to work.   I may still end up using the worksheet because I can filter keynotes by sheets and layers rather than going through the process of assigning keynotes to individual keynote lists.  

     

    FYI the hidden value to display the text of a keynote is ='Callout'.'Text'

     

    image.thumb.png.b79d6397222fd2b555646035b66422a2.png

    • Like 1
  5. We use a database of keynotes based on CSI spec section numbers and when we place them we don't place them in numerical order.  This is an issue because the keynote legend is based on the order that the note was dropped.  Does anyone have a work around to reorder the keynotes in the legend to be sorted in ascending order?  I know I can edit the legend and move them up and down manually but this is more work than should be necessary. 

    Sample file is attached. 

     

    image.thumb.png.29295c0ea3fb40d9ccf2a46733107150.png

    CALLOUTS AND KEYNOTES.vwx

    • Like 1
  6. 1 hour ago, JBenghiat said:

    Using ForEachObjectInList() instead of iterating with NextObj() is the easiest method (choosing the descend into groups option).

     

    Otherwise, make your while statement into a function. At the top of the function, check if the type of H1 is a symbol folder, and if so, call the function (recursively) on FInGroup(H1). Otherwise, process the symbol.

     

    I will give that a try, thank you. 

     

    1 hour ago, Pat Stanford said:

    Do you really intend to store the data from a single symbol instance into EVERY symbol definition in the drawing?

     

    I did revise it t a bit since I posted i but it cycles through the list of symbols in the resource browser and looks for the matching symbol in the drawing. When it finds it if it has the 'ITEM' record it copies the values from the symbol in the drawing and rewrites the values to the matching symbol in the resource browser.  I am using this because I have a customer that reuses equipment over and over but sometimes it gets revised.  I have an equipment schedule that pulls the info from the symbols in the drawing.  I am writing this script because if you edit the record on the symbol or from the schedule the record attached to the symbol in the resource browser is not updated by that edit.  This script will update the resource browser.  

  7. The following script writes back the records to the matching symbol from a symbol that have been edited in a the drawing.  The problem is that it only works on the symbols in the root of the resource browser but does not work on symbols that are in folders.  How do I make this script edit every symbol in the resource browser for the current drawing?

     

    {$DEBUG}
    PROCEDURE ItemRecordtosymbol;
    VAR
       countObj : INTEGER;
       lts,it1 : INTEGER;
       s3,itemname,grabsymbol,rITEM,rDESCRIPTION,rMANUFACTURER,rMODEL,rFURNISHEDBY,rINSTALLEDBY,rFLAMPS,rKW,rHP,rVOLTS,rPHASE,rDIRECTPOWER,rPLUG,rFILTERED,rCOLD,rHOT,rDIRECTWASTE,rINDERECTWASTE,rSIZE,rMBTUH,rREMARKS,rITEMGROUP,rREVISION:string;
       h,H1:handle;
    
    PROCEDURE ExplodeSymbols(h :HANDLE);
    BEGIN
    	rITEM := GetRField(h,'ITEM','ITEM');
    	rDESCRIPTION := GetRField(h,'ITEM','DESCRIPTION');
    	rMANUFACTURER := GetRField(h,'ITEM','MANUFACTURER');
    	rMODEL := GetRField(h,'ITEM','MODEL');
    	rFURNISHEDBY := GetRField(h,'ITEM','FURNISHED BY');
    	rINSTALLEDBY := GetRField(h,'ITEM','INSTALLED BY');
    	rFLAMPS := GetRField(h,'ITEM','FL-AMPS');
    	rKW := GetRField(h,'ITEM','KW');
    	rHP := GetRField(h,'ITEM','HP');
    	rVOLTS := GetRField(h,'ITEM','VOLTS');
    	rPHASE := GetRField(h,'ITEM','PHASE');
    	rDIRECTPOWER := GetRField(h,'ITEM','DIRECT POWER');
    	rPLUG := GetRField(h,'ITEM','PLUG');
    	rFILTERED := GetRField(h,'ITEM','FILTERED');
    	rCOLD := GetRField(h,'ITEM','COLD');
    	rHOT := GetRField(h,'ITEM','HOT');
    	rDIRECTWASTE := GetRField(h,'ITEM','DIRECT WASTE');
    	rINDERECTWASTE:= GetRField(h,'ITEM','INDIRECT WASTE');
    	rSIZE:= GetRField(h,'ITEM','SIZE');
    	rMBTUH:= GetRField(h,'ITEM','MBTUH');
    	rREMARKS:= GetRField(h,'ITEM','REMARKS');
    	rITEMGROUP:= GetRField(h,'ITEM','ITEM GROUP');
    	rREVISION:= GetRField(h,'ITEM','REVISION');
    END;
    
    
    
    Begin
    H1:=FSymDef;
    While H1 <> Nil do
     Begin
           	itemname := GetName(H1);
    		ForEachObject(ExplodeSymbols,((INSYMBOL & INOBJECT & INVIEWPORT & (T=SYMBOL) & (S=itemname))));
    		SetRField(H1,'ITEM','ITEM',rITEM);
    		SetRField(H1,'ITEM','DESCRIPTION',rDESCRIPTION);
    		SetRField(H1,'ITEM','MANUFACTURER',rMANUFACTURER );
    		SetRField(H1,'ITEM','MODEL',rMODEL);
    		SetRField(H1,'ITEM','FURNISHED BY',rFURNISHEDBY );
    		SetRField(H1,'ITEM','INSTALLED BY',rINSTALLEDBY );
    		SetRField(H1,'ITEM','FL-AMPS',rFLAMPS );
    		SetRField(H1,'ITEM','KW',rKW );
    		SetRField(H1,'ITEM','HP',rHP );
    		SetRField(H1,'ITEM','VOLTS',rVOLTS );
    		SetRField(H1,'ITEM','PHASE',rPHASE );
    		SetRField(H1,'ITEM','DIRECT POWER',rDIRECTPOWER );
    		SetRField(H1,'ITEM','PLUG',rPLUG );
    		SetRField(H1,'ITEM','FILTERED',rFILTERED );
    		SetRField(H1,'ITEM','COLD',rCOLD );
    		SetRField(H1,'ITEM','HOT',rHOT );
    		SetRField(H1,'ITEM','DIRECT WASTE',rDIRECTWASTE );
    		SetRField(H1,'ITEM','INDIRECT WASTE',rINDERECTWASTE);
    		SetRField(H1,'ITEM','SIZE',rSIZE);
    		SetRField(H1,'ITEM','MBTUH',rMBTUH);
    		SetRField(H1,'ITEM','REMARKS',rREMARKS);
    		SetRField(H1,'ITEM','ITEM GROUP',rITEMGROUP);
    		SetRField(H1,'ITEM','REVISION',rREVISION);
       H1:=NextObj(H1);
     End;
    End;
    
    Run(ItemRecordtosymbol);

     

  8. I have a spreadsheet with a list of equipment and each piece of equipment is identified with a unique id.  I also have symbols in the drawing with a record attached and a matching field for every column in the spread sheet.   I was able to create a report based on the record and I am able to copy cell by cell manually from the imported spread sheet to the record report worksheet.  My question is has anyone written a script that would search a worksheet for a matching id and copy all of the following cells in the row to the other worksheet?

  9. Worked perfectly.  I am still learning Python but I find it much simpler than vectorscript. Thank you.

     

    """
    This script assigns Item record to symbols in resource manager and instances in drawing. 
    It uses the name of the symbol for the value of the Item record. 
    
    It was useful when using a data tag to tag equipment in an equipment plan and elevations. 
    I was able to assign the same record to groups in the elevations and use the same data 
    tag to mark the items in the elevation.  
    
    This Python Script may be freely distributed. No warranty provided.
    Use at your own risk.
    
    David Hamer, 2020-08-30
    """
    
    def setrecord(h):
    	vs.SetRecord(h, 'ITEM')  # add record to symbols in drawing
    	vs.SetRField(h, 'ITEM', 'ITEM', itemname)  # modify record of the symbol in drawing
    
    h = vs.FSymDef()
    while h != []:
    	global itemname
    	itemname = vs.GetName(h)
    	vs.SetRecord(h, 'ITEM')  # add record to symbols in root folder of resource manager
    	vs.SetRField(h, 'ITEM', 'ITEM', itemname)  # modify record of symbol in root folder of resource manager
    	vs.ForEachObject(setrecord, "(S='"+itemname +"')") #selects symbols of same name in drawing and runs setrecord
    	h = vs.NextObj(h) #Looks for next symbol in resouce manager

     

  10. When using vectorscript I can use the following line with itemname being a variable. 

     

    ForEachObject ( ExplodeSymbols , ( (INSYMBOL & INOBJECT & INVIEWPORT & (T=SYMBOL) & (S=itemname) ) ) );

     

    But when using python i can use the itemname as a variable because the criteria is required to be inserted in quotes. 

    vs.ForEachObject ( ExplodeSymbols , "( ( INSYMBOL & INOBJECT & INVIEWPORT & (T=SYMBOL) & (S=itemname) ) ) "  );

     

    Does anyone know if there is a way around this.  I tried to replace everything inside the qoutes with a vs.concat created string but it kept asking for a right parenthesis.  Tried to add extra parenthesis to no avail. 

    def setrecord(h):
    	vs.SetRecord(h, 'ITEM')  # add record to inserted object
    	vs.SetRField(h, 'ITEM', 'ITEM', itemname)  # modify record to inserted object
    
    
    # Modifications to any objects happen here
    h = vs.FSymDef()
    while h != []:
    	global itemname
    	itemname = vs.GetName(h)
    	vs.SetRecord(h, 'ITEM')  # add record to inserted object
    	vs.SetRField(h, 'ITEM', 'ITEM', itemname)  # modify record to inserted object
    	grabsymbol = vs.Concat('setrecord',',"S=',itemname,'"')
    	vs.ForEachObject(grabsymbol)
    	h = vs.NextObj(h)

    I did rewrite the script in vectorscript as follows and it worked so I am just asking for future reference. 

     

    PROCEDURE ItemRecordfromsymbolname;
    VAR
       itemname:string;
       h,H1:handle;
    
    PROCEDURE ExplodeSymbols(h :HANDLE);
    BEGIN
    	AlrtDialog('running');
    	SetRecord(h, 'ITEM');
    	SetRField(h, 'ITEM', 'ITEM', itemname);
    END;
    
    
    Begin
    H1:=FSymDef;
    While H1 <> Nil do
     Begin
           	itemname := GetName(H1);
    		SetRecord(H1, 'ITEM');
    		SetRField(H1, 'ITEM', 'ITEM', itemname);
    		ForEachObject(ExplodeSymbols,((INSYMBOL & INOBJECT & INVIEWPORT & (T=SYMBOL) & (S=itemname))));
       H1:=NextObj(H1);
     End;
    End;
    
    Run(ItemRecordfromsymbolname);

     

  11. Does anyone know if the studio drivers are better than the gaming drivers for Nvidia geforce cards?

     

    From Nvidia driver download page

    """"

    Game Ready Drivers provide the best possible gaming experience for all major games. NVIDIA's driver team exhaustively tests games from early access through release of each DLC to optimize for performance, stability, and functionality. These drivers are certified by Microsoft’s Windows Hardware Quality Labs (WHQL).
     

    Studio Drivers provide the best possible experience for key creative applications. NVIDIA does extensive testing across the top creative applications to ensure the highest levels of performance, stability, and functionality. These drivers are certified by Microsoft’s Windows Hardware Quality Labs (WHQL).

    """"

  12. Script has been edited to omit objects selected on layers that are visible but not editable because layer options are not set to "Show/Snap/Modify Others"

     

    """
    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 08-13-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:
            hSEL.append(h)   # adds to list
            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:
            hSEL.append(h)  # adds to list
            h1 = vs.FIn3D(h)
            while h1 != []:
                if vs.GetObjectVariableInt(vs.GetLayer(h1), 154) == activetype:
                    if vs.GetTypeN(h1) == 15:
                        hSEL.append(h1)  # adds to list
                    if vs.GetTypeN(h1) == 86:
                        hSEL.append(h1)  # adds to list
                h1 = vs.NextObj(h1)
    
    
    def sl_processing(h):  # Omit's Viewports in Sheet Layers
        if vs.GetTypeN(h) != 122:
            assign(h)
    
    hSEL = [] # defines list to contain handles to all selected objects 
    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)))")
    	for h in hSEL:
    		if vs.GetPrefInt(506) != 5:
    			if vs.GetLayer(h) == vs.ActLayer():
    				assign(h)
    		else:
    			assign(h)
    				
    vs.NameClass(ACName)  # Return active class

     

  13. Ok, I can use

    from VPRename_A import hVP, numberStr

    to retrieve hVP and numberStr from VPRenumb_A

     

    Now that I have that solved It does not seem to fix my issue with the script.  

     

    If I run script "VP Label (Consecutive)" from the workspace and I place "VPRenumb_A.vsm"  in the workspace and call it via "vs.DoMenuTextByName('VPRenumb_A', 0)" it actually leaves my script to run the second script and this completes without giving me any messages about renumbering the drawing labels.  

     

    If I run script "VP Label (Consecutive)" from the workspace and I place "VPRenumb_A.py"  in the plugins folder and call it via "from VPRename_A import hVP, numberStr" it actually imports the "VPRenumb_A.py" into the first script to run and this completes giving me a warning messages about renumbering the drawing labels.  

     

    Is there a way to call an external python script without running it within the first script like "vs.DoMenuTextbyName" does? Note I still need to receive or send variables to or from the second script and not all of the labels redraw correctly.

     606774933_Annotation2020-08-05101109.thumb.png.bdaa6d650ea9f4be025a1e86ceadc9cf.png1352412360_Annotation2020-08-05093443.thumb.png.c5177bd8cf75339e4ec592c7a1bcd23e.png

     

    I have attached the two versions. 

     

     

    VP Label (Consecutive) (DoMenubytextName).zip VP Label (Consecutive) (import).zip

  14. """
    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)

     

    • Like 1
  15. The script creates several classes at once and would not know which class to assign the selected object to. I will think about it and if any ideas come to mind I will script them down.  On another note the script above would change the settings of previously created classes created by this script when running it a second time.  I have modified the script to only create a new class if it does not exist and to give you a list of all the newly created classes when it is finished. 

     

    """
    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 Revised 2020-07-31
    """
    
    ClassPrefix ='I-FNSH-' #Newly created classes prefix
    runtimes = 0
    
    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) 
    	ClassCount = vs.ClassNum()  # determine number of classes in drawing
    	vs.NameClass(TextureClassName)
    	if ClassCount + 1 == vs.ClassNum():
    		runtimes = runtimes + 1
    		if runtimes == 1:
    			allclasses = TextureClassName
    		else:
    			allclasses = vs.Concat(allclasses, ', ', 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
    
    if runtimes != 0:	
    	vs.AlrtDialog('New Classes Created: ', allclasses)
    else:
    	vs.AlrtDialog('No new Classes created')

     

  16. On 7/29/2020 at 12:22 PM, Pat Stanford said:

    I thought that import vs is needed to allow Python to see all of the vectroscript commands.

     

    I figured it out, if you run the python script as an external script that is imported via another script the "import vs" is needed, but when run directly from within vectorworks it is not.  

    • Like 1
×
×
  • Create New...