How to set_attribute to a line


Is it possible to set an attribute to a line? (No its not - but??)

#this don't work
my_line.set_attribute "dict", "key", "value"

Because I need to be able to search the model for specific lines to get the length of those lines.

Is there any other workarounds to solve that problem?

Edges, as well as all other Entities, can have attributes:

Id the variable my_line referring to an Edge or the mathematical concept of a line?

are you sure?

line_with_attr = @component_def.entities.add_edges edge_pts

# line_with_attr have no set_attribute method
puts	line_with_attr.methods

In my case it dont have a set_attribute method. I use SU2016

add_edges returns an Array of Edge objects, not an Edge object.

You can divide your code into smaller steps and output the results in the console to know what objects types you are working with.

1 Like

wow yes - now it works!

line_with_attr = @component_def.entities.add_edges edge_pts

line_with_attr.each_with_index do |myline,g|
  # working 
  myline.set_attribute "rsdict", "yv_line_length", 0.00

thank you very much!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.