Check if support Haslabel API

1234eddie
Advocate
Advocate

Check if support Haslabel API

1234eddie
Advocate
Advocate

Hi all,

 

I'm currently working on a script, that needs to check if a node in my model has a support applied and also to check the name of the support. 

I found a example code which uses the call HasLabel.

This is how i implemented it in my code:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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
#The inputs to this node will be stored as a list in the IN variables.

Sup_nodes = IN[0]
SUP_LAB = IN[1]


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


node = IRobotNode
node_col = structure.Selections.Get(IRobotObjectType.I_OT_NODE)
node_col = project.Structure.Nodes.Get("22")
node = node_col


if node.HasLabel(IRobotLabelType.I_LT_SUPPORT):
	OUT = "Support aanwezig"
	if node.HasLabel(IRobotLabelType.I_LT_SUPPORT,"2.705NAP"):
		OUT = "Support en label aanwezig"

When running this script the first if statement returns "Support aanwezig". works perfect.

but on the second if statement i get the error "Traceback (most recent call last):
File "<string>", line 33, in <module>
StandardError: Error while invoking HasLabel."

Does anyone know how to check also if the label is applied?

@Rafal.Gaweda @cool.stuff @jokiller70 

 

Thanks in advance 

 

ps: what i want to achieve with this function is to speed up a 'brute force search' model. because know the script is overwriting the nodesupports in all runs, while there are only some small changes.

 

Gr Edward

 

files are attached.

 

0 Likes
Reply
Accepted solutions (1)
535 Views
2 Replies
Replies (2)

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution

Hi @1234eddie 

 

There is no method with input mentioned by You.

 

haslabel.jpg So if it HAS label, Get it and check its name



Rafal Gaweda
0 Likes

1234eddie
Advocate
Advocate

@Rafal.Gaweda 

Thanks for your reply. 

i have not implemented it yet.

but thanks to an answer you gave in an other topic i have used the function

'application.Interactive = False

(Setlabel part)

application.Interactive = True'

 

Which increased the speed of the script enough for now.

 

Many thanks

 

Gr Edward

0 Likes