Last active
August 29, 2015 14:06
-
-
Save justinmilo/bbc1d64f28509737b601 to your computer and use it in GitHub Desktop.
Vectorworks Make Unique Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', '') | |
return | |
# 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', '') | |
return | |
#... | |
# 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 | |
vs.DSelectAll() | |
vs.MoveTo(0,0) | |
# 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.BeginSym(cPre) | |
vs.SymbolToGroup(nextObjH, 0) | |
nextObjH = vs.FSActLayer() | |
vs.HUngroup(nextObjH) | |
vs.EndSym() | |
#JSBase.printObjects("*handle after creating symbol*", h) | |
vs.DelObject(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