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?
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
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
ExCount = swEqnMgr.GetCount
I get "0" every time, as if there are no properties available for the part.
CODE
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
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
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
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
Am I missing something?
RE: Available Text Expressions in FileSummaryInfo
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
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
No problem, I know well enough these things can be confusing,
Handleman,
Once again you get
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
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.