Hi Arthur,
Here is the code for applying a trapezoidal load.
Note: in this example I provided a loop because for this particular example I ALWAYS provided a height, which was split into 10 robot elements, then the UDL force at each start/end point was calculated in a spreadsheet and passed into dynamo. That’s why you’ll see I looped through the objects list and applied the start/end values. It may take a bit to get the feeling for the API, it’s not straight forward… Should be easy enough to revert this code back to a single robot bar input and UDL. But let me know if you’re struggling and I’ll help out.
So trapazoidal load application:
#Set environment:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# add Robot Structural Analysis API reference
from System import Environment
# get the current user folder i.e C:\Users\<you>\AppData\Roaming
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
# add the reference to the interop file shipped with the package
# you may have to hunt where yours is saved and adjust the path.
clr.AddReferenceToFileAndPath(user +r"\Dynamo\Dynamo Revit\2.0\packages\Structural Analysis for Dynamo\bin\RSA\interop.RobotOM.dll")
# add needed import to be able to use Robot Structural Analysis objects
from RobotOM import *
from System import Object
#------------------#
## get input data ##
#------------------#
# the bar id will go to the input[0]
objects = IN[0]
# The following loads are based on the total height being split into 10:
# Relative references to height will define the names below (in the loop)
# The assumption is that the load will be applied to 10 members here.
heightloadsULS = IN[1]
LoadCaseName = IN[2]
#-------------------------------------------------------------#
# Connect to the running instance of Robot Structural Analysis
#-------------------------------------------------------------#
application = RobotApplicationClass()
# Get a reference of the current project
project = application.Project
structure = project.Structure
# Get a reference of the label server
labels = structure.Labels
# Automatically assign a case number:
caseNumber = structure.Cases.FreeNumber
# See API guide for explaination of the capital name references.
CaseLive = structure.Cases.CreateSimple(caseNumber, LoadCaseName,
IRobotCaseNature.I_CN_EXPLOATATION, IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR)
Trapezoidal = []
Trapezoidal.append(CaseLive.Records.New(IRobotLoadRecordType.I_LRT_BAR_TRAPEZOIDALE))
LoadRecord = CaseLive.Records.Get(Trapezoidal[0])
#----------------------------------#
# Apply the loads to robot elements
#----------------------------------#
# For my example I wanted to apply the load by splitting the overall
# height into 10 segments.
numRec = 10
i = 1
while i <= numRec:
# The SetValue numbers are explained in the API guide (page 150+)
# I had issues using the names (like the API example page 11) so
# reverted to using the actual integer values.
# The values set below will then affect the load application step.
LoadRecord.SetValue(13, 1) #set relative reference as true
LoadRecord.SetValue(6, 1) #set end point of UDL (on member)
LoadRecord.SetValue(7, 0) #set start poiint of UDL (on member)
LoadRecord.SetValue(0, heightloadsULS[i-1]*1000) #starting load
LoadRecord.SetValue(3, heightloadsULS[i]*1000) #end load
LoadRecord.Objects.FromText(objects[i-1]) #grab the object to be used
Trapezoidal.append(CaseLive.Records.New(IRobotLoadRecordType.I_LRT_BAR_TRAPEZOIDALE))
LoadRecord = CaseLive.Records.Get(Trapezoidal[i])
i += 1
#Assign the name to the OUT variable
OUT = caseNumber
Also as I mentioned, you will need a different node to calculate and retrieve nodes (because the Robot analysis packaged nodes do not play nice with other load types).
Calculate Model:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# add Robot Structural Analysis API reference
from System import Environment
# get the current user folder i.e C:\Users\<you>\AppData\Roaming
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
# add the reference to the interop file shipped with the package
clr.AddReferenceToFileAndPath(user +r"\Dynamo\Dynamo Revit\2.0\packages\Structural Analysis for Dynamo\bin\RSA\interop.RobotOM.dll")
# add needed import to be able to use Robot Structural Analysis objects
from RobotOM import *
from System import Object
# have an input just to control the graph flow.
objects = IN[0]
# Connect to the running instance of Robot Structural Analysis
application = RobotApplicationClass()
# Get a reference of the current project
project = application.Project
structure = project.Structure
# Get a reference of the label server
labels = structure.Labels
# Check out the API, there is an extensive array of options here
# This will just do your stock standard calculations.
project.CalcEngine.AnalysisParams.IgnoreWarnings = True
calcEngine = project.CalcEngine
calcEngine.AutoGenerateModel = True
#calcEngine.AutoFreezeResults = True
calcEngine.UseStatusWindow = True
OUT = calcEngine.Calculate()
Grab results:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# add Robot Structural Analysis API reference
from System import Environment
# get the current user folder i.e C:\Users\<you>\AppData\Roaming
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
# add the reference to the interop file shipped with the package
clr.AddReferenceToFileAndPath(user +r"\Dynamo\Dynamo Revit\2.0\packages\Structural Analysis for Dynamo\bin\RSA\interop.RobotOM.dll")
# add needed import to be able to use Robot Structural Analysis objects
from RobotOM import *
from System import Object
# get input data
# input 0 is just a result that indicates if the calculation ran ok.
# also makes sure we get loads AFTER running analysis.
calculateOutcome = IN[0]
# list of robot bar IDs that you want loads from:
inputBarIDs = IN[1]
# Connect to the running instance of Robot Structural Analysis
application = RobotApplicationClass()
# Get a reference of the current project
project = application.Project
structure = project.Structure
numberOfBars = len(inputBarIDs)
i = 0
barStresses = []
while i < numberOfBars:
# have a look at robot API pg 316 for some info about this part.
# and the example file page 16. The data structure is a bit hard to
# figure out.
# for this example the .Value(inputBarIDS[i],1,0).Fz/1000
# end up meaning: value( robot bar ID, Bar End, Offset ).(axis)
# The results are given using N so we divide by 1000 to get kN.
barStresses.append(structure.Results.Bars.Forces.Value(inputBarIDs[i],1,0).Fz/1000)
i += 1
# pass the list of values - this was displayed in dynamo and passed
# to an excel sheet for record.
OUT = barStresses
Hopefully this helps you out a bit. I would take a good look at the ros-example code to get an idea of what to expect. Once you get the feeling for how the API plays in python, it’s a bit easier to figure out.
As a bonus here is a quick alteration of the bar forces to get node forces:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# add Robot Structural Analysis API reference
from System import Environment
# get the current user folder i.e C:\Users\<you>\AppData\Roaming
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
# add the reference to the interop file shipped with the package
clr.AddReferenceToFileAndPath(user +r"\Dynamo\Dynamo Revit\2.0\packages\Structural Analysis for Dynamo\bin\RSA\interop.RobotOM.dll")
# add needed import to be able to use Robot Structural Analysis objects
from RobotOM import *
from System import Object
# get input data
# input 0 is just a result that indicates if the calculation ran ok.
# also makes sure we get loads AFTER running analysis.
calculateOutcome = IN[0]
# list of robot node IDs that you want reactions from:
inputNodeIDs = IN[1]
# Connect to the running instance of Robot Structural Analysis
application = RobotApplicationClass()
# Get a reference of the current project
project = application.Project
structure = project.Structure
numberOfNodes = len(inputNodeIDs)
i = 0
nodeReactions = [[]]
nodeReactions.append([])
nodeReactions.append([])
while i < numberOfNodes:
nodeReactions[0].append(structure.Results.Nodes.Reactions.Value(inputNodeIDs[i],1).Fx/1000)
nodeReactions[1].append(structure.Results.Nodes.Reactions.Value(inputNodeIDs[i],2).Fx/1000)
nodeReactions[2].append(structure.Results.Nodes.Reactions.Value(inputNodeIDs[i],3).Fx/1000)
i += 1
OUT = nodeReactions[ros_api.pdf|attachment](upload://q5Cgcka7ImQWdJvavPSThBfkyux.pdf) (1.1 MB) [ros-example.pdf|attachment](upload://tVKu9FsdB44MrSTMYuoS34yJVXB.pdf) (455.4 KB)[ros_api.pdf|attachment](upload://q5Cgcka7ImQWdJvavPSThBfkyux.pdf) (1.1 MB) [ros-example.pdf|attachment](upload://tVKu9FsdB44MrSTMYuoS34yJVXB.pdf) (455.4 KB)