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.
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?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With