2005-06-16 05:15 PM
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?
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
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?
!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
2005-06-16 08:44 PM
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>
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
2005-06-24 06:08 PM
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
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")
2005-06-24 08:36 PM
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.
2005-06-28 08:17 PM