Setting parameter exposed as property via VB.NET

Setting parameter exposed as property via VB.NET

mslosar
Advisor Advisor
1,472 Views
5 Replies
Message 1 of 6

Setting parameter exposed as property via VB.NET

mslosar
Advisor
Advisor

I have a dialog that lets you format a part description for various different object types what we use.

 

I have about 9 combo boxes listing the available parameters in the dialog, though only 3 or 4 are used in a given part. 

 

I have a single control that passes the info to inventor, creates, formats, exposes/exports and configures the parameter but doesn't show up in the descriptions. Other controls do exactly the same thing and work just fine. I have a feeling i'm missing something but do not see it.

 

Here's the code

 

'if angle is chosen
        If RadioButton3.Checked Then
            If AngBoxL1.Text = "" Or AngBoxL2.Text = "" Or AngBoxThk.Text = "" Or AngBoxLen.Text = "" Then
                MsgBox("You must fill in all values.", vbOKOnly)
            Else
                cnum = InStr(1, AngBoxL1.Text, "||", CompareMethod.Text)
                ln = Strings.Right(AngBoxL1.Text, Len(AngBoxL1.Text) - (cnum + 2))
                'MsgBox(desc)
                SetOther(ln, "LEG1")
                cnum = InStr(1, AngBoxL2.Text, "||", CompareMethod.Text)
                ln = Strings.Right(AngBoxL2.Text, Len(AngBoxL2.Text) - (cnum + 2))
                'MsgBox(desc)
                SetOther(ln, "LEG2")
                cnum = InStr(1, AngBoxThk.Text, "||", CompareMethod.Text)
                ln = Strings.Right(AngBoxThk.Text, Len(AngBoxThk.Text) - (cnum + 2))
                'MsgBox(desc)
                SetOther(ln, "THK")
                cnum = InStr(1, AngBoxLen.Text, "||", CompareMethod.Text)
                ln = Strings.Right(AngBoxLen.Text, Len(AngBoxLen.Text) - (cnum + 2))
                'MsgBox(desc)
                SetLen(ln)
                descr = "=ANG, <LEG1> x <LEG2> x <THK>"
            End If
            DelParam("WIDTH")
            DelParam("THK")
        End If



Private Sub SetOther(ans As String, pm As String)
        Dim oPartDoc As PartDocument
        oPartDoc = g_inventorApplication.ActiveDocument
        'MsgBox("1")
        Dim param As Object
        Try
            param = oPartDoc.ComponentDefinition.Parameters.UserParameters.Item(pm)
            'MsgBox("2")
        Catch ex As Exception
            'Dim newparam As UserParameter = oPartDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("PL_LENGTH", ans, UnitsTypeEnum.kInchLengthUnits)
            Dim newparam As UserParameter = oPartDoc.ComponentDefinition.Parameters.UserParameters.AddByExpression(pm, ans, UnitsTypeEnum.kInchLengthUnits)
            'MsgBox("3")
        End Try
        oPartDoc.ComponentDefinition.Parameters.UserParameters.Item(pm).Expression = ans
        oPartDoc.ComponentDefinition.Parameters.UserParameters.Item(pm).ExposedAsProperty = True
        'MsgBox("4")
        oPartDoc.ComponentDefinition.Parameters.UserParameters.Item(pm).CustomPropertyFormat.Units = UnitsTypeEnum.kInchLengthUnits
        oPartDoc.ComponentDefinition.Parameters.UserParameters.Item(pm).CustomPropertyFormat.Precision = CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
    End Sub

The only parameter not working is THK. Like I said. It pulls the correct value, assigns it to the parameter, the export checkbox is checked, the internal custom formatting is correct. It just doesn't show in the description field. The field is set to =ANG, <LEG1> X <LEG2> X <THK>

 

Leg1 and 2 work just fine. I get a black for THK even though it's set correctly. If i open it's Custom Property format dialog and just hit OK without touching anything, it pops right into the description.

 

Any help would be appreciated.

 

Thanks

0 Likes
Accepted solutions (1)
1,473 Views
5 Replies
Replies (5)
Message 2 of 6

bradeneuropeArthur
Mentor
Mentor

Hi.

 

Opart. Update 

Opart.save

 

Already tried that afterwards 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 6

mslosar
Advisor
Advisor

Did you respond to the right thread?

 

As i said, other parameters go through the exact same procedure and work just fine.

 

Just this one is not and i'd like to know why.

0 Likes
Message 4 of 6

bradeneuropeArthur
Mentor
Mentor

yes I did.

 

I meant the following:

 

oPartDoc.update

oPartDoc.save

 

What version of inventor are you using?

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 6

smilinger
Advisor
Advisor
Accepted solution

Well, simple.

First, because you deleted that "THK" parameter.

Second, this line of code, as I see, is not doing correct:
descr = "=ANG, <LEG1> x <LEG2> x <THK>"
even if it's correct, because you deleted THK, it will not get correct value.

Maybe try

descr.Expression = "=ANG, <LEG1> x <LEG2> x <THK>"

 

And, if you must delete that parameter, do not use expression in your property.

0 Likes
Message 6 of 6

mslosar
Advisor
Advisor

That was it. I caught it yesterday morning. Just starting at too many lines way too long 🙂

 

as for the descr = bit, it's not the description property - it's just text at that point. Later on i tack additional lines onto it if necessary.

 

Thanks!

0 Likes