Discussion Groups

Robot Structural Analysis

Reply
Active Contributor
guillaumeniel
Posts: 44
Registered: ‎12-07-2012
Accepted Solution

Robot API - how to modify units

431 Views, 9 Replies
12-15-2012 02:53 PM

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 ?

Please use plain text.
Product Support
Rafal.Gaweda
Posts: 4,935
Registered: ‎04-26-2010

Re: Robot API - how to modify units

12-17-2012 02:43 AM in reply to: guillaumeniel
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
Please use plain text.
Active Contributor
guillaumeniel
Posts: 44
Registered: ‎12-07-2012

Re: Robot API - how to modify units

12-17-2012 12:50 PM in reply to: Rafal.Gaweda

Thanks.

Please use plain text.
Active Contributor
guillaumeniel
Posts: 44
Registered: ‎12-07-2012

Re: Robot API - how to modify units

12-17-2012 01:02 PM in reply to: Rafal.Gaweda

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. 

 

Please use plain text.
Product Support
Rafal.Gaweda
Posts: 4,935
Registered: ‎04-26-2010

Re: Robot API - how to modify units

12-18-2012 02:23 AM in reply to: guillaumeniel
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
Please use plain text.
Active Contributor
guillaumeniel
Posts: 44
Registered: ‎12-07-2012

Re: Robot API - how to modify units

12-18-2012 01:10 PM in reply to: Rafal.Gaweda

Thanks.

Please use plain text.
Active Contributor
guillaumeniel
Posts: 44
Registered: ‎12-07-2012

Re: Robot API - how to modify units

12-21-2012 02:21 PM in reply to: Rafal.Gaweda

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 ?

Please use plain text.
Product Support
Rafal.Gaweda
Posts: 4,935
Registered: ‎04-26-2010

Re: Robot API - how to modify units

12-23-2012 11:32 PM in reply to: guillaumeniel

That's interesting, we have to check it.



Rafal Gaweda
Please use plain text.
Active Contributor
guillaumeniel
Posts: 44
Registered: ‎12-07-2012

Re: Robot API - how to modify units

01-13-2013 06:01 AM in reply to: Rafal.Gaweda

Hi,

Any answer to my problem ?

 

Thanks

Please use plain text.
Product Support
Artur.Kosakowski
Posts: 4,544
Registered: ‎12-17-2010

Re: Robot API - how to modify units

01-13-2013 11:17 PM in reply to: guillaumeniel

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
Please use plain text.