IV2022 Setting measuring precicion with api don't work as expected

IV2022 Setting measuring precicion with api don't work as expected

dg2405
Advocate Advocate
387 Views
5 Replies
Message 1 of 6

IV2022 Setting measuring precicion with api don't work as expected

dg2405
Advocate
Advocate

Setting the length or angle-precicion don't work as in 2020. Iv i run this short piece of code "ThisApplication.MeasureTools.SetLengthPrecision(oDoc, 3)" the value indeed is changing, but it has no efffect on the measuring command:

Unbenannt.PNG

@Anonymous i think you have to open an incident

0 Likes
388 Views
5 Replies
Replies (5)
Message 2 of 6

Michael.Navara
Advisor
Advisor

I can't confirm this. I test the same code and everything works as expected.

Tested version: Inventor 2022 (Build 260153000, 153) Czech Language

0 Likes
Message 3 of 6

dg2405
Advocate
Advocate

I've made a video, please take a look on it. I have Inventor 2022.1. With IV2020 everything worked fine.

0 Likes
Message 4 of 6

Michael.Navara
Advisor
Advisor

Sorry, now I test it again and length measurement doesn't work 😞 as you described, but Ange units work as expected. I will continue in research

0 Likes
Message 5 of 6

Michael.Navara
Advisor
Advisor

It looks like a bug. Sometimes it works, but sometimes not. The settings in "CommandSettings.xml" file takes precedence over the settings in "ThisApplication.MeasureTools".

Here is a workaround code which changes the content of settings file and then executes the measure command.

 

AddReference "System.Xml.dll"
Dim precision = 5
'ThisApplication.MeasureTools.SetLengthPrecision(ThisDoc.Document, precision)

Dim xmlDocument As New System.Xml.XmlDocument()
Dim commandSettings As String = System.Environment.ExpandEnvironmentVariables("%AppData%\Autodesk\Inventor 2022\CommandSettings.xml")
xmlDocument.Load(commandSettings)
Dim nodes As System.Xml.XmlNodeList = xmlDocument.DocumentElement.SelectNodes("//Command[@PanelId='MeasureCmd']//IDC_MEASURE_PRECISION_SELECTOR")
For Each node As System.Xml. XmlNode In nodes
	node.Attributes("Value").Value = precision.ToString()
Next
xmlDocument.Save(commandSettings)
ThisApplication.CommandManager.ControlDefinitions("AppMeasureDistanceCmd").Execute()

 I hope Autodesk will fix this issue in future.

Message 6 of 6

dg2405
Advocate
Advocate

Thank's for your effort! Don't know that these values also stored in the xml. Your code works!

@Anonymous I see the code from michael.navara only as a workaround and this problem should be fixed.

0 Likes