License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
GDL
About building parametric objects with GDL.
SOLVED!

Problem with SUBGROUP

Jim Allen
Advisor

I'm building a parametric component for a modular battery storage unit. Everything works in terms of basic geometry creation, but I want to finish the component with some additional details - recessed handles and grooves.

 

This is what the 'dumb' component looks like:

 

Screenshot 2023-02-20 at 15.10.40.png

This is the parametric one:

Screenshot 2023-02-20 at 15.10.15.png

I need to undertake a subtraction to create the grooves and handles. I've created groups, and looked up the SUBGROUP syntax, but I'm getting an error.

 

This is my script:

 

"top":

GROUP "topsection"

ADDZ (footheight*2) + baseheight + modoffset +((modoffset + modheight)* modcopies)
material mat2
!curved corner 1

ADDX footheight !footheight is same dimension as corner radius
ADDY footheight
CYLIND topheight, footheight 
del 2

!curved corner 2
ADDX A-footheight
ADDY footheight
CYLIND topheight, footheight
del 2

!curved corner 3
ADDX footheight
ADDY B-footheight
CYLIND topheight, footheight
del 2

!curved corner 4
ADDX A-footheight
ADDY B-footheight
CYLIND topheight, footheight
del 2

SLAB 4, topheight, 
footheight, 0, 0,
A-footheight,0, 0,
A-footheight,B, 0,
footheight, B, 0

SLAB 4, topheight, 
0, footheight, 0,
A, footheight, 0,
A, B-footheight, 0,
0, B-footheight, 0

ENDGROUP

GROUP "topgrooves"

!groove1
material mat3
ADDX footheight
SLAB 4, topheight, 
0, 0, 0,
GrooveWidth, 0, 0,
GrooveWidth, GrooveDepth, 0,
0, GrooveDepth, 0
Del 1

!groove2
material mat3
ADDX A - GrooveWidth - footheight
SLAB 4, topheight, 
0, 0, 0,
GrooveWidth, 0, 0,
GrooveWidth, GrooveDepth, 0,
0, GrooveDepth, 0
Del 1

!groove3
material mat3
ADDX A - GrooveWidth - footheight
ADDY B - GrooveDepth
SLAB 4, topheight, 
0, 0, 0,
GrooveWidth, 0, 0,
GrooveWidth, GrooveDepth, 0,
0, GrooveDepth, 0
Del 2

!groove4
material mat2
ADDX footheight
ADDY B- GrooveDepth
SLAB 4, topheight, 
0, 0, 0,
GrooveWidth, 0, 0,
GrooveWidth, GrooveDepth, 0,
0, GrooveDepth, 0
Del 2
ENDGROUP

topcomplete = SUBGROUP (topsection, topgrooves)

del top

RETURN

 

I've checked the syntax, but when I run the Check Script function, I get this error:

 

Group name or group type expression required at line 249 in the 3D script of file BYD Battery Box LVS.gsm.

 

I'm not sure what I'm doing wrong - any ideas?

 

Archicad 27 UKI | OS X 12.7.1 Monterey
1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Now you've made the opposite error! Your last PLACEGROUP of course must not have the quotes 😉

If unsure: just reread my first post.

 

EDIT: Also I'm not sure why you place the group which is used for the subtraction. If you only did this temporarily for debugging, then it's fine.

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»

View solution in original post

11 REPLIES 11
runxel
Legend

There are actually two types of groups.

  1. Groups you have created with the GROUP command, which you will refer to with a string: "my group" (can have spaces)
  2. Groups that result from a compound command, like SUBGROUP.

The result of the latter will be stored inside a variable – kind of like a function in other languages.

Funfact: VARTYPE will show type 2 for this variable (means string!), but you can not actually do string operations with this. Instead this works like a pointer to the resulting geometry stored in memory.

So check your SUBGROUP command: You use variables in error here, instead the names would need to be wrapped in quotes.
Happy coding!

 

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»

Thanks, I've fixed the group definitions, and amended the SUBGROUP syntax, but it's not working.

There are no errors, and the geometry is displaying correctly - except the geometry subtraction.

 

This is the script:

 

"top":


!ADDZ (footheight*2) + baseheight +((modoffset + modheight)* modcopies)
ADDZ (footheight*2) + baseheight + modoffset +((modoffset + modheight)* modcopies)

GROUP "topsection"
material mat2
!curved corner 1

ADDX footheight !footheight is same dimension as corner radius
ADDY footheight
CYLIND topheight, footheight 
del 2

!curved corner 2
ADDX A-footheight
ADDY footheight
CYLIND topheight, footheight
del 2

!curved corner 3
ADDX footheight
ADDY B-footheight
CYLIND topheight, footheight
del 2

!curved corner 4
ADDX A-footheight
ADDY B-footheight
CYLIND topheight, footheight
del 2

SLAB 4, topheight, 
footheight, 0, 0,
A-footheight,0, 0,
A-footheight,B, 0,
footheight, B, 0

SLAB 4, topheight, 
0, footheight, 0,
A, footheight, 0,
A, B-footheight, 0,
0, B-footheight, 0

ENDGROUP
PLACEGROUP "topsection"


GROUP "topgrooves"

!groove1
ADDX footheight
ADDY -nudge
SLAB 4, topheight+(nudge*2), 
0, 0, -nudge,
GrooveWidth, 0, -nudge,
GrooveWidth, GrooveDepth, -nudge,
0, GrooveDepth, -nudge
Del 2

