Import Structural Analysis functions to python script in Dynamo

Hello. I’m trying to import the functions from Structural Analysis (for example, AnalyticalBar) into a python script in Dynamo.

Do you know the line of code to do that import and how to use those functions?

Hi @pinhosl3

i’m not sure if i understand you correct, but why do you want to import these functions?
because the functions are listed in the RSA SDK-api.

but can you explain what kind of workflow you want to use it for and which programs you are using?

if you search on the RSA forum on my user name you wil find some scripts.(keep in mind they are for dynamo studio and written in ironpython)

Gr Edward

1 Like

Hi @1234eddie,

Thank you very much for your reply.

I want to import those functions to a Python environment so I can write the entire script in a single node. I’m a beginner in Dynamo but I’m a lot more experienced in Python. For example, I basically want this line of code to run:

AnalyticalBar.ByLine(line)

I get the error message that “NameError: name ‘AnalyticalBar’ is not defined” since that function does not exist in my Python environment.

I’ve tried:

clr.AddReference(‘Analysis’)
import StructuralAnalysis

I’ve read some of your posts and got introduced to the RobotOM library although this does not contain the functions I am looking for.

Please let me know if you need anything … I can try to explain it better

Hi @pinhosl3
it’s correct that AnalyticalBar.ByLine is not a command inside the RobotOM.
when using the RobotOM you should us this code.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReferenceToFileAndPath(user +r"\Dynamo\Dynamo Core\1.3\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
from RobotOM import *
from System import Object
#The inputs to this node will be stored as a list in the IN variables.
Bar_n = IN[0]
Bar_s = IN[1]
Bar_e = IN[2]
Barsection = IN[3]
Rel_name = IN[4]

application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
ProjectPrefs = project.Preferences
bars = structure.Bars

for j in range(len(Bar_n)):
	if (bars.Exist(Bar_n[j])):
		OUT = "Barexist"
	if not(bars.Exist(Bar_n[j])):
		structure.Bars.Create(Bar_n[j],Bar_s[j],Bar_e[j])
	selectionBars = structure.Selections.Get(IRobotObjectType.I_OT_BAR)
	selectionBars.FromText(Bar_n[j])
	structure.Labels.Get(IRobotLabelType.I_LT_BAR_SECTION,Barsection)
	structure.Bars.SetLabel(selectionBars,IRobotLabelType.I_LT_BAR_SECTION,Barsection)
	structure.Labels.Get(IRobotLabelType.I_LT_BAR_RELEASE,Rel_name[j])
	structure.Bars.SetLabel(selectionBars,IRobotLabelType.I_LT_BAR_RELEASE,Rel_name[j])
	
OUT = "Bars getekend en labels toegekend", Bar_n

maybe @gwizdzm can tell you if it’s possible to write AnalyticalBar.Byline inside python.

Hi eddie,

Thank you very much for your help again. I think we’re almost done. This was not what I was looking for but I can work with this code you sent me.
With your code I was able to find the function to create the nodes as well using:

structure.Nodes.Create(1,0,0,0)
structure.Nodes.Create(2,10,10,10)
Bar_s = 1
Bar_e = 2
structure.Bars.Create(Bar_n[j],Bar_s, Bar_e)

That way everything works.
I just have a final question which would be: Where can I find the documentation for RobotOM? I’ve searched for it but I could only find some zip folders that I don’t know how to open. Any suggestion?