Hi all,
We are currently upgrading our scripts from IronPhyton 2 to CPhyton 3
I want to create the Non-Linear Model Definition of the supports. In the script attached, the supports are created successfully. However, as the second picture shows, the definition of K1,D1, and K2 do not appear.
Could someone help me to check why is it not working?
Thanks in advance!
Best regards,
Stefany Salguero
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 Core\2.11\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.
#Define input
nodeSupportName = IN[0]
Model_name = IN[1]
K1= IN[2]
D1 = IN[3]
K2 = IN[4]
nodeSupportData = IN[5]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
ProjectPrefs = project.Preferences
lab_serv=IRobotLabelServer
#Lab_serv=labels
#NodeSupport
KNLL = IRobotNonlinearLinkServer
KNLL = IRobotNonlinearLink
KnnLP= IRobotNonlinearLinkParamsBLinear
for i in range(len(nodeSupportName)):
KNLL= structure.Nodes.NonlinearLinks.Create(Model_name[i])
KNLL.ModelType= IRobotNonlinearLinkModelType.I_NLMT_FORCE_DISPLACEMENT
KNLL.SetCurveType(IRobotNonlinearLinkCurveType.I_NLCT_B_LINEAR)
KnnLP = KNLL.GetParams(IRobotNonlinearLinkSemiAxisType.I_NLSAT_ANY)
KnnLP.D1 = D1[i]
KnnLP.K1 = K1[i]
KnnLP.K2 = K2[i]
#KnnLP.D1 = 10
#KnnLP.K1 = 20
#KnnLP.K2 = 30
KNLL.SetParams(KnnLP)
node = IRobotLabel(labels.Create(IRobotLabelType.I_LT_NODE_SUPPORT, nodeSupportName[i]))
#node = robapp.Project.Structure.Labels.Create(IRobotLabelType.I_LT_NODE_SUPPORT, nodeSupportName[i]))
relData=IRobotNodeSupportData(node.Data)
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_UX, KNLL.Name)
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_UY, KNLL.Name)
node.Data.UZ = nodeSupportData[0]
node.Data.RX = nodeSupportData[1]
node.Data.RY = nodeSupportData[2]
node.Data.RZ = nodeSupportData[3]
labels.Store(node)
application.Visible = True
application.Interactive = True
application.Project.ViewMngr.Refresh()
OUT = node.Data
Solved! Go to Solution.
Solved by JacquesGaudin. Go to Solution.
Thank you for your reply, I checked the example and I tried to follow and see if it applies the values of D1,K1, and K2 in the Non-Linear Model Definition, but it didn't, see figure below. Could you or someone else help me to check why is it happening?
# 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 Core\2.11\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
# The inputs to this node will be stored as a list in the IN variables.
#dataEnteringNode = IN
from RobotOM import *
from System import Object
nodeSupportName = IN[0]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
ProjectPrefs = project.Preferences
lab_serv = RobotLabel
KNLL = RobotNodeSupportData
KNLL = RobotNonlinearLinkMngr
KNLL = RobotNonlinearLink
#KNLL = RobApp.Project.Structure.Nodes.NonlinearLinks.Create("ABSSKM")
KNLL= structure.Nodes.NonlinearLinks.Create("ABSSKM")
KNLL.ModelType = IRobotNonlinearLinkModelType.I_NLMT_MOMENT_ROTATION
KNLL.SetCurveType(IRobotNonlinearLinkCurveType.I_NLCT_B_LINEAR)
KNLL.SetCurveType(IRobotNonlinearLinkCurveType.I_NLCT_B_LINEAR)
KnnLP = KNLL.GetParams(IRobotNonlinearLinkSemiAxisType.I_NLSAT_ANY)
KnnLP = IRobotNonlinearLinkParams(KNLL.Data)
#KnnLP = IRobotNonlinearLinkParamsBLinear
#KnnLP = KNLL.GetParams
KnnLP.K1 = 0.0085
KnnLP.D1 = 174560
KnnLP.K2 = 0
KNLL.SetParams(KnnLP)
lab_serv = IRobotLabelServer
#node
#lab_serv = RobApp.Project.Structure.Labels.Create(I_LT_SUPPORT, "ROT")
node = IRobotLabel(labels.Create(IRobotLabelType.I_LT_SUPPORT, "ROT"))
#relData = Label.Data
relData = IRobotNodeSupportData(node.Data)
#Set NLM = NSD.NonlinearModel
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_RY, "ABSSKM")
#NLM.Set I_DOF_RY, "ABSSKM"
relData.UX = 1
relData.UY = 1
relData.UZ = 1
relData.RX = 0
relData.RZ = 0
# RobApp.Project.Structure.Labels.Store Label
# Place your code below this line
# Assign your output to the OUT variable.
OUT = node
I tried to clean up your code above. As a general note, try to avoid reassigning the same variable with differnet objects, it gets very confusing otherwise.
In Python, there is no declaration of types, the language is built around a concept called duck-typing (if the object looks, sounds and acts like a duck then it's a duck!) as opposed to .Net languages like C# and VBA.
# 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 Core\2.11\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
from RobotOM import *
from System import Object
nodeSupportName = IN[0]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
KNLL= structure.Nodes.NonlinearLinks.Create("ABSSKM")
KNLL.ModelType = IRobotNonlinearLinkModelType.I_NLMT_MOMENT_ROTATION
KNLL.SetCurveType(IRobotNonlinearLinkCurveType.I_NLCT_B_LINEAR)
KNLL.SetCurveType(IRobotNonlinearLinkCurveType.I_NLCT_B_LINEAR)
KnnLP = IRobotNonlinearLinkParamsBLinear(
KNLL.GetParams(IRobotNonlinearLinkSemiAxisType.I_NLSAT_ANY)
)
KnnLP.K1 = 0.0085
KnnLP.D1 = 174560
KnnLP.K2 = 0
KNLL.SetParams(KnnLP)
new_label = IRobotLabel(labels.Create(IRobotLabelType.I_LT_SUPPORT, "ROT"))
relData = IRobotNodeSupportData(new_label.Data)
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_RY, "ABSSKM")
relData.UX = 1
relData.UY = 1
relData.UZ = 1
relData.RX = 0
relData.RZ = 0
OUT = node
Hi @JacquesGaudin,
Thank you for your reply. The first part of the scrip now works, but the only value that gets set is K1, could you help me checking the script one more time, because we do not understand why it is happening?
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 Core\2.11\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
from RobotOM import *
from System import Object
nodeSupportName = IN[0]
Model_name = IN[1]
K1= IN[2]
D1 = IN[3]
K2 = IN[4]
nodeSupportData = IN[5]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
lab_serv=IRobotLabel
for i in range(len(nodeSupportName)):
KNLL= structure.Nodes.NonlinearLinks.Create(Model_name[i])
KNLL.ModelType= IRobotNonlinearLinkModelType.I_NLMT_FORCE_DISPLACEMENT
KNLL.SetCurveType(IRobotNonlinearLinkCurveType.I_NLCT_B_LINEAR)
KnnLP = IRobotNonlinearLinkParamsBLinear(KNLL.GetParams(IRobotNonlinearLinkSemiAxisType.I_NLSAT_ANY))
KnnLP.K1 = 174560
KnnLP.D1 = 0.0085
KnnLP.K2 = 0
#KnnLP.D1 = D1[i]
#KnnLP.K1 = K1[i]
#KnnLP.K2 = K2[i]
#KnnLP.D1 = 1000
#KnnLP.K1 = 2
#KnnLP.K2 = 3
KNLL.SetParams(KnnLP)
lab_serv=IRobotLabelServer
node = IRobotLabel(labels.Create(IRobotLabelType.I_LT_NODE_SUPPORT, nodeSupportName[i]))
relData = IRobotNodeSupportData(node.Data)
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_UX, KNLL.Name)
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_UY, KNLL.Name)
relData.UZ = nodeSupportData[0]
relData.RX = nodeSupportData[1]
relData.RY = nodeSupportData[2]
relData.RZ = nodeSupportData[3]
labels.Store(node)
application.Visible = True
application.Interactive = True
application.Project.ViewMngr.Refresh()
OUT = node
Thank you in advance for your help.
Best regards,
Stefany
Hi Stephany,
Your 0.0085 value for D1 is very small and rounds up to 0.0 with one digit precision. Can you try with a larger value? It could be that the value is in mm not meters. The API document is not very helpful to guess which is correct! 😢
I can't see any obvious reason why the script wouldn't be correct for now.
Jacques
Hi @JacquesGaudin,
Thank you for your response.
I have tried with larger values, for the parameters D1, and K2, please see picture below. But, D1 is still not assigned to a value.
And, I also have tried with small values but It did not work.
Could you help me to check it?
Thank you in advance.
Best regards,
Stefany
@stefanyC6JZ7 @Romanich @Rafal.Gaweda
It looks like there is a typo somewhere. The API documentation shows D1 with an upper case D and the object has an attribute d1 with a lower case d.
Try to put your value in d1 instead:
KnnLP.d1 = 10.0 # <- Mind the lower case d!
FYI, I just tried and the typo seems to be the issue. The value for d1 is given in meters.
Hi @JacquesGaudin,
Thank you very much for your response and for your help, the error is indeed the typo of D1. Now it is working perfectly.
Best regards,
Stefany
Hi @stefanyC6JZ7 and @Rafal.Gaweda I had followed this script in my Robot model, the only different is that I had certain supports with non symmetrical Bi Linear, which I thought could easily solve by adding Symetry. But it turned out that Symetry is read-only and by default, the Symmetry is ticked. I had posted my case here: https://forums.autodesk.com/t5/robot-structural-analysis-forum/trouble-assigning-non-symmetrical-spr...
and here is the Python script, I would really appreciate if there is any solutions to this.
Thank you.
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReference("C:\Program Files\Autodesk\Robot Structural Analysis Professional 2024\Exe\Interop.RobotOM.dll")
from RobotOM import *
#Symmetry = False # Assuming initially the option is unticked
Spring_Symmetry = IN[9]
nodeSupportName = IN[0]
Model_name = IN[1]
nodeSupportData = IN[2]
K1_positive = IN[3]
d1_positive = IN[4]
K2_positive = IN[5]
K1_negative = IN[6]
d1_negative = IN[7]
K2_negative = IN[8]
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
for i in range(len(nodeSupportName)):
KNLL = structure.Nodes.NonlinearLinks.Create(Model_name[i])
KNLL.Symetry = Spring_Symmetry[i]
KNLL.ModelType = IRobotNonlinearLinkModelType.I_NLMT_FORCE_DISPLACEMENT
KNLL.SetCurveType(IRobotNonlinearLinkCurveType.I_NLCT_B_LINEAR)
KnnLP_positive = IRobotNonlinearLinkParamsBLinear(KNLL.GetParams(IRobotNonlinearLinkSemiAxisType.I_NLSAT_POSITIVE))
KnnLP_positive.d1 = d1_positive[i]
KnnLP_positive.K1 = K1_positive[i]
KnnLP_positive.K2 = K2_positive[i]
KNLL.SetParams(KnnLP_positive)
KnnLP_negative = IRobotNonlinearLinkParamsBLinear(KNLL.GetParams(IRobotNonlinearLinkSemiAxisType.I_NLSAT_NEGATIVE))
KnnLP_negative.d1 = d1_negative[i]
KnnLP_negative.K1 = K1_negative[i]
KnnLP_negative.K2 = K2_negative[i]
KNLL.SetParams(KnnLP_negative)
node = IRobotLabel(labels.Create(IRobotLabelType.I_LT_NODE_SUPPORT, nodeSupportName[i]))
relData = IRobotNodeSupportData(node.Data)
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_UX, KNLL.Name)
relData.NonlinearModel.Set(IRobotDegreeOfFreedom.I_DOF_UY, KNLL.Name)
relData.UZ = nodeSupportData[0]
relData.RX = nodeSupportData[1]
relData.RY = nodeSupportData[2]
relData.RZ = nodeSupportData[3]
labels.Store(node)
application.Visible = True
application.Interactive = True
application.Project.ViewMngr.Refresh()
OUT = node
Can't find what you're looking for? Ask the community or share your knowledge.