Creation of User-defined sections through Python Codes

Creation of User-defined sections through Python Codes

Anonymous
Not applicable
203 Views
0 Replies
Message 1 of 1

Creation of User-defined sections through Python Codes

Anonymous
Not applicable

Hi everyone, I am working on designing a Python script to create Ax, Iy,Iz....sections in Dynamo because  I need to create them using visual programming nodes. However, the script releases the following error "unexpected error from". I must admit I am novel using Python language.

Construccincivil_0-1654281102436.png

Can anyone help me in finding the error in the script, please?. I attach the script as follows:

Best

 

# Load the Python Standard and DesignScript Libraries
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)
# add the reference to the interop file shipped with the package
clr.AddReferenceToFileAndPath("C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2022\Dynamo\2.11\Rsa\Package\SAD\bin\RSA"

# add needed import to be able to use Robot Structural Analysis objects
from RobotOM import *
from System import Object

# The inputs to this node will be stored as a list in the IN variables

# Define inputs
SectionName = IN[0]
SectionIy = IN[1]
SectionMaterial = IN[2]

# Connect to the running instance of Robot Structural Analysis
application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
ProjectsPrefs = project.Preferences
bars = structure.Bars

# Create user-defined section
 lab_serv = IRobotLabelServer
 lab_serv = labels
 sec = IRobotLabel
 sec = lab_serv.create(IRobotLabelType.I_LT_BAR_SECTION, SectionName)
 data = sec.data
 data.Type = IRobotBarSectionType.I_BST_STANDARD
 data.ShapeType = IRobotBarSectionType.I_BSST_UNKNOWN
 nonst_data = IRobotBarSectionNonstdData
 nonst_data = data.CreateNonstd(0)
 nonst_data.SetValue(IRobotBarSectionNonstdDataValuedata.I_BSDV_AX, 0)
 nonst_data.SetValue(IRobotBarSectionNonstdDataValuedata.I_BSDV_AY, 0)
 nonst_data.SetValue(IRobotBarSectionNonstdDataValuedata.I_BSDV_AZ, 0)
 nonst_data.SetValue(IRobotBarSectionNonstdDataValuedata.I_BSDV_IX, 1)
 nonst_data.SetValue(IRobotBarSectionNonstdDataValuedata.I_BSDV_IY, SectionIy)
 nonst_data.SetValue(IRobotBarSectionNonstdDataValuedata.I_BSDV_IZ, 2)
 data.MaterialName = SectionMaterial
 data.CalcNonstdGeometry()
 lab_serv.Store(sec)
 
# Assign the name to the OUT variable
OUT = "ok"

 

 

0 Likes
204 Views
0 Replies
Replies (0)