Jump to content
sully8391

Import Symbol from User Libraries

Recommended Posts

Hi all,

 

I have some plugin objects that I would like to use predefined symbols instead of drawing their geometry for each instance, but I'm having a lot of trouble figuring out how to import a symbol from a user library. It looks like the functions under "Document List Handling" might hold the key, but I can't make any sense out of them. Is what I'm trying to do possible? What would a basic script for this look like?

 

Thanks!

Share this post


Link to post

You seem to be on the right track with Document List Handling.

Basically you need to build a resource list. Since there are your symbols and you should know the name, I would start with BuildResourceListN. This will return a ListID into a LongInt that you will use to identify the list in the laters calls.

Then iterate throughout the resource list using GetNamefromResourceList and checking that against the symbol name you want.

Once you locate the index of the symbol you want, import it into the current file with ImportResoucetoCurrentFile.

 

And as there are a multiple versions of most of the above functions/procedures, you will have to read the manual and experiment with what works best for you.

 

Ask again if you need more help.

Share this post


Link to post

Thanks for this! I finally got it working. GetNameFromResourceList, and variations on that, will return empty strings/handles if called before ImportResourceToCurrentFile. In my case that's no big deal, because I intend to import all of the symbols anyway. It's also worth noting that the resource list starts its indices at 1.

 

  • Like 1

Share this post


Link to post

You should be able to get the name of the resource before you import. You cannot get handles to objects outside of the current document, as only objects from open documents get loaded into memory. Generally, I will use GetObject for each name on the list, and if the handle is nil, import the resource.

  • Like 1

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...