Jump to content

Add Object from Library with Python


Recommended Posts

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
Link to comment
  • 1 month later...

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.

×
×
  • Create New...