UserParameter Error

UserParameter Error

NachoShaw
Advisor Advisor
160 Views
1 Reply
Message 1 of 2

UserParameter Error

NachoShaw
Advisor
Advisor

Hey

 

Im getting thrown an error in my function. I have a User Parameter in my part called CONVERT_FT and its unit is set to ft. Here is my code

Friend Function QuantifyLengthAsFT(ByVal length As String) As String

            Dim ret As String = String.Empty

            Dim oParams As UserParameters = CType(_BMDef.Parameters.UserParameters, UserParameters)
            Dim ParameterUnits As UnitsTypeEnum = UnitsTypeEnum.kFootLengthUnits
            Try
                Dim P As UserParameter = oParams.Item("CONVERT_FT")

                P.Expression = length
                Dim r As Double = CType(oParams.Item("CONVERT_FT").Value, Double)
                ret = ConvertValueToFT(CType(r, Double)) & " " & P.Units
                P.Expression = "0 ft"
            Catch ex As Exception
                ret = "Not Value"
            End Try

            Return ret
        End Function

(Assume _BMDef is a ComponentDefinition)

 

As i step through the function, the error is thrown on this line

Dim P As UserParameter = oParams.Item("CONVERT_FT")

and the error is

{The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"}

 

I have another similar function with the unit as inches and that doesnt have an error

 

 

Any ideas?

 

 

 

Thanks

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


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

NachoShaw
Advisor
Advisor

figured it out, i was using the wrong document...

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes