GDL Help Please
![Red Red](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_353.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-16 05:15 PM
Red
i7 8700k
ROG Strix Z390-E MoBo
64gb RAM
EVGA GeForce GTX 2080
_______________________
http://www.facebook.com/flatcreekdesignstn
http://www.sraarchitects.biz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-16 06:25 PM
Red wrote:FOR/NEXT loop. I assume the RECT2s need to be spaced out in some way.
What I'm trying to do is multiple as many copies as I need of an 2D object (rect2 0,0,2',2' ) by an integer parameter.
FOR k=1 TO RedsIntegerParam ADD2 (k-1)*x_spacing, (k-1)*y_spacing RECT2 0,0,2',2' DEL 1 NEXT kFor an array multiply you need to nest another loop inside.
Red wrote:In principle, yes. The array might be helpful/needed, or maybe not. 8-ball says, answer hazy, post screenshot.
Also can each copy have a movable (SMART) hotspot in the middle allowing it to only move in the x axis. Would array be used in this process?
![](/legacyfs/online/emojis/icon_biggrin.gif)
![Red Red](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_353.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-16 07:25 PM
James wrote:Is it possible to add something to this code for each of them to move independently?
FOR k=1 TO RedsIntegerParam ADD2 (k-1)*x_spacing, (k-1)*y_spacing RECT2 0,0,2',2' DEL 1 NEXT k
Red
i7 8700k
ROG Strix Z390-E MoBo
64gb RAM
EVGA GeForce GTX 2080
_______________________
http://www.facebook.com/flatcreekdesignstn
http://www.sraarchitects.biz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-16 08:40 PM
Red wrote:So we have a object made of some number of squares, each with its own offset from some origin, each position graphically editable.
each of them to move independently?
![](/legacyfs/online/emojis/icon_question.gif)
For that you need an array. To edit the offset graphically, it needs to be a parameter, that means a parameter array. Since (I'm pretty sure) you can't have a dynamic parameter array, you'll need to pick number as a limit. It can be big. I don't know how big, it's more than 256.
To make an array parameter click the button to the right of the parameter type (length, etc.) button. This opens the array values dialog. Since you only have one offset, you need just one column and some number of rows. Click the "1" button to the left of the top row, and then click insert however many times. OK. To change this later, don't click the array button again, click 'Set' at the top next to delete.
(The number of rows will be the limit. I would also offer users a parameter for how many copies they actually want; tell them about the limit there.)
Assuming each offset is from 0. Also assuming a hard-coded 2'x2' RECT2:
!Parameter: Qty is user's # of copies !Array parameter: x_offset is offset distances FOR k=1 to Qty HOTSPOT2 0, 0, hsid, x_offsetFor each copy, it reads the value in the array in the slot numbered 'k' and builds everything from that., 1 : hsid=hsid+1 !b HOTSPOT2 x_offset , 0, hsid, x_offset , 2 : hsid=hsid+1 !m HOTSPOT2 -1, 0, hsid, x_offset , 3 : hsid=hsid+1 !r RECT2 x_offset -1.0', -1.0', x_offset +1.0', 1.0' !optional corner spots on rect2 HOTSPOT2 x_offset -1.0', -1.0' HOTSPOT2 x_offset +1.0', -1.0' HOTSPOT2 x_offset -1.0', 1.0' HOTSPOT2 x_offset +1.0', 1.0' NEXT k
If you want default values in the array of other than zero, you need to put them in using the set button.
If the squares all start at zero, the user doesn't know which one they're moving, but to me it wouldn't matter.
The array parameter can be hidden. The user only needs to interact with it graphically IMO.
Put in an error handler for the Qty: IF Qty>RedsArraySize THEN Qty= RedsArraySize. Note: RedsArraySize exists in your mind, it's not a variable.
![TomWaltz TomWaltz](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_74.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-16 08:44 PM
You will also need some way to define all those array values, probably stretchy hotspots.
That would be:
unID = 1 FOR k=1 TO RedsIntegerParam DIM x_spacing[], y_spacing[] ! Define two dynamic arrays HOTSPOT2 x_spacing, 0, unID, y_spacing , 1+128 : unID = unID +1 HOTSPOT2 x_spacing , -1, unID, y_spacing , 3 : unID = unID +1 HOTSPOT2 x_spacing , y_spacing, unID, y_spacing , 2 : unID = unID +1 HOTSPOT2 0, y_spacing , unID, x_spacing , 1+128 : unID = unID +1 HOTSPOT2 -1, y_spacing , unID, x_spacing , 3 : unID = unID +1 HOTSPOT2 x_spacing , y_spacing , unID, x_spacing , 2 : unID = unID +1 <the rest of your code>
![Red Red](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_353.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-24 03:22 PM
!!Pipe Column FOR k=1 to NUMOPC HOTSPOT2 0, 0, hsid, X4PC, 1 : hsid=hsid+1 !b HOTSPOT2 X4PC , 0, hsid, X4PC , 2 : hsid=hsid+1 !m HOTSPOT2 -1, 0, hsid, X4PC , 3 : hsid=hsid+1 !r ADD2 (PCT/2)*(-1),0 RECT2 X4PC ,O,PCT+X4PC ,S2SF-SFT-HDRS DEL TOP !!FOOTER SET FILL 6 POLY2_B{2} 6, 7, 6, 91, -1'-2",-ST, 1, (-1'-2")+2",(ST+4")*(-1), 1, (-1'-2")+2",(ST+4"+10")*(-1), 1, (1'-2")-2",(ST+4"+10")*(-1), 1, (1'-2")-2",(ST+4")*(-1), 1, 1'-2",-ST,1, -1'-2",-ST,1 PEN 91 LINE2 -1'-2",-ST,1'-2",-ST PEN 2 LINE2 (-1'-2")+2",(ST+4")*(-1),(1'-2")-2",(ST+4")*(-1) NEXT k
First off thanks for the help on getting me this far. I'm starting to see the light at the end of the tunnel. Anyway the pipe column is working great as you can see above. Now I'm trying to add the footer which is the 2nd POLY2_B{2} and the two LINE2. Will I need to reference all of their "X" values as a parameter plus add the
Red
i7 8700k
ROG Strix Z390-E MoBo
64gb RAM
EVGA GeForce GTX 2080
_______________________
http://www.facebook.com/flatcreekdesignstn
http://www.sraarchitects.biz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-24 06:08 PM
It can become cumbersome to put in operations for the offset in every XY coord pair of the shapes. The alternative is to use a transformation of the offset distance instead.
FOR k=1 to Qty HOTSPOT2 0, 0, hsid, x_offsetFor each iteration:, 1 : hsid=hsid+1 !b HOTSPOT2 x_offset , 0, hsid, x_offset , 2 : hsid=hsid+1 !m HOTSPOT2 -1, 0, hsid, x_offset , 3 : hsid=hsid+1 !r ADDx x_offset RECT2 -1.0', -1.0', +1.0', 1.0' !optional corner spots on rect2 HOTSPOT2 -1.0', -1.0' HOTSPOT2 +1.0', -1.0' HOTSPOT2 -1.0', 1.0' HOTSPOT2 +1.0', 1.0' DEL 1 NEXT k
Do the hotspots for x_offset
Move the origin to x_offset
Draw the stuff.
Go back to 0. (DEL 1)
A couple more tips: Rather than typing 1'-2" over and over, create a variable. You can call it anything, I would call it X1. This is faster for AC to parse and easier for you to read/understand/change later. I would write your polygon like this:
X1=14" X2=X1-2" Y1=-ST Y2=-(ST+4") Y3=-(Y2+10") POLY2_B{2} 6, 7, 6, 91, -X1, Y1, 1, -X2, Y2, 1, -X2, Y3, 1, X2, Y3, 1, X2, Y2, 1, X1, Y1, 1, -X1, Y1, 1There's probably a typo in there but you get the idea. Also, use inches rather than feet & inches; faster parsing again. If you have fractions, convert them to decimals. (1.5" not 1 1/2")
Don't use DEL TOP. The only place you can safely use it is at the very end of a script. Once you start doing more complexly structured scripts (subroutines, macros), DEL TOP will wreck your life. Always delete only the number you need to. You can get help keeping track of the transformation stack by using PRINT NTR(), which tells you the number of trans at that point in the script.
![TomWaltz TomWaltz](https://community.graphisoft.com/legacyfs/online/avatars/actalk/a27517d178c246abb0dd17b6f4f6758a_74.jpg)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-24 08:36 PM
Whenever I start a new loop, I set delNum to 0. Then I make compound statements, such as : ADD2 xOffset, yOffset : delNum = delNum + 1
Then at the end of the loop, I DEL delNum
This allows me to bury ADD, MUL and ROT statements inside loops anywhere, and DEL the proper varying number at the end.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-24 09:29 PM
TomWaltz wrote:Tom,
I've gotten in the habit of using a variable: delNum.
Whenever I start a new loop, I set delNum to 0. Then I make compound statements, such as : ADD2 xOffset, yOffset : delNum = delNum + 1
Then at the end of the loop, I DEL delNum
This allows me to bury ADD, MUL and ROT statements inside loops anywhere, and DEL the proper varying number at the end.
I seem to recognize the programmer spirit sleeping in you, but this is an interesting tip.
![](/legacyfs/online/emojis/icon_smile.gif)
Thank you for sharing!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2005-06-28 08:17 PM
CUTPLANE : cutz=cutz+1
CUTPOLY yada yada
cutz=cutz+1
etc., then at the end,
FOR k=1 TO cutz
CUTEND
NEXT k
I was thinking that counting the transformations isn't any better than using NTR(), but it is better, because in a macro you can have it delete only the local transformations.