Jump to content
connered

Add Object from Library with Python

Recommended Posts

Hey,

I`m new to Vector Works and try to write a script to place objects from Library files to the scene . Can someone give me a start point for that ?

Thanks

Share this post


Link to post

Here's my base functions that load up a symbol in the folder inside my plugins user folder called "JRSPlugins/JRSPythonProjectsLinked/VWXSymbols"

I have a gist of this code here: https://gist.github.com/justinmilo/d85a048cb1ec4ce54270#file-jsbase-py

ef JRSymbol(name, x, y, rotation):

if not symbolExists(name):

importSymbol(name)

vs.Symbol(name, x, y, rotation)

return vs.LNewObj()

def importSymbol(id):

aListID = 1

objectType = 16 #Symbol Index

folderIndex = -2 # Plug-In Data Folder (negative means user folder)

aListID, numOfItems = vs.BuildResourceList( objectType , folderIndex, "JRSPlugins/JRSPythonProjectsLinked/VWXSymbols")

aString = ""

for i in range(0, numOfItems):

#myInt = vs.InsertImagePopupResource (dialog1, 4, aListID, i)

name = vs.GetNameFromResourceList (aListID, i)

if name == id:

vs.ImportResourceToCurrentFile(aListID, i)

def symbolExists (id):

objectType = 16 #Symbol Index

folderIndex = 0 # Current Document

aListID, numOfItems = vs.BuildResourceList( objectType , folderIndex, "")

for i in range(0, numOfItems):

name = vs.GetNameFromResourceList (aListID, i)

if name == id:

return True

return False

def Symbol2D3D(SymString, X, Y, Z, Xr, Yr, Zr):

JRSymbol (SymString, X, Y, Xr)

vs.Move3DObj(vs.LNewObj(), 0, 0, Z)# to move an individual

Edited by Justin Smith

Share this post


Link to post

i try to use your source - where do you call the Symbol3D or Symbol2D3D

by direct call i get an error "Error: Statement must follow creation of a 3D object."

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×