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 ?
Solved! Go to Solution.
Solved by Rafal.Gaweda. Go to Solution.
Solved by Rafal.Gaweda. Go to 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
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.
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
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 ?
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.