Hello!
I am trying to write a code to calculate steel. I found examples on the forums that worked, but after using them in my file, I get an error:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReference(user + r"\Dynamo\Dynamo Revit\3.2\packages\Structural Analysis for Dynamo\bin\interop.RobotOM.dll")
from RobotOM import RobotApplicationClass, IRDimCalcParamVerifType, IRDimCalcParamLimitStateType
clr.AddReference("System.Reflection")
from System.Reflection import BindingFlags
from RobotOM import *
from System import Object
class ComObj:
def __init__(self, obj):
self.obj = obj
self.typ = obj.GetType()
def __getattr__(self, name):
def newm(*args):
args = args or (None,)
return self.typ.InvokeMember(
name,
BindingFlags.InvokeMethod | BindingFlags.GetProperty,
None,
self.obj,
*args,
)
return newm
objects = IN[0]
app = RobotApplicationClass()
project = app.Project
project.ViewMngr.Refresh()
rdm_server = IRDimServer(app.Kernel.GetExtension("RDimServer"))
rdm_server.Mode = 1
rdm_calc_engine = IRDimCalcEngine(rdm_server.CalculEngine)
calc_param = IRDimCalcParam(rdm_calc_engine.GetCalcParam())
calc_conf = rdm_calc_engine.GetCalcConf()
stream = IRDimStream(rdm_server.Connection.GetStream())
stream.Clear()
stream.WriteText("all")
calc_param.SetObjsList(IRDimCalcParamVerifType.I_DCPVT_GROUPS_VERIF,stream)
calc_param.SetLimitState(IRDimCalcParamLimitStateType.I_DCPLST_SERVICEABILITY,1)
stream.Clear()
stream.WriteText("all")
calc_param.SetLoadsList(stream)
rdm_calc_engine.Solve(stream)
all_results = IRDimAllRes(rdm_calc_engine.Results())
detailed_results = IRDimDetailedRes(all_results.Get("1"))
case = detailed_results.GovernCaseName
ratio = detailed_resuls.Ratio
OUT = case, ratio
I don’t know what this error is caused by, and I’m not quite sure what I should plug into this script under “objects = IN[0]” I created the membertype and group necessary for calculations and they are working well.
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReference(user + r"\Dynamo\Dynamo Revit\3.3\packages\Structural Analysis for Dynamo\bin\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.
dataEnteringNode = IN
Rygiel = IN[0]
# Place your code below this line
app = RobotApplicationClass()
bars = app.Project.Structure.Bars
select = app.Project.Structure.Selections.Create(1)
select.FromText(IN[0])
labeltype = bars.SetLabel(select,16,"Rygiel")
# Assign your output to the OUT variable.
OUT = Rygiel
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReference(user + r"\Dynamo\Dynamo Revit\3.3\packages\Structural Analysis for Dynamo\bin\interop.RobotOM.dll")
from RobotOM import RobotApplicationClass, IRDimCalcParamVerifType, IRDimCalcParamLimitStateType
clr.AddReference("System.Reflection")
from System.Reflection import BindingFlags
from RobotOM import *
from System import Object
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
Rygiel = IN[0]
# Place your code below this line
app = RobotApplicationClass()
project = app.Project
project.ViewMngr.Refresh()
structure = project.Structure
labels = structure.Labels
bars = structure.Bars
objects = structure.Objects
#Obliczenia
app.Preferences.multiprocessing = True
dim = project.DimServer
connect = dim.Connection
groups = dim.GroupsService
#grupy
g1 = groups.New(0,1)
g1.Name = "Luk"
g1.Material = "S 235"
strm = connect.GetStream()
strm.Clear()
strm.WriteText(str(Rygiel))
g1.SetMembList(strm)
grpprof = connect.GetGrpProfs()
grpprof.Clear()
strm.WriteText("IPE")
grpprof.SetFamilies("RPLN7",strm)
g1.SetProfs(grpprof)
groups.Save(g1)
# Assign your output to the OUT variable.
OUT = Rygiel
Most, as not all, of the interface classes used here are not available in the API documentation, because when looking for particular functions, they simply weren’t there, but in the above code found on the forum, you can see working classes, not described in the API. I looked for additions to the API, but did not find them. Is there any additional documentation to fill in these API gaps? I’m also not entirely convinced, through lack of access to documentation, exactly what each function does.