Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multiple parts mass precision

4 REPLIES 4
Reply
Message 1 of 5
hEINSTEIN
232 Views, 4 Replies

Multiple parts mass precision

Hi I am trying to write a ilogic code that will set the part precion to zero. I have a bunch of parts that shows 3 decimals and the rest are showing none, I need to change them all to 0.

 

I tried this code:

' iLogic rule to change linear dimension display to 0 in Document Settings

Dim oDoc As Document = ThisDoc.Document

' Open Document Settings
oDoc.Settings.EditDocumentSettings()

' Switch to Units tab
Dim oDialog As PropertyManagerDialog = oDoc.Settings.GetPropertyManagerDialog()
oDialog.GetControl("UnitsTab").Select()

' Set linear dimension display to 0
oDoc.Settings.GeneralOptions.ModelingDimensionDisplay = 0

' Save and close Document Settings
oDoc.Settings.Save()
oDoc.Settings.Close()

 

But I get this erro line.

 

hEINSTEIN_0-1714084828614.png

 

4 REPLIES 4
Message 2 of 5
A.Acheson
in reply to: hEINSTEIN

Hi @hEINSTEIN 

 

Just curious as to how this code came about? The inventor API doesn’t list settings as a method see help page here for part document.


Can you supply an image of what settings your trying to change in the User Interface? I suspect you want to get to the units of measure but it’s only a guess at this stage.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 5
hEINSTEIN
in reply to: A.Acheson

@A.Acheson 

 

Hi this is the setting I want to change for all my parts.

 

hEINSTEIN_0-1720027775074.png

 

Message 4 of 5
Frederick_Law
in reply to: hEINSTEIN

Very creative code.

 

Please read the API help to find what's available.

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-CF60F6F3-8074-4719-B8E0-5E482E5AF783

 

You can set it with:

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-3E732FB2-A8FA-4B89-BED0-03F5933DEBA1

 

UnitsOfMeasure.LengthDisplayPrecision = 0

 

Changing that setting only affect that part.  It won't change any assembly or drawing.

 

You can open Templates and change it there if you want it in all new files.

Message 5 of 5
nstevelmans
in reply to: hEINSTEIN

Hi, try this code.

 

Dim oDoc As Document = ThisApplication.ActiveDocument
        Dim oUm As UnitsOfMeasure = oDoc.UnitsOfMeasure

        ' Get the current length units.
        Dim eLengthUnits As UnitsTypeEnum = oUm.LengthUnits

        oUm.LengthUnits = UnitsTypeEnum.kMillimeterLengthUnits
        oUm.LengthDisplayPrecision = 0

 

If a response answers your question, please use  ACCEPT SOLUTION  to assist other users later.

Also be generous with Likes!  Thank you and enjoy!

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report