Error about using RSA API on Dynamo

Hello everyone, I am trying to create simple truss on RSA by using API. I managed to do basically everything except Defining the list of objects to which load will be applied. In this step I am getting error even though I am doing same thing that tutorial document shows. Any idea how can I solve this problem ?

What is the error?

I have found that a zero touch node written in C# is a more effective way of interacting with the Robot API due to the API being written for COM.

I can create a load case and set value to that case as you can see in the picture. But when I try to choose the node which load will be applied, I got error. In documentation it says I should use “case11.Objects.FromText(“1”)” this line for this purpose but I am having trouble in this line.

Here is the example of my code :


# Load the RSA API library
clr.AddReference(r'D:\Programs\Autodesk\Revit2024\Robot Structural Analysis Professional 2024\Exe\interop.RobotOM.dll')

# Import the RSA API
from RobotOM import *
from System import Object

RobApp= RobotApplicationClass()
# Initialize the Robot application
RobApp.Project.Structure.Nodes.Create(1,0,0,0)
RobApp.Project.Structure.Nodes.Create(2,10,0,0)
RobApp.Project.Structure.Nodes.Create(3,0,0,10)
RobApp.Project.Structure.Nodes.Create(4,10,0,10)
RobApp.Project.Structure.Nodes.Create(5,20,0,10)
RobApp.Project.Structure.Nodes.Create(6,20,0,0)

RobApp.Project.Structure.Bars.Create(1,1,2)
RobApp.Project.Structure.Bars.Create(2,3,4)
RobApp.Project.Structure.Bars.Create(3,4,5)
RobApp.Project.Structure.Bars.Create(4,2,4)

RobApp.Project.Structure.Bars.Create(5,2,6)
RobApp.Project.Structure.Bars.Create(6,5,6)
RobApp.Project.Structure.Bars.Create(7,1,4)
RobApp.Project.Structure.Bars.Create(8,2,3)
RobApp.Project.Structure.Bars.Create(9,4,6)
RobApp.Project.Structure.Bars.Create(10,2,5)
	
# Retrieve a node and set its label
# with the 'SetLabel' method.
set_node1 = RobApp.Project.Structure.Nodes.Get(1)
set_node2 = RobApp.Project.Structure.Nodes.Get(3)



# Cast the COM object to the specific interface type
support1= IRobotNode(set_node1)
support2= IRobotNode(set_node2)


# Now you can call the 'SetLabel' method
support1.SetLabel(IRobotLabelType.I_LT_SUPPORT, "Fixed")
support2.SetLabel(IRobotLabelType.I_LT_SUPPORT, "Pinned")


# Create a new simple case
case_number = RobApp.Project.Structure.Cases.FreeNumber
cas = RobApp.Project.Structure.Cases.CreateSimple(case_number,"Case_1", IRobotCaseNature.I_CN_PERMANENT , IRobotCaseAnalizeType.I_CAT_STATIC_NONLINEAR)

case1=cas.Records.Create(IRobotLoadRecordType.I_LRT_NODE_FORCE)


case11=RobotLoadRecord(case1)
case11.SetValue(IRobotNodeForceInPointRecordValues.I_NFIPRV_FZ , 3000)

print(dir(case11))


case11.Objects.FromText("1")

Result of my print command is :

 [
  ['GetValue', 'SetValue', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'get_Objects', 'get_Type']

]

The error I get is :
image

Best to ask on the robot product forum for API issues, but my guess is you need to use get_Objects due to the Python interpretation of the C# api.

Again, Python implementation of COM APIs is very limiting and I recommend using C# and a zero touch node setup instead.

@ugur_yavan_61

You are not the only one with this problem.
I tried your script and ran into the same problem, see also my topics with my username here and on the RSA forum.

What i think is happening is that if i click in the API documentation to Objects, you and up in the area of selection.
This is a short part of a script that select nodes, maybe we can go from here?

	SelectionNodes = structure.Selections.Get(IRobotObjectType.I_OT_NODE)
	SelectionNodes.FromText(str(allnodes[j]))
	structure.Labels.Get(IRobotLabelType.I_LT_SUPPORT,supportlabel2)
	structure.Nodes.SetLabel(SelectionNodes,IRobotLabelType.I_LT_SUPPORT,supportlabel2)

Hope you will find this usefull
Or maybe @JacquesGaudin now how to use the selected nodes to apply the load to.

Gr Edward

The Python version and Pythonnet version in Dynamo are not supported by the Pythonnet team. Hence the issues with the missing function in Dynamo.

Without Dynamo the Robot API works fine.

I guess Autodesk have compiled their own binaries for Pythonnet but something must have happened in the process.

Best I can suggest is to avoid Dynamo and run Python scripts from a independent Python interpreter.

Hopefully Dynamo will be fixed at some point.

@JacquesGaudin

thanks for your answer.

@gwizdzm @jacob.small can you share us insight in this if it’s goiing to be solved from the autodesk side or structural analysis package part.
I would really like to know?

other information in this topic
the suggested option does not work.

Hope to hear from the team soon

Gr Edward

@ugur_yavan_61
can you share the tutorial where you are talking about?

99.9% sure Dynamo does not have its own own Python - feel free to compare the checksum of the included binaries in GitHub to those of the Python foundation releases.

I am not sure what Jacques saw that indicated otherwise to him.

This is not what I’m saying. I’m talking about Pythonnet.

The version of Pythonnet used is not supported for the version of Python in the latest Dynamo. No binaries for Pythonnet are provided by the Pythonnet team for this combo.