adding load to bar with python/api created loadcase

adding load to bar with python/api created loadcase

1234eddie
Advocate Advocate
735 Views
1 Reply
Message 1 of 2

adding load to bar with python/api created loadcase

1234eddie
Advocate
Advocate

Hi all,

 

I created a code that creates a ‘load case’(works), and after the creation of the loadcase i want to add a load tot he bar in that particular loadcase. But this gives errors(see picture 1). And after adding the load tot he bar i want to calculate the structure, also with a python script. But the problem with this script is that it’s executed before the structure is drawn in robot.

 

I have 2 questions about these problems:

  • What/where is something wrong in the code for adding the load tot the bar?
  • How can i solve the problem that calculation will start after it’s drawn in robot.

Complete setup:

Script for loadcase and load to bar.JPG

picture 1:

error with load and loadcase.png

Error inside robot

Errors inside robot.JPG

Code for adding load to bars

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

objects = IN[0]
LoadPX = IN[1]
LoadPY = IN[2]
LoadPZ = IN[3]
LoadID = IN[4]

application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases

LoadCaseName = IRobotCaseServer.Get()

Uniform = []
Uniform.append(LoadCaseName.Records.New(IRobotLoadRecordType.I_LRT_BAR_UNIFORM))
LoadRecord = LoadCaseName.Records.Get(Uniform[0])
LoadRecord.SetValue(0,LoadPX)
LoadRecord.SetValue(1,LoadPY)
LoadRecord.SetValue(2,LoadPZ)
LoadRecord.Objects.FromText(objects)

#Assign your output to the OUT variable.
OUT = 0

Code for calculations:(runs now to early)

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.
objects = IN[0]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
project.CalcEngine.AnalysisParams.IgnoreWarnings = True
calcEngine = project.CalcEngine
calcEngine.AutoGenerateModel = True
calcEngine.UseStatusWindow = True
OUT = calcEngine.Calculate()

All files are also added in the zip file.

 

Thanks in advance

 

Edward

0 Likes
Accepted solutions (1)
736 Views
1 Reply
Reply (1)
Message 2 of 2

1234eddie
Advocate
Advocate
Accepted solution

I solved this by myself. 

 

just use python code to create the structure.

 

PS: quite funny to see that a lot of people don't react when using API or python in the title, while it brings you much more possibilities in automation of structures.

0 Likes