Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bug in Solidworks API for Custom Properties?

Status
Not open for further replies.

shawn76o

Nuclear
Nov 14, 2006
31
0
0
US
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
[ignore]"SW-Mass@P-24-3-6.SLDPRT"[/ignore], 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 [ignore]"SW-Mass@P-24-3-6.SLDPRT"[/ignore]. 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 [ignore]"SW-Mass@P-24-3-6.SLDPRT[/ignore]" doesn't change at all, not one character.

Is this a bug, or am I missing something?

Code:
[green]'Check for missing props and add as needed[/green]
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.
[URL unfurl="true"]http://www.transcoproducts.com[/URL]

SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM
 
Replies continue below

Recommended for you

I've been unable to reproduce your issue on my machine. My only suggestion at this point would be to bring this function down to its simplest form and test it from there. Try this macro, changing the part name in the code to whatever part is active when you run it.

Code:
Sub main()
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
 
handleman,

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"! [purpleface]

P.S. - I couldn't find an emoticon for "DOH?!"
Maybe something like [ignore][homersimpson][/ignore]? LOL
Anyway, thanks handleman and have a great day!

Shawn Oelschlager
Production Control Ass't
Transco Products Inc.

SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM
 
Status
Not open for further replies.
Back
Top