Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting custom materials from solidworks

Tags:

c#

solidworks

First note I don't have solidworks installed on my computer, but use the files for a project.

Solidworks has the ability to make a custom tab to the file properties. In this tab you can find all kind of information about a model(part) that is made in solidworks.

I read out all these information and store it in a .txt file see image. Within this information you can find the material type of the part, where my question comes in.enter image description here

I know the material type, however in solidworks the user can also assign custom materials to the material that is defined in the custom properties. For example the material is just regular wood, but the user want this wood to be pink.

Is it possible to read out the custom materials that are attached to the material in custom properties?

like image 935
Desutoroiya Avatar asked Mar 23 '16 08:03

Desutoroiya


1 Answers

If you don't have SOLIDWORKS installed, you can use the document manager (requires active SOLIDWORKS subscription to get key) to access custom properties:

String sLicenseKey = "Your key from SOLIDWORKS";
SwDmDocumentOpenError nRetVal = 0;
SwDmCustomInfoType customInfoType;
SwDMClassFactory swClassFact = new SwDMClassFactory();
SwDMApplication swDocMgr = (SwDMApplication)swClassFact.GetApplication(sLicenseKey);
SwDMDocument17 swDoc = (SwDMDocument17)swDocMgr.GetDocument("C:\Filepath", SwDmDocumentType.swDmDocumentPart, false, out nRetVal);
SwDMConfigurationMgr swCfgMgr = swDoc.ConfigurationManager;
SwDMConfiguration14 swCfg = (SwDMConfiguration14)swCfgMgr.GetConfigurationByName("Config Name");
String materialProperty = swCfg.GetCustomProperty2("Property Name", out customInfoType);
like image 167
AndrewK Avatar answered Sep 25 '22 00:09

AndrewK