×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Available Text Expressions in FileSummaryInfo
2

Available Text Expressions in FileSummaryInfo

Available Text Expressions in FileSummaryInfo

(OP)
When adding Custom Properties for components I've noticed that, depending on the part, certain "Text Expressions" are available for one part and unavailable for others.  For example, I'm told by our engineers that the Text Expression for a "Thickness" property is only available for a sheet metal part, which makes sense.
Since I'm writing a macro that checks every part in an assembly to ensure that all neccessary properties (for a Bill of Materials) have been entered, I need to know how I can determine if the "Thickness" property is available as a Text Expression for a part?  I can determine this by manually opening a part and brining up the Summary Info window and checking the "Value / Text Expression" drop-down list to see if "Thickness" is listed.

How can I do this in a macro?  Or, how can I determine if a part is a "sheet metal" part? Can anyone help me with this?

RE: Available Text Expressions in FileSummaryInfo

Hi shawn
For the Thickness property in the Summary info window you can use the ModelDoc2::CustomInfo2 (this will give you all the property that exist in the summary info window)

For the sheet metal part search in the EquationManager (ModelDoc2::GetEquationMgr) and search for an equation which contain the word "thickness". In a sheet metal part you always have a thickness value in the equation manager (it represent naturly the thickness of your sheet metal part).

Hope this help

##################################
Stef
SW 2006 SP4.1 Win XP Pro SP2
www.technaxindustrie.com
##################################

RE: Available Text Expressions in FileSummaryInfo

(OP)
Thanks Stef!  That looks like what I need.  However, I'm having some difficulty getting some results. Can you take a look at my code and tell me if I'm doing something wrong. I'm not getting any errors, but the line where I call

ExCount = swEqnMgr.GetCount

I get "0" every time, as if there are no properties available for the part.

CODE

Sub CheckEquations()

Dim ExCount     As Long
Dim ExCycle     As Long
Dim EqItem      As String
Dim swEqnMgr    As SldWorks.EquationMgr
Dim SheetMetal  As Boolean

Set Part = swApp.ActiveDoc
Set swEqnMgr = Part.GetEquationMgr

ExCount = swEqnMgr.GetCount

For ExCycle = 0 To ExCount
    EqItem = swModel.GetEquationMgr.Equation(ExCycle)
    If InStr(EqItem, "Thickness") <> 0 And InStr(EqItem, "Volume") <> 0 Then
        SheetMetal = True
        Else: SheetMetal = False
    End If
Next ExCycle

End Sub

RE: Available Text Expressions in FileSummaryInfo

(OP)
Another note...

When I do this:

Debug.Print "  Status = " & swEqnMgr.Status


after setting the SldWorks.EquationMgr object - I get the value "-1" which, according to SW API Help, is the "Index of the equation" and will return "-1" if there was an error.

Still not sure why I'm getting an error.

RE: Available Text Expressions in FileSummaryInfo

The thickness appears to be a linked value rather than an actual equation.  Linked values show up in the feature manager design tree under the equations folder, but they are handled differently in the API.  You can verify this by adding an equation to a sheet metal part you're working with.  The GetCount should then return "1".  

In order to find whether the part is sheet metal by searching for the "Thickness" string you are going to have to iterate through all the dimensions of the model looking for one that is linked and is named "Thickness".  There is a code example in the API help to find linked dimensions.

On a side note, your code line

If InStr(EqItem, "Thickness") <> 0 And InStr(EqItem, "Volume") <> 0 Then

will only be true if EqItem is a string that contains both "Thickness" and "Volume".  My test sheet metal part doesn't have any equation or linked value with the word "Volume" in it.

Also, you probably want to change the line

EqItem = swModel.GetEquationMgr.Equation(ExCycle)

to

EqItem = swEqnMgr.Equation(ExCycle)


Good luck!

RE: Available Text Expressions in FileSummaryInfo

(OP)
Just to make sure we're on the same page here...

I understand the "equations" to be the expressions in the FileSummaryInfo window (aka Custom Properties) e.g., ""SW-Volume@PSC-18.SLDPRT"" is a text expression that is evaluated as something like "3.63".  It IS linked somehow, to what I'm not sure.

The code I'm working with and the examples on "linked dimensions" I've read in SW API don't seem to quite jive with these Custom Property expressions. I made the changes that Handleman suggested but

CODE

swEqnMgr.GetCount
still returns "0" on every part, which shouldn't be the case if we're looking at available expressions for custom props...

Am I missing something?

RE: Available Text Expressions in FileSummaryInfo

Shawn,
There seem to be a couple of questions going on here that are getting mixed up.  Your original question was how to determine if a certain text expression will be available in the dropdown box.  Your example was that "Thickness" is only available for sheet metal parts.  

Every part will have the values available for all of the mass type properties (Mass through Lzz).  These are automatically calculated by SolidWorks.

Additionally, the names of any linked dimensions and any global variables will be available in that box.  Please see the SolidWorks help on what linked values and global variables are.

Any time you make a part to be sheet metal, SolidWorks automatically adds a linked dimension named "Thickness".  The names and values of linked dimensions are displayed in the feature manager under the "Equations" folder.  I believe this may be where some confusion came in.  Linked dimensions are not actually equations, and they are not accessible from the EquationMgr object.  Therefore, in order to determine if a part is sheet metal or not you will need to iterate through the dimensions and look for one that is linked and named "Thickness".  

Equations are entirely different from custom properties.  Equations define relationships between dimensions of a model.  Please see the SolidWorks help on equations for a good explanation.  The equation count for any part will be zero unless you add an equation to the part.

RE: Available Text Expressions in FileSummaryInfo

Shawn
I apologize for the confusion.
I've never test the Thickness (linked value) in the equation manager so I've put you on the wrong way.
But for the custom property (File summary info window) I'm sure it's good.

Hope this help

##################################
Stef
SW 2006 SP4.1 Win XP Pro SP2
www.technaxindustrie.com
##################################

RE: Available Text Expressions in FileSummaryInfo

(OP)
Stef,

No problem, I know well enough these things can be confusing, 3eyes but even when we get side-tracked, we can learn new things.  In this case, I learned about the difference between "Equations" and "Linked Dimensions" in Solidworks - so I thank you for that!

Handleman,

Once again you get 2thumbsup and a medal !  Thanks for clearing this up for me.  You were right - I was confused on the terminology.  I knew what I was looking for but I'm not as well-versed with Solidworks as I am with VB, so I didn't know the correct term for what I needed.
In this case, "Linked Dimensions" is exactly where I needed to go, and I did find a great example in Solidworks API Help, called the "Get Linked Dimensions Example".  I tried it, and it does exactly what I want!  Now I just need to tweak it a little...

Thanks again everyone!!

RE: Available Text Expressions in FileSummaryInfo

No problem, Shawn.  Apologies if my last post seemed a bit brusque.  I was in a bit of a hurry when I typed it, and now that I read it again my references to the help files could sound condescending, which was certainly not my intention.  The help files just do a better job at explaining the terminology than I could.

I certainly don't envy your position of trying to write SolidWorks API code without being primarily a SolidWorks user yourself.  It's much easier to find the right stuff in the API when you use the same functionality through the user interface on a daily basis.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources