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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


 

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.

×
×
  • Create New...