Parameter eqution or number

Parameter eqution or number

Anonymous
Not applicable
280 Views
1 Reply
Message 1 of 2

Parameter eqution or number

Anonymous
Not applicable

How can i check if a parameter(User or Model) in a part is an equation(e.g. =a1+b1) or a number value(=20 mm)??? 

0 Likes
281 Views
1 Reply
Reply (1)
Message 2 of 2

HideoYamada
Advisor
Advisor

Hello vulic,

 

Check Parameter.DrivenBy.Count.

Sub test()
    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveEditDocument
    
    Dim partCompDef As PartComponentDefinition
    Set partCompDef = partDoc.ComponentDefinition
    
    Dim param As Parameter
    
    For Each param In partCompDef.Parameters
        Dim isDriven As Boolean
        
        isDriven = (param.DrivenBy.Count <> 0)
        Debug.Print param.Name & " = " & param.Expression & " : " & isDriven
    Next
End Sub

I run this macro with the document containing parameters follows.

Capture.PNG

And got this result.

param1 = 10 mm : False
param2 = 10 mm * 2 ul : False
param3 = param1 * 2 ul : True
d0 = 30 mm : False
d1 = d0 * 0.1 ul : True

"param2" consists from the equation, but the equation has no parameter, so the "param2" is treated as just a number.

If you want to know Parameter.Expression is a equation or not exactly, try to parse Parameter.Expression.

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes