Hi all,
We are trying to migrate our scripts from IronPython2 to CPython3.
I am trying to apply loads to the load case “GCW” as picture shows. The original script is attached, it was done with version IronPython2 and it works, however when turning to CPython 3, there are some errors.
Warning: AttributeError : ‘__ComObject’ object has no attribute ‘Records’ [’ File “”, line 32, in \n’]
and I got problems with IRobotLoadRecordMngr.Count. Could you help me checking what is wrong with the script?
Thank you in advance.
Best regards,
Stefany
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
sys.path.append(user+r"\Dynamo\Dynamo Core\2.11\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
clr.AddReference('interop.RobotOM')
#clr.AddReference(user+r"\Dynamo\Dynamo Core\2.11\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
from RobotOM import *
from System import Object
objects = IN[0]
LoadCaseID = IN[1]
ILRT = IN[2]
LoadPX = IN[3]
LoadPY = IN[4]
LoadPZ = IN[5]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
CreatedLoads = []
case = structure.Cases.Get(LoadCaseID)
simplecase = IRobotSimpleCase
simplecase = case
rec = IRobotLoadRecord
IRobotLoadRecordMngr = simplecase.Records
count = IRobotLoadRecordMngr.Count
for i in range(count+1)[::-1]:
rec = simplecase.Records.Delete(i)
#for i in range(1,count+1,1):
# rec = simplecase.Records.Delete(i)
for j in range(len(objects)):
for k in range(len(objects[j])):
Uniform = []
Uniform.append(simplecase.Records.New(ILRT))
LoadRecord = simplecase.Records.Get(Uniform[0])
LoadRecord.SetValue(0,LoadPX)
LoadRecord.SetValue(1,LoadPY)
LoadRecord.SetValue(2,LoadPZ[j])
LoadRecord.Objects.FromText(objects[j][k])
CreatedLoads.append(LoadRecord.UniqueID)
application.Visible = True
application.Interactive = True
application.Project.ViewMngr.Refresh()
#Assign your output to the OUT variable.
OUT = CreatedLoads, count