Assign Member type to bar using Dynamo

Hello,

I’m working with Dynamo&Robot. Structural Analysis package do not have Assign Member Type node. So when I generate structure I have to manually set member types. It’s difficult in 1 structure and I want to generate few of them.

How can I automatize this process? Is there a way to write a code in Dynamo to assign member types to particular bars? Or will I have to link Dynamo-Excel-Robot and use API, if its possible at all.

regards
Marcin

By member type do you mean sections?
Or is it the “Type” value under “General” e.g. “Simple Bar”?

Nope, no section.
Member type like you mentioned “Simple Bar”.

Hi I’ve had a fight in the SDK, you should have a look it’s 2415 pages of confusion :slight_smile:

This small script will accomplish what you’re after, all you’ll need is the bar-numbers and name of the desired Member Type :slight_smile: (Make sure you are pointing at the interop on your system if this is not the same as mine :slight_smile:

#Import libraries
import clr
# 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(user +r"\Dynamo\Dynamo Revit\1.3\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
#Create empty lists
app = RobotApplicationClass()
#Define output
AvailableNames = []
#Connect to Structure server of Bars and Labels.
bars = app.Project.Structure.Bars
labels = app.Project.Structure.Labels
barnum = 1
#Set the Structural object to Beam for bar number 1
bars.SetStructuralType(barnum, IRobotObjectStructuralType.I_OST_BEAM)
#Get the member type (of bar number 1)
membertypename = bars.Get(barnum).GetLabel(IRobotLabelType.I_LT_MEMBER_TYPE).Name
#Set the member type (of bar number 1) to
bars.Get(barnum).SetLabel(IRobotLabelType.I_LT_MEMBER_TYPE,'Beam')
#app.Project.Structure.Labels.GetAvailableNames(IRobotLabelType.I_LT_MEMBER_TYPE).Set(2,'Beam')
x = labels.GetAvailableNames(IRobotLabelType.I_LT_MEMBER_TYPE).Count
#Find available names:
for i in range(1,x):
	nm = labels.GetAvailableNames(IRobotLabelType.I_LT_MEMBER_TYPE).Get(i)
	AvailableNames.append(nm)
OUT = AvailableNames, membertypename

image

2 Likes

Thank you!
I’m completely novice in SDK, although I try to find something in Robot API Tutorial.
I write my thesis in Dynamo/Revit and it seems that this is the only part where I have to deal with SDK/Python scritp.
So I managed set member type for a bar number from input. However I have to assign different member types to a different bars.
Could you help me with figure out how to:

  • plug an list to an INPUT,
  • and then assign particular number from a list of member type names to that list from INPUT.

Then I will just feed script with several ‘barnum1’ ‘barnum2’… and copy line number 25:
e.g bar.Get(barnum1).SetLabel(IRobotLabelType.I.LT_MEMBER_TYPE, e.g third name of list)

Hi @MarcinLas

I am myself writing my thesis within the same field of study, I can really encourage you to learn either C# or Python for the purposes of extending the power of Dynamo even further and to connect to the Revit API and perform tasks not possible using mere nodes. :wink:

I’ll show you how to input a list og lists (of bar numbers) and as long as that list correspond to the list of names it will set name 1 for list 1 in the member list of lists.

Also, if a comment solved your request please mark that comment as the solution, and maybe leave a like here and there.

import clr
from System import Environment
user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
clr.AddReferenceToFileAndPath(user +r'\Dynamo\Dynamo Revit\1.3\packages\Structural Analysis for Dynamo\bin\RSA\interop.RobotOM.dll')
from RobotOM import *
from System import Object
app = RobotApplicationClass()
bars = app.Project.Structure.Bars
Barnumbers = IN[0]
MembertypeNames = IN[1]
p = 0
try:
	for i in MembertypeNames:
		for j in Barnumbers[p]:
			bars.Get(j).SetLabel(IRobotLabelType.I_LT_MEMBER_TYPE , i)
		p = p + 1
	output = 'Success'
except:
	output = 'Failure, Check List Lengths'
OUT = output
4 Likes

That’s a bullseye! Thank you @Jonathan.Olesen

So it’s time to make friends with mr.Python!

1 Like

Hello everyone,
First I must say I am totally new with Dynamo +Robot,
I was trying to model a cable supported bridge in Dynamo, when I realized that I cannot set the member type, as the section or the material. So I looked on internet how can I do and came across with this post, that helped me a lot.
Now, I am able to set the member type (shown in the pictures above) except for the cable type, I don’t know why is not working.
Moreover, I would interest in set the section of the cable too, but with the node Setions only show the normal sections not cable section.

Pd: I thought to open a new post, but is the continue of this script, If is wrong I will open a new post.
i attached my Dynamo file, is only an arch where I doing trials.

SOLVED. I read the document of the API and how to call the cables.

> Blockquote
for j in barnum:
bars.SetStructuralType(j, IRobotObjectStructuralType.I_OST_UNDEFINED)
bars.Get(j).SetLabel(IRobotLabelType.I_LT_BAR_CABLE,‘Cable_3’)

2 Likes

Hi @Jonathan.Olesen,

thanks a lot for this solution!

I was wondering if it is possible to create superbars in Dynamo?
(superbars = joining several timber members and create a new member)

Thanks for your help!

Best regards,
Ina

Hi @Jonathan.Olesen. I am struggling to get this to work in Dynamo, through a Dynamo-Robot integration. I have tried to put in exactly the same script you performed in a new dynamo file, but get the message “Failure, Check List Length” due to the value being null.
By studying the script and doing some error checking, it seems like its the bars.Get(j).SetLabel function that is the problem. The Get functions get a error Type error.

What I would like to do in my script originally. Is to give the analytical bars, which already have a section, material and release, a material type. To then make the steel design more easily.

Im also curious if its possible to create the steel design groups through dynamo. As id like to create column groups for each floor etc. Rather than taking all columns quickly, or doing it all manually.

Sincerely
Thor