Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
We are currently upgrading our scripts from IronPhyton 2 to CPhyton 3.
I want to get the results of node displacement using CPython3. The code in IronPython2 cretes 6 lists of results in UX,UY,UZ,RX,RY,and RZ, please see picture below.
In CPython3 I get the following error: Warning: AttributeError : '__ComObject' object has no attribute 'UX' [' File "<string>", line 41, in <module>\n'].
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)
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")
# 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:
inputNodeIDs = IN[1]
All_Case_Comb_nr = 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
NodeDisplacement = []
NodeDisplacement.append([])
NodeDisplacement.append([])
NodeDisplacement.append([])
NodeDisplacement.append([])
NodeDisplacement.append([])
NodeDisplacement.append([])
node = IRobotNodeDisplacementServer
node_dis = IRobotDisplacementData
for l in range(len(All_Case_Comb_nr)):
NodeDisplacement[0].append(structure.Results.Nodes.Displacements.Value(inputNodeIDs[0],All_Case_Comb_nr[l]).UX*1000)
NodeDisplacement[1].append(structure.Results.Nodes.Displacements.Value(inputNodeIDs[0],All_Case_Comb_nr[l]).UY*1000)
NodeDisplacement[2].append(structure.Results.Nodes.Displacements.Value(inputNodeIDs[0],All_Case_Comb_nr[l]).UZ*1000)
NodeDisplacement[3].append(structure.Results.Nodes.Displacements.Value(inputNodeIDs[0],All_Case_Comb_nr[l]).RX*1000)
NodeDisplacement[4].append(structure.Results.Nodes.Displacements.Value(inputNodeIDs[0],All_Case_Comb_nr[l]).RY*1000)
NodeDisplacement[5].append(structure.Results.Nodes.Displacements.Value(inputNodeIDs[0],All_Case_Comb_nr[l]).RZ*1000)
OUT = NodeDisplacement
I have been trying to change the code with the following classes, but It is not working.
node = IRobotNodeDisplacementServer
node_dis = IRobotDisplacementData
Could you help me to solve the issue?
Thank you in advance.
Best regards,
Stefany
Solved! Go to Solution.