RSA API draw polyline

RSA API draw polyline

1234eddie
Advocate Advocate
941 Views
3 Replies
Message 1 of 4

RSA API draw polyline

1234eddie
Advocate
Advocate

Hi all,

 

I'm currently working on a script to draw a polyline in RSA by using a python script inside dynamo.

(i will use this line later to apply a load in it[it will be part of a panel edge])

 

But at the moment i can't get the script working. I get this error:

error method descriptor.jpg

 

This is the function inside RSA

Polyline in RSA.jpg

 

below my script i wrote:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReferenceToFileAndPath(user +r"\Dynamo\Dynamo Core\1.3\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
from RobotOM import *
from System import Object

application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
objects = structure.Objects
ProjectPrefs = project.Preferences

pts = application.Kernel.CmpntFactory.Create(IRobotComponentType.I_CT_POINTS_ARRAY)
#pts = application.Kernel.CmpntFactory.Create(IRobotComponentType.I_CT_GEO_POLYLINE)
obj_server = IRobotObjObjectServer
obj = IRobotObjObject

pts.SetSize(2)
pts.Set(1, 0, 0, 0)
pts.Set(2, 10, 0, 0)

obj_server.CreatePolyline(IRobotObjObjectServer.CreatePolyline,1,pts)

OUT = 0

I hope someone of you can tell me what is should change of append different?

 

Thanks in advance

 

gr Edward

files are attached.

0 Likes
Accepted solutions (1)
942 Views
3 Replies
Replies (3)
Message 2 of 4

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution

Hi @1234eddie 

 

Here You are:

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from System import Environment

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

# Place your code below this line

#user=Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReferenceToFileAndPath(r'c:\Users\gawedar\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll')

from RobotOM import *
from System import Object

application= RobotApplicationClass()
project= application.Project
structure=project.Structure
objects = structure.Objects

pts = application.CmpntFactory.Create(IRobotComponentType.I_CT_POINTS_ARRAY)

pts.SetSize(2)
pts.Set(1, 0, 0, 0)
pts.Set(2, 10, 0, 0)

objects.CreatePolyline(1,pts)

OUT = 0


Rafal Gaweda
Message 3 of 4

1234eddie
Advocate
Advocate

@Rafal.Gaweda 

Many thanks. 

I didn't realize that the polyline is a part of the objects group.

I will start a new topic about a question i have when using linear load on edge.

 

Thanks.

 

Gr. Edward. 

to complete this topic here is also the script with loops for multiple polylines.(file is also attached)

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReferenceToFileAndPath(user +r"\Dynamo\Dynamo Core\1.3\packages\Structural Analysis for Dynamo\bin\RSA\Interop.RobotOM.dll")
from RobotOM import *
from System import Object

Points = IN[0]
Count_points = IN[1]
NR_polyline = IN[2]

application = RobotApplicationClass()
project = application.Project
structure = project.Structure
labels = structure.Labels
loads = structure.Cases
objects = structure.Objects
ProjectPrefs = project.Preferences

pts = application.Kernel.CmpntFactory.Create(IRobotComponentType.I_CT_POINTS_ARRAY)

for j in range(len(Points)):
	pts.SetSize(Count_points[j])
	for i in range(len(Points[j])):
		pts.Set(Points[j][i][0],Points[j][i][1],Points[j][i][2],Points[j][i][3])
	objects.CreatePolyline(NR_polyline[j],pts)

OUT = 0
0 Likes
Message 4 of 4

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @1234eddie 

 


I will start a new topic about a question i have when using linear load on edge.

See this topic and macro there:

https://forums.autodesk.com/t5/robot-structural-analysis-forum/error-2110-problem-with-linear-loads/...



Rafal Gaweda
0 Likes