Oh OK I see that you wish to group the same heights onto one line with the height total at the end.
I’ll need to think a bit on this.
EDIT:
Ok when you change a DC’s attributes, the DC engine makes it a unique component, so it copies the definition, and gives the new one a name with “#number
” appened.
ie, “Enkelzijdige kolom#1
”, “Enkelzijdige kolom#2
”, etc.
So when searching for matching definitions, you need to use a Regular Expression to match all definitions whose name begins with “Enkelzijdige kolom
”.
dname = "Enkelzijdige kolom"
deflist = Sketchup.active_model.definitions
matches = deflist.find_all {|d|
!d.group? && !d.image? && d.name =~ /\A(#{dname})/
}
The escaped A (\A
) means match at beginning of string.
Then you need to iterate all matches
, each one will be the data for each line:
total = 0
matches.each {|definition|
number = definition.count_used_instances
total += number
attribute = definition.get_attribute(dictionary_name, 'lenz').to_l
height = Sketchup.format_length( attribute )
@report << format( DATALINE, definition.name, height, number )
}
NOTE: The above snippet was updated in a following post:
http://forums.sketchup.com/t/dynamic-component-count-to-text-file/20979/22