Jump to content

NTT

Member
  • Posts

    6
  • Joined

  • Last visited

Posts posted by NTT

  1. Hallo
    I managed to write a python script in script palette for this function (converting multiple user selected objects to one 2D symbol) . I have two questions:

    1. the newly created symbol is not placed in the center of the new object !!!

    2. how do I export and share the script .py file with other users so that they import it from server and use it? 

    Thank you

    image.thumb.png.f08566794e9fda9c5aecf8744de8349b.png

     

    # written by NNT 27.9.2023
    
    import vs;
    
    objs = []
    
    def GetBBoxCenter (h):        
            box = vs.GetBBox(h)
            topL2D = box[0]
            botR2D = box[1]
            center = [None, None]
            BB_width  = botR2D[0] - topL2D[0]
            BB_height = topL2D[1] - botR2D[1]
            center[0] = topL2D[0] + BB_width / 2
            center[1] = topL2D[1] - BB_height / 2
            center = tuple (center)
            return (center, BB_width)
            
    def collect(handle):
    	objs.append(handle)
    
    # collect visible selected objects
    vs.ForEachObject(collect, '((VSEL=TRUE))')
    vs.AlrtDialog('Anzahl der ausgewählten Objekte: {}'.format(len(objs)))
    
    # create new Symbol in Document
    newSymNameDefault = 'YourNewSymbol'
    newSymName = vs.StrDialog("Neues Symbol Name",newSymNameDefault)
    vs.SetOriginAbsolute(0,0,0)
    vs.BeginSym(newSymName)
    vs.Locus(0,0,0)
    h = vs.LNewObj()
    vs.EndSym()
    
    h_sym = vs.GetObject(newSymName)
    
    # add/set first obj to symbol
    objSym = objs[0]
    vs.SetPlanarRef(objSym, 0) # 0 is ref ID for Screen plane
    vs.SetParent(objSym, h_sym)
    vs.ResetObject(objSym)
    vs.ResetObject(h_sym)
    vs.Set2DComponentGroup(h_sym, objSym, 10) # this command works for screen plane objects only
    
    # replace all selected objs with new symbol
    # get original symbol obj center and width for rotation angle comparison
    objSymCenter, objSymWidth = GetBBoxCenter(objSym)
    for i,obj in enumerate(objs):
    		objCenter, objWidth = GetBBoxCenter(obj)
    		rotAngle = 0
    		if objWidth != objSymWidth:
    			rotAngle = 90
    		newSym = vs.Symbol(newSymName, objCenter, rotAngle)
    		vs.ResetObject(obj)
    		vs.ResetObject(newSym)
    		vs.DelObject(obj)
    
    vs.AlrtDialog('Symbol "{}" ist in Zubehör Manager'.format(newSymName))

     

  2. Hello Community,

     

    I am trying to subtract / clip some polygons but I keep getting the original polygons with the Result. see below.
    I tried to find out polygons that have similar area then remove the duplicates by original list indices, unfortunately, it didn't work. any clue how can i achieve the desired result below? Thanks

     

    Manually, I would select all, clip surface , then delete the resulted selected polygon (automatically selected from Vectorworks)

     

    Desired Result:

     

     Screenshot2023-06-12at19_13_56.thumb.png.73382cd5a7dc3b3b1339e8a6ccf4fbad.pngp

     

    Script Result:

     

    Screenshot2023-06-12at19_15_37.thumb.png.c2b7b22eb78e25645c7363950593c75b.png

  3. Hello

    Any updates on this issue? it still happens when I copy a Data Tag from another file. it reverts to the default values when I paste it (it happens for both options, keeping the current file style or replace it with the copied style). I had to rename them every time I paste. now I have same Tag with different names in Resource manager 😕

    Thanks

    macOS Ventura 13.3.1 VW Architect 2023 SP4

×
×
  • Create New...