setting Precision for Inventor Doc using API

setting Precision for Inventor Doc using API

BM_Ashraf
Advocate Advocate
606 Views
4 Replies
Message 1 of 5

setting Precision for Inventor Doc using API

BM_Ashraf
Advocate
Advocate

Hi ,

I managed to design a windows form to make some changes to a model, but i have a problem when the user inserts a numeric value in a text box. for example when the user inserts a value of 1970  i get in inventor parameters 1970.00000000 mm.  I've tried many times to adjust the Part Precision but it's not helping. Part lin dim Precision is set by default to 3 .

Here is also part of the code that i wrote,  hope you could help me to set that parameter to default and to get a result of 1970.00 mm

 

 

'Declare the Application object()
Dim oApplication As Inventor.Application

' Obtain the Inventor Application object.


' This assumes Inventor is already running.
oApplication = GetObject(, "Inventor.Application")

 

' Set a reference to the active document.
' This assumes a document is open.
Dim oCurrentDocument As PartDocument
oCurrentDocument = oApplication.ActiveDocument

 

' Get the custom property set.
Dim CustomPropSet As PropertySet
CustomPropSet = oCurrentDocument.PropertySets.Item("Inventor User Defined Properties")

 

Dim userParams As UserParameters
userParams = oCurrentDocument.ComponentDefinition.Parameters.UserParameters

 

Dim oUOM As UnitsOfMeasure
oUOM = oCurrentDocument.UnitsOfMeasure

 

' Get the enum value that defines the current default length units.
Dim eLengthUnit As UnitsTypeEnum
eLengthUnit = oUOM.LengthUnits

 

PanelHeight = txtPanelHeight.Text


Dim oparamh2 As Inventor.Parameter
oparamh2 = userParams.Item("h2")  'h2 is the panel height

oparamh2.Value = oUOM.GetValueFromExpression(PanelHeight, eLengthUnit)

 



Many Thanks
Ashraf

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.

Blue Mech

Add-ins for Inventor!

0 Likes
Accepted solutions (1)
607 Views
4 Replies
Replies (4)
Message 2 of 5

Ralf_Krieg
Advisor
Advisor

Hello

 

I don't believe there's an option for this. What's the problem if the parameter has more digits? You can always format this value if displaying in your application.


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 3 of 5

BM_Ashraf
Advocate
Advocate

Hi Krieg,

Thank you for your Reply!

I thought there is a way to make those values from API more like the others by Default in Inventor.
No, there is no problem if the Parameter has more digits.
Yeah, in the Applications the values are displayed in a right format.

Thank you again for your help !

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.

Blue Mech

Add-ins for Inventor!

0 Likes
Message 4 of 5

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Can you try if it solves your problem when replacing

oparamh2.Value = oUOM.GetValueFromExpression(PanelHeight, eLengthUnit)

with

If oUOM.IsExpressionValid(PanelHeight, oparamh2.Units) Then
    oparamh2.Expression = oUOM.ConvertUnits(oUOM.GetValueFromExpression(PanelHeight, oparamh2.Units), "cm", oparamh2.Units)
Else
    MsgBox ("Incompatible Expression")
    Exit Sub
End If

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 5 of 5

BM_Ashraf
Advocate
Advocate

Hello,
That code solved the problem !
Thanks a lot !

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.

Blue Mech

Add-ins for Inventor!

0 Likes