Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
Vectorworks Make Unique Command
import vs;
import JSBase
from imp import reload
reload (JSBase)
# Only works on 3D symbols not inside a group.
# maybe only works in plan view // Havent tested
def duplicateSymbolDefinition(h): #handle to symbolDefinition
# check for 2D vs 3D vs Hybrid
# 0 - 2D Only 1 - 3D Only 2 - Hybrid
symT = vs.GetSymbolType(h)
# return empty if not a 3D symbol
if symT != 1:
vs.AlertInform('Error: Unsuported Symbol Type', 'Make Unique does not work for Hybrid symbols', '')
# check if it's in a group when making uniqe ...
# ... for some reason copying of geometry doesnt' stay within group in current implementation below
layerH = vs.GetParent(h)
# return empty if inside a group
if layerH == JSBase.VSEnums.ObjectType.Group:
vs.AlertInform('Error: Unsuported Parent Type', 'Make Unique does not work inside groups', '')
# Save name, origin, and rotation for Symbol
name = vs.GetSymName(h)
pointx, pointy = vs.GetSymLoc(h)
rot = vs.GetSymRot(h)
# Deselect and move to center of drawing before adding new symbol
# May need to change for list handeling
# Duplicate symbol at origin and get handle
vs.Symbol(name, 0, 0, 0)
nextObjH = vs.FSActLayer()
cPre = vs.StrDialog('Name duplicate symbol', name)
# Create new symbol at
vs.SymbolToGroup(nextObjH, 0)
nextObjH = vs.FSActLayer()
#JSBase.printObjects("*handle after creating symbol*", h)
vs.Symbol(cPre, pointx,pointy,rot)
vs.ForEachObject(duplicateSymbolDefinition, "(VSEL=TRUE)");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment