Jump to content

hharker

Member
  • Posts

    2
  • Joined

  • Last visited

Posts posted by hharker

  1. Hi there all,

     

    At our office we use a master classes file, that is referenced into all of our drawings, where all class attributes can be centrally controlled and propagated throughout drawing packs. 

    However right now we're having to use two - one for the design files (showing various line colours for easier drawing), and the other for Sheet/Print Files (with a restricted printable line colour palette - mainly red  / black / grey)

    It's a bit of a pain having to have two of the these (as they quickly go out of sync with each other, as classess are added or modified) - so I'm writing on the forum to ask if anyone has found a way around this - to just have one master classes file?


    I'm also open to completely different ways of controlling classes across drawing packs - as I expect the tech has moved on so open to better ways of doing this.

     

    Thanks in advance!

    Ross

     

  2. On 11/5/2018 at 2:09 PM, twk said:

    Here you go:

    You need to turn on all your classes visibilities (obviously)

     

    import vs
    
    def classes_name_list(createOrder=0):
        """
        createOrder=0, no sorting, list sorted based on class creation order
        createOrder=1, sorted Alphabetically
        """
    
        classes_total = vs.ClassNum()
        classNameList = []
        for x in range(classes_total):
            classNameList.append(vs.ClassList(x + 1))
    
        if createOrder == 0:
            return classNameList
        elif createOrder == 1:
            classNameList.sort(key=lambda x: x.lower())
            return classNameList
    
    layer_scale = vs.GetLScale(vs.ActLayer()) #page mm scale 1:1
    square_dim = 5 * layer_scale
    spacing = 7 * layer_scale
    
    groups = []
    for clasN in classes_name_list(1):
        vs.BeginGroup()
    
        vs.Rect((-square_dim,square_dim/2),(0,-square_dim/2))
        RECT = vs.LNewObj()
        vs.SetClass(RECT,clasN)
        vs.CreateText("{}".format(clasN))
        TEXT = vs.LNewObj()
    
        # set text vertical align and horizontal align = center, left
        vs.SetTextVerticalAlign(TEXT,3)
        vs.SetTextJust(TEXT, 1)
        vs.HMove(TEXT,spacing,0)
    
        # move text in place on right of rectangle
        vs.EndGroup()
        groups.append(vs.LNewObj())
    
    for i, group in enumerate(groups):
        if i != 0:
            prev_group = groups[i - 1]
    
            prev_group_bbox = vs.GetBBox(prev_group)
            group_bbox = vs.GetBBox(group)
    
            vs.HMove(group,0,(prev_group_bbox[1][1])-spacing)

     

    Cheers

    twk - how do I implement this script?
    I've tried copying it into 'textedit' and saving the file as a .txt file - but the 'import script' in vectorworks does not work. There's a vital basic step I'm missing here.
    Thanks 

×
×
  • Create New...