Working with part materials using SOLIDWORKS API

Edit ArticleEdit Article

Material database in SOLIDWORKS is stored within the XML file. SOLIDWORKS API doesn't provide any direct methods of working with materials database (i.e. searching, adding, reading etc.). However as XML is an open format any XML parsing techniques would apply, i.e. using the XmlDocument, XmlSerializer etc.

ISldWorks::GetMaterialDatabases SOLIDWORKS API method returns the paths to material databases.

IPartDoc::GetMaterialPropertyName2 returns the name of the material and the name of the database this material is stored in.

This section contains examples explaining how to work with the materials database in SOLIDWORKS, how to apply and read material information from SOLIDWOKS parts and bodies.


All articles and code at CodeStack are now open-source and hosted on GitHub. If you want to contribute by modifying existing articles and code snippets, submitting new ones, reporting errors and bugs etc. please follow this blog post for more information. We appreciate any contribution.

Product of Xarial Product of Xarial