Robot Structural Analysis Forum
Welcome to Autodesk’s Robot Structural Analysis Forums. Share your knowledge, ask questions, and explore popular Robot Structural Analysis topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Robot API - how to modify units

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
guillaumeniel
1419 Views, 9 Replies

Robot API - how to modify units

Hi,

I would like to change default units for forces with Robot API, and set N instead of kN.

Here is my script :

 

Dim projPref As RobotProjectPreferences

projPref = Robot.Project.Preferences
projPref.Units.Set(IRobotUnitType.I_UT_FORCE, N)

 

The last line does not work (red part).

 

What is the appropriate syntax to set the unit to Newtons ?

9 REPLIES 9
Message 2 of 10

Dim Robot As New RobotApplication
Dim projPref As RobotProjectPreferences
Set projPref = Robot.Project.Preferences

Dim RU As RobotUnitData
Set RU = projPref.Units.Get(I_UT_FORCE)

RU.E = False
RU.Name = "N"
RU.Precision = 2

projPref.Units.Set I_UT_FORCE, RU

 



Rafal Gaweda
Message 3 of 10

Thanks.

Message 4 of 10

It works for forces, but it does not work for moments. Here is my code : 

 

Dim projPref As RobotProjectPreferences
Dim RU As RobotUnitData
projPref = Robot.Project.Preferences
RU = projPref.Units.Get(IRobotUnitType.I_UT_FORCE)
RU.E = False
RU.Name = "daN"
RU.Precision = 2
projPref.Units.Set(IRobotUnitType.I_UT_FORCE, RU)
RU = Nothing
RU = projPref.Units.Get(IRobotUnitType.I_UT_MOMENT)
RU.E = False
RU.Name = "daN*m"
RU.Precision = 2
projPref.Units.Set(IRobotUnitType.I_UT_MOMENT, RU)

 

I don't get any error message, but it does not work for moment, whereas it works for forces. 

 

Message 5 of 10

Dim RUCD As RobotUnitComplexData
Set RUCD = projPref.Units.Get(I_UT_MOMENT)

RUCD.E = False
RUCD.Name = "daN"
RUCD.Name2 = "m"
RUCD.Precision = 2

projPref.Units.Set I_UT_MOMENT, RUCD

 



Rafal Gaweda
Message 6 of 10

Thanks.

Message 7 of 10

Hi,

Sorry to come back again to this topic which appears as solved, but there is still a problem with units in my script. In Robot, if I go to Tools>Project Preferences>Units>Force, I can see that kN changed to daN, as I wanted.

 

 

The problem is that when I calculate and then display the forces array (Results>Forces), forces are still in kN in the array. So I have to go to  Tools>Project Preferences>Units>Force and quit, and then the array is updated and forces appear in daN.

 

So there is a kind of "refresh" problem for units.

 

Same problem if I want to diplay forces diagrams. Unless I open Tools>Project Preferences>Units>Force, forces are still in kN.

 

How can I fix this ?

Message 8 of 10

That's interesting, we have to check it.



Rafal Gaweda
Message 9 of 10

Hi,

Any answer to my problem ?

 

Thanks

Message 10 of 10

It will not be possible for us to investigate this situation before the next week.

 

Try to add projPref.Units.Refresh at the end of your code.



Artur Kosakowski

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

Post to forums  

Autodesk Design & Make Report