Jump to content
hybridobject

Importing Symbol Folder Ressources (Callback Function Problem)

Recommended Posts

Hi, 

 

I'm trying to import a list of symbol folders with all contained symbols from a source file and this works fine using 'vs.BuildResourceListN2' and 'vs.ImportResToCurFileN'.
I'm having trouble figuring out how the required callback function for 'vs.ImportResToCurFileN' is supposed to work though.

 

The first time I run the script in Work_file_B it successfully imports the list of symbol folders from Source_file_A. 
When I run the script again Vectorworks prompts me to rename the folder.
I would like it to be replaced though (and all the contents as well).

The documentation for 'vs.ImportResToCurFileN' says that you need a return value of '1' from the callback function to handle this.
However, this does not seem to work. Maybe I'm misunderstanding what the callback procedure does?


Background: 
I want to be able to make changes to symbols in a central file A. When I run the script in work files B,C,D,..... (that have the same symbol folders) I want to import and replace that set list 
of symbol folders and their content from file A to file B. This way I would be able to update all changes to symbols in the source file to all work files that run the script.

 

Would be great if someone could shed some light on the workings of the callback function.
i.e. Why does it have an input parameter but is not called with one?

 

Here is what my code looks like:

def callback(resName): # callback for 'vs.ImportResToCurFileN'-used in case of conflict (imported res already in cur file)
    ImportResCallback = 1 # '0' = Do not import ; 1' = replace ; '2' = rename
    return ImportResCallback

sourcePath = r"C:\Users\Username\My\Path\Source_File_A.vwx"
symFoldList = ["Symbols - Geometry", "Symbols - Text"]

importSymFoldListID, importSymFoldNumItems = vs.BuildResourceListN2(92, sourcePath, False)
importSymFoldDict = {}
for i in range(importSymFoldNumItems):
	importSymFoldName = vs.GetNameFromResourceList(importSymFoldListID, i + 1)
	importSymFoldDict[importSymFoldName] = i + 1

for foldername in symFoldList:
	vs.ImportResToCurFileN(importSymFoldListID, importSymFoldDict[foldername], callback)

vs.AlrtDialog(str(importSymFoldListID) + "\n" + str(importSymFoldNumItems) + "\n" + str(importSymFoldDict))

 

Source_File_A.vwx Work_File_B.vwx

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