Jump to content
Developer Wiki and Function Reference Links ×

Find name of referenced file for a symbol definition


Recommended Posts

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 by KN_Michael
Link to comment

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;
    VectorWorks::SReferencedFileInfo info = outRefFilesInfo.GetAt(0); // Iterate trough the total count
    info.winFilePathName; // Build a resource list and check if the Symbol is contained.





Edited by PatW
Link to comment

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 by KN_Michael
Link to comment

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.


Link to comment

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.

Link to comment

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.

Link to comment
  • 5 months later...

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.

Link to comment

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.

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