Bug in Solidworks API for Custom Properties?
Bug in Solidworks API for Custom Properties?
(OP)
I seem to have found a Solidworks API oddity or bug...
When I use the following code (below) to add a custom property Name "Volume" with a Value of
"SW-Mass@P-24-3-6.SLDPRT", it almost works as expected. The value is added correctly, exactly as it should be.
However, when I check the results of the macro by opening the part and looking at the custom properties, the evaluated value is not "evaluated" properly. It is still displayed as "SW-Mass@P-24-3-6.SLDPRT". But if I click the drop-down list and select the "Volume" property, the Evaluated Value changes to an actual number, (0.06) as it should, although the value "SW-Mass@P-24-3-6.SLDPRT" doesn't change at all, not one character.
Is this a bug, or am I missing something?
[code]
'Check for missing props and add as needed
If ThkDef = False Then Part.AddCustomInfo3 "", "Thickness", swCustomInfoText, Chr(34) & "Thickness@" & CStr(ShortName) & Right(swChildComp3.GetPathName, 7) & Chr(34)
If VolDef = False Then Part.AddCustomInfo3 "", "Volume", swCustomInfoText, Chr(34) & "SW-Mass@" & CStr(ShortName) & Right(swChildComp3.GetPathName, 7) & Chr(34)
[/code}
When I use the following code (below) to add a custom property Name "Volume" with a Value of
"SW-Mass@P-24-3-6.SLDPRT", it almost works as expected. The value is added correctly, exactly as it should be.
However, when I check the results of the macro by opening the part and looking at the custom properties, the evaluated value is not "evaluated" properly. It is still displayed as "SW-Mass@P-24-3-6.SLDPRT". But if I click the drop-down list and select the "Volume" property, the Evaluated Value changes to an actual number, (0.06) as it should, although the value "SW-Mass@P-24-3-6.SLDPRT" doesn't change at all, not one character.
Is this a bug, or am I missing something?
[code]
'Check for missing props and add as needed
If ThkDef = False Then Part.AddCustomInfo3 "", "Thickness", swCustomInfoText, Chr(34) & "Thickness@" & CStr(ShortName) & Right(swChildComp3.GetPathName, 7) & Chr(34)
If VolDef = False Then Part.AddCustomInfo3 "", "Volume", swCustomInfoText, Chr(34) & "SW-Mass@" & CStr(ShortName) & Right(swChildComp3.GetPathName, 7) & Chr(34)
[/code}
Shawn Oelschlager
Production Control Ass't
Transco Products Inc.
http://www.transcoproducts.com
SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM






RE: Bug in Solidworks API for Custom Properties?
CODE
Const PARTNAME as String = "Part1.SLDPRT"
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.AddCustomInfo3 "", "TestName1", swCustomInfoText, Chr(34) & "SW-Mass@" & PARTNAME & Chr(34)
swModel.AddCustomInfo3 "", "TestName2", swCustomInfoText, Chr(34) & "Thickness" & "@" & PARTNAME & Chr(34)
MsgBox "Mass: " & swModel.GetCustomInfoValue("", "TestName1")
MsgBox "Thickness: " & swModel.GetCustomInfoValue("", "TestName2")
End Sub
RE: Bug in Solidworks API for Custom Properties?
I have to apologize because this seems to be another case of my "jumping to conclusions". I'm not sure what happened, but this was a problem I was having on Saturday and when I tried again today, I too was unable to duplicate the issue. It seems to be working fine now, so I guess we can call this one "case dismissed"!
P.S. - I couldn't find an emoticon for "DOH?!"
Maybe something like [homersimpson]? LOL
Anyway, thanks handleman and have a great day!
Shawn Oelschlager
Production Control Ass't
Transco Products Inc.
http://www.transcoproducts.com
SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM