Setting material using API in SW2005
Setting material using API in SW2005
(OP)
How do I set the material for a part in SW05 using Visual Basic? I am using:
but it doesn't work. I don't get any error just the part does not update.
Another question:
When I declare variables like
i get an error saying that user type is not defined. It works if I use Object instead of SldWorks.PartDoc.
Thanx for help
Andrew
CODE
Part.SetMaterialPropertyName "sldmaterials.sldmat ", "HRS"
but it doesn't work. I don't get any error just the part does not update.
Another question:
When I declare variables like
CODE
Dim Part as SldWorks.PartDoc
i get an error saying that user type is not defined. It works if I use Object instead of SldWorks.PartDoc.
Thanx for help
Andrew






RE: Setting material using API in SW2005
PartDoc.SetMaterialPropertyName(database, name) is obsolete in Sw2005 SP0.1
Use PartDoc.SetMaterialPropertyName2( configName, database, name). This might solve your 1rst problem.
I cannot reproduce the second problem on my system. Check your project's references to see if you are referencing the SW 2005's libraries ("Sldwork 2005 Type Library" and "Sldwork 2005 Constants Type Library") and not one of the previous version (2004, 2003 ...)
One test will be to see if your code compile correctly in a vba module. If not, and if the syntax is correct, you might try to uninstall and re-install sw.
Hope this help
RE: Setting material using API in SW2005
I fixed the second part of my question by checking the SolidWorks libraries in the project's references.
The first part still doesn't work. I know
PartDoc.SetMaterialPropertyName(database, name) is obsolete in Sw2005 SP0.1. Still, it should work.
Anyway, I tried to use PartDoc.SetMaterialPropertyName2( configName, database, name) and I got the same result. The program run's smoothly with no error, does everything else of what is supposed to do just the material of the part it is not updated.
There is something I'm missing here. I hope someone can enlighten me.
RE: Setting material using API in SW2005
What environment are you programming in? VB6? Another macro editor?
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: Setting material using API in SW2005
RE: Setting material using API in SW2005
CODE
Are you sure the "HRS" material really exists in your database?? And btw, I dont have the sldmaterials.sldmat on my system.
Grtz, Bouke
RE: Setting material using API in SW2005
CODE
Is "sldmaterials.sldmat " parameter supposed to have that extra space at the end inside the quotes?
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: Setting material using API in SW2005