2023-02-20 04:19 PM - last edited on 2023-02-24 02:26 PM by Daniel Kassai
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:
This is the parametric one:
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?
Solved! Go to Solution.
2023-02-20 08:55 PM - edited 2023-02-20 08:58 PM
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.
2023-02-20 06:52 PM
There are actually two types of groups.
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!
2023-02-20 07:04 PM - edited 2023-02-20 07:09 PM
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:
I'm doing something wrong, I'm just not sure exactly what...
2023-02-20 08:55 PM - edited 2023-02-20 08:58 PM
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.
2023-02-20 09:21 PM
check you last line must looks like it
topcomplete = SUBGROUP ("topsection", "topgrooves")
2023-02-21 01:52 AM
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
2023-02-21 05:30 PM
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.
2023-02-21 05:57 PM
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
2023-02-21 06:10 PM
then change your groups name. i guess "topsection" is a reserved word
2023-02-22 03:18 AM
Try ...
topgroup = subgroup("topsection","topgrooves")
placegroup topgroup
Barry.