cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Domagoj Lukinic
Booster

ADDGROUP in loops

Hi all,

I am trying to merge my geometry into one, i found this:
https://community.graphisoft.com/t5/GDL/add-several-GROUPs-without-additional-lines/m-p/274202

However is ti possible to not have an error in the code ("Identical operands in group operation").

I need something like this for my code:

pen 1
material 1

group "object":
	gosub "Fixed geomety"

	gosub "Looped geometry"
endgroup

res = addgroup ("object", "object")
placegroup res 


end:!=====================================================

"Fixed geomety":
	block 1,1,1
return

"Looped geometry":
	for i=1 to 5
		addx 1/2
		block 1,1/2,1
	next i
return

 

I tried to add an empty group but no result, any solutions?

1 Solution

Accepted Solutions
Pertti Paasky
Expert

I use this:


val_a=1
val_b=2
val_z=1

group "mygroup"
block val_a,val_b,val_z
endgroup

mygroup="mygroup"

for i= 1 to 3
   
group "mygroup"+str("%.0m",i)
add i*.2,i*.3,i*.1  
block val_a,val_b,val_z
del 1
endgroup

mygroup=addgroup(mygroup,"mygroup"+str("%.0m",i))
killgroup "mygroup"+str("%.0m",i)
next i

placegroup mygroup
killgroup mygroup
- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

Go to post

3 Replies 3
Jochen Suehlo
Moderator Emeritus

I think the problem is the Addgroup with 2 identical Group Names. Try this:

pen 1
material 1


	group "object1"
		gosub "Fixed geomety"
		gosub "Looped geometry"
	endgroup

	group "object2"
		gosub "Fixed geomety"
		gosub "Looped geometry"
	endgroup

res = addgroup ("object1", "object2")
placegroup res 


end:!=====================================================

"Fixed geomety":
	block 1,1,1
return

"Looped geometry":
	for i=1 to 5
		addx 1/2
		block 1,1/2,1
	next i
return

 

Jochen Suehlo . AC12-29 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de

I wrote a number that gets 1 added each loop but is converted to a string for the group name. That way there is never a duplicate group name

Pertti Paasky
Expert

I use this:


val_a=1
val_b=2
val_z=1

group "mygroup"
block val_a,val_b,val_z
endgroup

mygroup="mygroup"

for i= 1 to 3
   
group "mygroup"+str("%.0m",i)
add i*.2,i*.3,i*.1  
block val_a,val_b,val_z
del 1
endgroup

mygroup=addgroup(mygroup,"mygroup"+str("%.0m",i))
killgroup "mygroup"+str("%.0m",i)
next i

placegroup mygroup
killgroup mygroup
- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!