API / Python



This may be a very silly doubt, but i spent the last few days trying to find a solution and no luck.
I have already created some simple macros using VB but i was trying to create a simple script on Python and i’m having some difficulties.
Just a basic example using VB to explain:

Dim robapp As IRobotApplication
robapp = New RobotApplication

But when trying to use Python:

import RobotOM

and i get the following tip and error:
|Help on method-descriptor New
| New(…)
| New(self: IRobotProject, pt: IRobotProjectType)

|Message: New() takes exactly 2 arguments (1 given)

I was hopping that someone already has done something with the API from Robot Structural Analysis using Python and maybe could show me some examples/tutorials so i can start learning more.
Thanks in advance!

(Menno Deij - van Rijswijk) #2

I have no experience with Robot Structural Analysis, but what I see you doing here is COM. What may be going on here is that from VB you can use optional arguments in the New() function, whereas in Python you can’t. My guess is that one of the arguments that VB uses optionally is Nothing (in VB) or None (in Python).

Try if this works:

import RobotOM
RobotOM.RobotProject.New(RobotOM.IRobotProjectType.I_PT_SHELL, None)


import RobotOM
RobotOM.RobotProject.New(None, RobotOM.IRobotProjectType.I_PT_SHELL)


Thanks for the help, but unfortunately it didn’t work.

import RobotOM
RobotOM.RobotProject.New(None, RobotOM.IRobotProjectType.I_PT_SHELL)

got the following error:

expected IRobotProject, got NoneType

I have almost zero experience with python, but could it be the .dll file that i’m using?
This only happens when using the .dll from Robot Structural Analysis.
Maybe i’m just making a rookie mistake.

Thanks again!

Oh, and another thing I tried and maybe more expert users can take more information out of it.
When trying:


Cannot create instances of IRobotProject because it is abstract


Cannot create instances of RobotProject because it is abstract

(Menno Deij - van Rijswijk) #4

Just to make sure, you did try this variant too?
Where the None is coming as the second argument?


Yes i did try, and the result was:

expected IRobotProject, got IRobotProjectType

(Steve Baer) #6

Is there any SDK documentation for Robot?

(Menno Deij - van Rijswijk) #7

None that I could find. I did come across the code below though. It looks like you need to use the Common Language Runtim (CLR) to talk to RSA. When importing it like the code below, I presume you can call it the same way you did in VB.

import clr
import RobotOM as rbt

Then you can call RSA classes as follow :
Robot = rbt.RobotApplication

Buried somewhere on an Autodesk forum


I did find some documentation,

ros_api.pdf (1.1 MB)
ros-example.pdf (455.4 KB)

The problem persists when using menno new idea, but again thanks!
I will try to gather more information.