7 Replies Latest reply on Jun 3, 2016 12:02 AM by Deepak Gupta

    Get/Set Material Description

    Digvijay Taunk


      Does anyone know how to Get/Set material description shown in image below of "Edit Material" property of part. If "YES", I want to use it in assembly BOM. Can it be directly linked with custom property. I know, I can create a macro to add value in custom property if I get the description value, but I wanted to know is there any direct method to do that.



        • Re: Get/Set Material Description
          Digvijay Taunk

          Anyone... please

          • Re: Get/Set Material Description
            Alex Herzberg

            I am looking for the same information. Anyone know how to retrieve this information through a macro to export it into a custom property?

                • Re: Get/Set Material Description
                  Alex Herzberg

                  It set me on the right path at least. Looks like you have to go out to the .sldmat file and pull the data from there. I have modified a function I found to be able to go out and pull the material description. It is posted below. Hope this helps everyone.


                  Function GetCustomProperty(materialName As String, materialDatabaseFile As String) As String


                  '       materialName is the name of the material in the .sldmat material manager file

                  '       materialDatabaseFile is the full path filename of the .sldmat material manager file

                  '       customProperty is the Property Name as you entered it in the Custom Tab of the Material Manager


                  '       Material description as string

                  '       This could potentially be Double; I think the manager only accepts double values here.


                  'Reference to Microsoft XML, v 6.0  (although an earlier version will probably work -

                  '                   the .sldmat file itself is written in XML 1.0

                  Dim xml_doc As New DOMDocument

                  Dim brtn As Boolean

                  Dim onode As IXMLDOMElement



                  brtn = xml_doc.Load(materialDatabaseFile) 'xml_doc exiting reference



                  If brtn Then

                      For Each onode In xml_doc.selectNodes("//material")             'Get any nodes that are labeled as materials

                          If onode.getAttribute("name") = materialName Then           'Look for the material we are interested in

                          Debug.Print onode.getAttribute("name")

                          GetCustomProperty = onode.getAttribute("description")       'Get the description for the material we are interested in and set it to a variable

                          Debug.Print onode.getAttribute("description")

                          End If



                      MsgBox "Unable to open XML File"                                'Built in error message if it can't open the xml file

                  End If



                  End Function

              • Re: Get/Set Material Description
                Lee CS Young

                I have a macro that pulls custom properties from the material and puts them into the part's custom property. Contact me if you're interested.