Shouldnt this return 'cm'?

Shouldnt this return 'cm'?

m_carreira3Y72Q
Participant Participant
533 Views
4 Replies
Message 1 of 5

Shouldnt this return 'cm'?

m_carreira3Y72Q
Participant
Participant

app = adsk.core.Application.get()

ui = app.userInterface

design = adsk.fusion.Design.cast(app.activeProduct)

uManager = design.unitsManager

units = uManager.internalUnits

print(f"Current length units: {units}")

 

Current length units: InternalUnits

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

kandennti
Mentor
Mentor
0 Likes
Message 3 of 5

m_carreira3Y72Q
Participant
Participant

I am just wondering if i undestand it right, i was expecting 'cm', but there has to be more internal units, other than the ones used to measure distances, so... i'm not sure what to make of this, still think there is something wrong here...

0 Likes
Message 4 of 5

kandennti
Mentor
Mentor

Problems will likely arise.

        print(f"formatValue: {unitsMgr.formatValue(1)}")
        print(f"formatValue: {unitsMgr.formatValue(1, 'cm')}")
        print(f"formatValue: {unitsMgr.formatValue(1, unitsMgr.internalUnits)}") #error
0 Likes
Message 5 of 5

BrianEkins
Mentor
Mentor
Accepted solution

It seems a bit worthless, but I found that it does work with the UnitsManager.convert method. Here are some examples and their results. You can see that it's not limited to distances but infers the unit type from the other specified unit. I think it would be best if this wasn't in the API because it's not very useful and just creates confusion about what it's for.

um.convert(1, "in", "InternalUnits") 
2.54

um.convert(180, "deg", "InternalUnits")
3.141592653589793

  

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com