Message 1 of 1
Python integration with Robot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Can someone please give me some guidance for integrating python with Robot. I've searched the forum but there is little guidance.
I'm trying to build some basic geometry in Robot using a python script. I've managed to use the following code to be able to open a Robot window but I'm missing the final link to load my nodes in. Does anyone have experience with Python and can spot my mistake?
Thanks
This is my code:
from RSABase import RSABase
import RobotOM as rbt
my_RSABase = RSABase()
file = my_RSABase.project.New(rbt.IRobotProjectType.I_PT_FRAME_3D)
my_RSABase.nodes.Create(1),(1),(2),(3)
I import a class called RSABase:
import clr
clr.AddReference(
r"C:\Program Files\Autodesk\Robot Structural Analysis Professional 2023\Exe\Interop.RobotOM.dll"
)
import RobotOM as rbt
class RSABase:
"""This is a base class for creation of all RSA API classes"""
def __init__(self) -> None:
self._connnect_to_app()
self.project = self.app.Project
self.structure = self.project.Structure
self.labels = self.structure.Labels
self.cases = self.structure.Cases
self.nodes = self.structure.Nodes
self.results = self.structure.Results # IRobotResultServer
self.objects = self.structure.Objects
self.preferences = self.project.Preferences
self.bars = self.structure.Bars
# self.materials = self.structure.Materials
self.rbt = rbt
def _connnect_to_app(self):
self.app = rbt.RobotApplication()