!groove2
ADDX A - GrooveWidth - footheight
ADDY-nudge
SLAB 4, topheight+(nudge*2), 
0, 0, -nudge,
GrooveWidth, 0, -nudge,
GrooveWidth, GrooveDepth, -nudge,
0, GrooveDepth+nudge, -nudge
Del 2

!groove3
ADDX A - GrooveWidth - footheight
ADDY B - (GrooveDepth-nudge)
SLAB 4, topheight+(nudge*2), 
0, 0, -nudge,
GrooveWidth, 0, -nudge,
GrooveWidth, GrooveDepth, -nudge,
0, GrooveDepth, -nudge
Del 2

!groove4
ADDX footheight
ADDY B - (GrooveDepth-nudge)
SLAB 4, topheight+(nudge*2), 
0, 0, -nudge,
GrooveWidth, 0, -nudge,
GrooveWidth, GrooveDepth, -nudge,
0, GrooveDepth, -nudge
Del 2

ENDGROUP
PLACEGROUP "topgrooves"
!
topsection = SUBGROUP ('topsection', 'topgrooves')
PLACEGROUP "topsection"


del top

RETURN

 

 

I've adjusted the positions and dimensions of the cutting grooves so that they project through the target geometry, but there's no solid subtraction happening - unless I'm missing something.

 

This is the resulting object:

 

Screenshot 2023-02-20 at 18.01.24.png

I'm doing something wrong, I'm just not sure exactly what... 

Archicad 27 UKI | OS X 12.7.1 Monterey
Solution

Now you've made the opposite error! Your last PLACEGROUP of course must not have the quotes 😉

If unsure: just reread my first post.

 

EDIT: Also I'm not sure why you place the group which is used for the subtraction. If you only did this temporarily for debugging, then it's fine.

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»
Jorge_Arreguin
Booster

check you last line must looks like it

 

topcomplete = SUBGROUP ("topsection", "topgrooves")

AllanP
Advocate

you may just want to just place the result of the subgroup...

placegroup subgroup("topsection","topgrooves")

 

remember to killgroup all groups at the end of the code.

killgroup "topsection"

killgroup "topgrooves"

 

"top":

GROUP "topsection"

ADDZ (footheight*2) + baseheight + modoffset +((modoffset + modheight)* modcopies)
material mat2
!curved corner 1

ADDX footheight !footheight is same dimension as corner radius
ADDY footheight
CYLIND topheight, footheight 
del 2

!curved corner 2
ADDX A-footheight
ADDY footheight
CYLIND topheight, footheight
del 2

!curved corner 3
ADDX footheight
ADDY B-footheight
CYLIND topheight, footheight
del 2

!curved corner 4
ADDX A-footheight
ADDY B-footheight
CYLIND topheight, footheight
del 2

SLAB 4, topheight, 
footheight, 0, 0,
A-footheight,0, 0,
A-footheight,B, 0,
footheight, B, 0

SLAB 4, topheight, 
0, footheight, 0,
A, footheight, 0,
A, B-footheight, 0,
0, B-footheight, 0

ENDGROUP

GROUP "topgrooves"

!groove1
material mat3
ADDX footheight
SLAB 4, topheight, 
0, 0, 0,
GrooveWidth, 0, 0,
GrooveWidth, GrooveDepth, 0,
0, GrooveDepth, 0
Del 1

!groove2
material mat3
ADDX A - GrooveWidth - footheight
SLAB 4, topheight, 
0, 0, 0,
GrooveWidth, 0, 0,
GrooveWidth, GrooveDepth, 0,
0, GrooveDepth, 0
Del 1

!groove3
material mat3
ADDX A - GrooveWidth - footheight
ADDY B - GrooveDepth
SLAB 4, topheight, 
0, 0, 0,
GrooveWidth, 0, 0,
GrooveWidth, GrooveDepth, 0,
0, GrooveDepth, 0
Del 2

!groove4
material mat2
ADDX footheight
ADDY B- GrooveDepth
SLAB 4, topheight, 
0, 0, 0,
GrooveWidth, 0, 0,
GrooveWidth, GrooveDepth, 0,
0, GrooveDepth, 0
Del 2
ENDGROUP

placegroup SUBGROUP ("topsection", "topgrooves")
killgroup "topsection"
killgroup "topgrooves"
del top

RETURN

 

 

AllanP_2-1676940694184.png

 

AllanP_0-1676940613844.pngAllanP_1-1676940657791.png

 

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)

Thanks - I thought that the duplicate PLACEGROUP statements would create duplicate geometry, but the solid operation was not functioning, so when they were omitted, I had no geometry!

 

I got caught out by use of single and double quotes, and no quotes at all.

Archicad 27 UKI | OS X 12.7.1 Monterey

placegroup subgroup("topsection","topgrooves") doesn't work for me in AC25, I get this message:

 

Keywords can't be used as variables at line 229 in the 3D script of file BYD Battery Box LVS.gsm

Archicad 27 UKI | OS X 12.7.1 Monterey

then change your groups name. i guess "topsection" is a reserved word

AC 22, 24 | Win 10

Try ...

 

topgroup =  subgroup("topsection","topgrooves")

placegroup topgroup

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11