Robot API - how to modify units

Robot API - how to modify units

Anonymous
Not applicable
2,400 Views
9 Replies
Message 1 of 10

Robot API - how to modify units

Anonymous
Not applicable

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 ?

0 Likes
Accepted solutions (2)
2,401 Views
9 Replies
Replies (9)
Message 2 of 10

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution
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
0 Likes
Message 3 of 10

Anonymous
Not applicable

Thanks.

0 Likes
Message 4 of 10

Anonymous
Not applicable

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. 

 

0 Likes
Message 5 of 10

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution
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
0 Likes
Message 6 of 10

Anonymous
Not applicable

Thanks.

0 Likes
Message 7 of 10

Anonymous
Not applicable

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 ?

0 Likes
Message 8 of 10

Rafal.Gaweda
Autodesk Support
Autodesk Support

That's interesting, we have to check it.



Rafal Gaweda
0 Likes
Message 9 of 10

Anonymous
Not applicable

Hi,

Any answer to my problem ?

 

Thanks

0 Likes
Message 10 of 10

Artur.Kosakowski
Autodesk Support
Autodesk Support

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
0 Likes