KN_Michael Posted February 28, 2020 Share Posted February 28, 2020 (edited) I have the handle of a symbol definition and want to know where this symbol comes from. The symbol window shows this information, so at least VW can internally get this name. Can I somehow find out the file name from which a symbol definition comes from as well? VWSymbolDefObj symbolDef = ...; bool isReferenced = gSDK->IsObjectFromReferencedFile(symbolDef); if (isReferenced) { // how to continue here? TXString refFileName = ???; } Edited February 28, 2020 by KN_Michael Quote Link to comment
PatW Posted February 28, 2020 Share Posted February 28, 2020 (edited) In case no one comes up with a better solution you could try it by checking the referenced files for the symbol. When the symbol you want to check is in the resource list off the file it should be referenced. (I assume that ther ewould be conflict when you reference a file that has sym "A" and sym "A" is already in the master file). VectorWorks::TVWArray_ReferencedFileInfo outRefFilesInfo; gSDK->GetReferencedFilesInfo(outRefFilesInfo); VectorWorks::SReferencedFileInfo info = outRefFilesInfo.GetAt(0); // Iterate trough the total count info.winFilePathName; // Build a resource list and check if the Symbol is contained. http://developer.vectorworks.net/index.php/VS:BuildResourceListN regards, Patrick Edited February 28, 2020 by PatW Quote Link to comment
KN_Michael Posted March 2, 2020 Author Share Posted March 2, 2020 (edited) I've seen this function already and checked it but I don't know what to do with the data returned in my case. I get the file paths of all referenced files but what now? I can not check if the symbol comes from this path or not with any function, can I? I did not find any... My only idea now would be to programmatically open each file, check if it contains the symbol and close it again - which is not very useful in my case as I want to show the information for all symbols inside a dialog. And this is not how VW internally does it when you open the resource browser and check the symbols. Edited March 2, 2020 by KN_Michael Quote Link to comment
Hippocode Posted March 3, 2020 Share Posted March 3, 2020 I faced a similar issue trying to find out if some of my custom plug-ins were referenced or not. I used the following approach which seemed to work as the "IsObjectFromReferencedFile" function didn't (always) return the expected results you can just look at the object's layer name instead. // Referenced? fInfo.IsReferenced = gSDK->IsObjectFromReferencedFile(this->GetThisObject()) || gSDK->IsViewportGroupContainedObject(this->GetThisObject(), kViewportGroupCrop); // Since above doesn't work :( MCObjectHandle hLayer = this->GetParentLayer(); if(hLayer && VWLayerObj::IsLayerObject(hLayer)) { VWLayerObj L(hLayer); TXString strLevel = L.GetName(); fInfo.IsReferenced = strLevel.Find("NNA") != -1; // NNA seems to be put in all referenced layers, so any object that is referenced matches this parent layer name. } Quote Link to comment
KN_Michael Posted March 4, 2020 Author Share Posted March 4, 2020 Thanks for the alternative solution, but I'm looking for a way to find out the filename of the referenced file that belongs to a symbol. The reason is, we have files with a lot of symbols (thousands, coming from imports) that are only used once and we want to provide a possibility to show our users a list of symbols that should be removed but therefore we must tell them in which file the symbol is defined. Quote Link to comment
Hippocode Posted March 4, 2020 Share Posted March 4, 2020 Couldn't find any constant to read that property in the minicads file. I vagely remember when building lists the filename was used as prefix or something similar but that would require you to build a huge list of all available resources, which is still a valid possibility. From looking at this article, one of the other similar functions will probably return the filename within the symbolname if from an external file, but it might only work if those are duplicate: http://developer.vectorworks.net/index.php/VS:GetActualNameFromResourceList You could also try using the IResourceManagerContent VCOM interface to search for the specific symbols, maybe some of the functions also return the filename. Quote Link to comment
Stefan Bender Posted August 14, 2020 Share Posted August 14, 2020 You might try calling VWResourceList::BuildList(short objectType, IFileIdentifier* fileID); Quote Link to comment
Pat Stanford Posted August 15, 2020 Share Posted August 15, 2020 The Vectorscript function GetNamefromResourceList will return the name the file is in if there are multiple items with the same name. The file is appended to the end in parentheses. So theoretically you could import the resource, run GetNameFromResourceList, parse it to get the file name and then delete the imported version. NVE. (Not Very Elegant). I hope there is a better way to do this using the SDK. 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.