2 Replies Latest reply on Nov 7, 2013 9:24 AM by Tony Szuta

    Remove Material

    Tony Szuta

      Hi everyone. It's been quite a while since I dabbled with any sort of code. I've got a simple task at hand that I hope someone can help me out with.


      All that I am trying to do is remove material that has been assigned to a part. As for assigning material, I've got that working OK. I just need to do the opposite.


      Here is the line of code I am using to apply a material from our library:


           swPart.SetMaterialPropertyName2 swApp.GetActiveConfigurationName(swPart.GetTitle), "**PathRemoved**/CustomMaterialLibrary.sldmat", "304 SS, 7 GA."


      I've skimmed through the API help but can't seem to find what I am after. I have tried swPart.DELETEFRIGGINMATERIAL but for some reason it doesn't seem to work. LOL


      Thanks in advance. Any help is appreciated as usual.

        • Re: Remove Material
          Deepak Gupta

          Try these codes:

          Sub main()

              Dim swApp                       As SldWorks.SldWorks

              Dim swModel                     As SldWorks.ModelDoc2

              Dim swPart                      As SldWorks.PartDoc

              Dim sMatDB                      As String


              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set swPart = swModel


              swPart.SetMaterialPropertyName2 "", "", ""


          End Sub