"Magic" custom properties via API?
"Magic" custom properties via API?
(OP)
I am trying to set some custom properties via the API to take advantage of SolidWorks' "magic" properties, like:
"SW-MATERIAL@Part1.SLDPRT" to get the material name
"D2@Sketch2@Part1.SLDPRT" to get a dimension's value
etc.
However, when I add these values in, what I get is the literal spelling of the magic property, not the evaluable version that SolidWorks generates. I've tried generating the property name with and without the surrounding quotes. Neither way seems to work.
Currently running SWX2007. The help is, as usual, not much help.
Is there a secret control character? Type code? handshake?
Please help.
"SW-MATERIAL@Part1.SLDPRT" to get the material name
"D2@Sketch2@Part1.SLDPRT" to get a dimension's value
etc.
However, when I add these values in, what I get is the literal spelling of the magic property, not the evaluable version that SolidWorks generates. I've tried generating the property name with and without the surrounding quotes. Neither way seems to work.
Currently running SWX2007. The help is, as usual, not much help.
Is there a secret control character? Type code? handshake?
Please help.






RE: "Magic" custom properties via API?
- swModel.Parameter(DimName).SystemValue
Also try the Help, go to SolidWorks/Main Menu/SolidWorks and Add-Ins API Help TopicsKen
RE: "Magic" custom properties via API?
RE: "Magic" custom properties via API?
It does not matter if you use the new CustomPropertyManager or the older Doc.AddCustomInfo calls.
The magic syntax for pretty much any of the SW-XXXX@PART values (Material, Mass, Volume, Density, Surface Area, Center-of-mass, moments of inertia, etc.) refuses to work if the callout is in all-caps.
"SW-MATERIAL@PART.SLDPRT" fails to resolve.
"SW-Material@Part.SLDPRT" works.
"SW-Material@PART.SLDPRT" works. The filename does NOT appear to be case-sensitive.
Interestingly, the dimension callouts are NOT case sensitive. This is good, because now I can make my code work. It's bad for my blood-pressure though.
Why? Why? I ask myself. Why couldn't the smart people in Concord make custom property names, values, and magic uniformly case-sensitive or case-insensitive? And why couldn't they document it either way?
I just know there's a fascinating explanation lurking behind it all.
William.
RE: "Magic" custom properties via API?