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
robapp.Project.New(IRobotProjectType.I_PT_SHELL)
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!
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).
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:
x=RobotOM.IRobotProject()
Cannot create instances of IRobotProject because it is abstract
x=RobotOM.RobotProject()
Cannot create instances of RobotProject because it is abstract
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
clr.AddReferenceToFileAndPath(“C:.…\Interop.RobotOM.dll”)
import RobotOM as rbt
Then you can call RSA classes as follow :
Robot = rbt.RobotApplication
Hello,
This thread starts to be a little bit old but if it can help this is the syntax you have to use:
import RobotOM # Connect or open Robot Session note the suffix “Class” that you have to use after “RobotApplication” robApp = RobotApplicationClass() # then robApp is the starting point for all the rest.
*#This should create a new shell project * robApp.Project.New(IRobotProjectType.I_PT_SHELL)