hi, thank you all, i tried to put my groups in the suggested ways into a loop, but i always get errors. with '@@groups' i would reach all grups, wouldn't i ?
i will try to describe the whole problem:
i have a defined amount of groups with one basic construction point (thanx dan), the amount changes by user input, so it must be variable, so there may be 2 or 20 @group_handlauf_mitte - groups.
@group_handlauf_mitte1
@group_handlauf_mitte2
@group_handlauf_mitte3
@group_handlauf_mitte4
and so on
i cannot find out, how can i access those 'group_handlauf_mitte ' groups in a loop to be able to select a group by
@group_handlauf_mitte[index].entities. (my index here ist PODESTNR)
i also tried to create the group name as a string-combination within a loop
for step 1..20
a = "group" + step.tp_s.name
a.name = a
end
but that's obviously not working , too.
at the moment i have to define like this:
if @podestnr == 1
entities = @group_handlauf_mitte1.entities
new_line = entities.add_line rl13, rl14
entities = @group_handlauf_mitte1.entities
elsif @podestnr == 2
entities = @group_handlauf_mitte2.entities
new_line = entities.add_line rl13, rl14
entities = @group_handlauf_mitte2.entities
elsif @podestnr == 3
entities = @group_handlauf_mitte3.entities
new_line = entities.add_line rl13, rl14
entities = @group_handlauf_mitte3.entities
elsif @podestnr == 4
entities = @group_handlauf_mitte4.entities
new_line = entities.add_line rl13, rl14
entities = @group_handlauf_mitte4.entities
end
instead of this i would like to make a loop in which STEP decides, which grop's entities will become ENTITIES, but only for those groups, not all groups i have.
hopefully i can once understand the syntax for group selection by index, because i could then make the ruby-code many times shorter.
in this loop i need the griup name 1,2,3,4 to become dependent from the index MTH
model = Sketchup.active_model
y1 = 0 - @run ## the overall variables come from earlier code !!!
y2 = 0
y3 = @run
z = @rise
pf = []
for mth in 1..10
entities = @group_handlauf_mitte1.entities ### MTH instead of 1 needed
entities.erase_entities entities[0]
rl1 = [0, y1, 0]
rl2 = [0, y2, z]
group = @group_handlauf_mitte1 = entities.add_group ### MTH instead of 1 needed
entities2 = @group_handlauf_mitte1.entities ### MTH instead of 1 needed
new_line = entities2.add_line rl1, rl2
length = new_line.length
pf[mth] = [0, 0 - @run+@run*@il*(mth-1)+@run*@la*(mth-1)+@ro.abs, (mth-1)*@il*@rise+@sr] #mitte
#point1 = Geom;;Point3d.new pf51
#constpoint = entities.add_cpoint point1
centerpoint = pf[mth]
new_line = entities2.add_line rl1, rl2
vector = new_line.line[1]
vector2 = vector.normalize!
edges = entities2.add_circle centerpoint, vector2, @thradius
kreis = entities2.add_face edges
entity1 = entities[0]
kurvem = entity1.all_connected
status1 = kreis.followme kurvem
end
thanx for helping
stan