twk Posted March 1, 2021 Share Posted March 1, 2021 Greetings, I'm trying to read default record field values from another file using the BuildResourceListN function: def vs.BuildResourceListN(type, fullPath): return (LONGINT, numItems) I manage to read in the record names from the other file, however using the GetResourceFromList function returns NIL on resource handles. And, as the dev wiki documentation describes, this will return NIL if resource is not in document. Is there another function call I'm missing? or is this not possible. I see that the titleblock tool can open and display issue data from another file. How is it doing this? @JBenghiat, @Vlado, anyone? Thanks in advance Quote Link to comment
JBenghiat Posted March 1, 2021 Share Posted March 1, 2021 If the handle is NIL, you need to import the resource, take what information you need, and then delete it. You only get the handle if the resource is in the current file. The resource manager has the ability to show attached records in other files. I believe this is due to cached data and happened at the core level, so a script can't do something similar. I could be wrong, though. Quote Link to comment
twk Posted March 1, 2021 Author Share Posted March 1, 2021 Hmm, yes that is what I'm currently doing, importing then deleting. I thought there was a different way. Thanks for the insight. I'm looking at the build resource list calls, in what use case would the addResoureceToList function call be used for? Is it just a container mechanism for VS? The same functionality can be done using lists in python correct? Quote Link to comment
JBenghiat Posted March 2, 2021 Share Posted March 2, 2021 The python API still parallels the VectorScript API, so none of the functions are particularly geared towards python's capabilities. The resource "list" is not related to an actual python list. Behind the scenes, the list is a c++ container, and the LONGINT variable the functions use is essentially a pointer to that container. You can, of course, construct you own functions that output the various Vectorworks calls into python lists. 1 Quote Link to comment
Vectorworks, Inc Employee Vlado Posted March 8, 2021 Vectorworks, Inc Employee Share Posted March 8, 2021 That is a special index to an internal list created with the build function, and only accessible with the appropriate functions. @Lada can you help with this question? 1 Quote Link to comment
Vectorworks, Inc Employee Lada Posted March 10, 2021 Vectorworks, Inc Employee Share Posted March 10, 2021 JBenghiat is right. There is no way to get a resource from a non-active document. The only possibility is to import the resource, do what you need and delete the resource. 2 Quote Link to comment
Jayme McColgan Posted June 19, 2023 Share Posted June 19, 2023 hey everyone! I'm poking this bear again... just confirming that there's still no way to read records of symbols in another file. the idea of importing the symbol, checking the records, then deleting is very slow since the other files can have lots of symbols. i can make it somewhat better by breaking up the symbols int subfolders but then I'm relying on the end user to maintain that idea. Quote Link to comment
DomC Posted June 20, 2023 Share Posted June 20, 2023 Hi A possible workaround I once used is: 1. I had a big library document with much of Elements. Importing, reading informations, delete/purge would be time-consuming. 2. On the library document running a script after every change. The Script dumps the needed informations to a file which contains the metha-data from the library file 3. Or alternatively dump to a text object inside a symbol (I think does not work with too much data because of text size limitation maybe) and just import that index symbol to read source data 4. If the process should be automated there could be used a custom "save" command which dumps the data automatically before saving the file import json def update_library(): log_info = [] log_info_sym = [] counter_sym = 0 counter_xg = 0 listID, numItems = vs.BuildResourceList(16, 0, '') # Symbols dumps = {} SymbolLibraryDump = None for i in range(1, numItems + 1): counter_sym += 1 res_name = vs.GetNameFromResourceList(listID, i) sym_h = vs.GetResourceFromList(listID, i) if sym_h != vs.Handle(0): t = vs.GetTypeN(sym_h) found_cabinet = functions.get_XG_Cabinet_h_in_symbol(sym_h) if found_cabinet: dump = functions.attach_infos(sym_h, found_cabinet) dumps[res_name] = dump counter_xg += 1 log_info_sym.append(f"{res_name} {dump}") else: pass # log_info.append('kein Korpusmöbel gefunden') if 'SymbolBibliothekDump' in res_name: SymbolLibraryDump = sym_h else: vs.AlrtDialog(str(res_name)) if SymbolLibraryDump: vs.DelObject(SymbolLibraryDump) log_info.append('Daten an Symbole anghängen:') log_info.append(f"{counter_sym} Symbole im Dokument-Zubehör") log_info.append(f"{counter_xg} Symbole mit KM im Dokument-Zubehör") log_info = log_info + log_info_sym field_value = json.dumps(dumps, indent=1) vs.BeginSym('SymbolBibliothekDump' + vs.Date(2, 2)) vs.CreateText(field_value) vs.EndSym() log_info.append('Dump Symbol generiert (index zum auslesen aus anderen Dateien)') log_info = rename_symbols(log_info) return log_info Quote Link to comment
Recommended Posts
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.