automatic boxes
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2010-01-20 05:28 PM
ā2010-01-20
05:28 PM
actually i got the error of making more lines then the needed ones.
this is the actual script
for i = 1 to o_nmr step 1got tips?
block o_la , o_lu , h
if i * o_la < ed_la then
addx o_la
else
! for e = 1 to int( ( o_la * i ) / ed_la ) step 1
!
! if o_lu * e < ed_lu then
!
! addx o_la * int ( ( ed_la - (o_la *i) ) / i )
!
! addy o_lu
!
! endif
!
!
! next e
endif
next i
7 REPLIES 7
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2010-01-20 09:20 PM
ā2010-01-20
09:20 PM
I'm not sure I understand your description, but I think what you are looking for is:
if i * o_la > ed_la then
Keep in mind that this will repeat for each remaining value of i after the condition is met.
if i * o_la > ed_la then
Keep in mind that this will repeat for each remaining value of i after the condition is met.
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2010-01-22 02:23 PM
ā2010-01-22
02:23 PM
now i'm doing with a different script and more clear to read.
this is the new script...and similar problem...
this is the new script...and similar problem...
for e = 1 to int ( obj_nbr*obj_lenght/length_max) step 1
for i = 1 to obj_nbr step 1
block obj_lenght , obj_width , heigth
if int (i * obj_lenght / length_max ) < 1 then
addx obj_lenght
else
del top
addy obj_width*e
addx obj_lenght
endif
next i
next e
del top
mulz -1
block length_max,width_max,0.1
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2010-01-22 04:36 PM
ā2010-01-22
04:36 PM
Two things that may be problems...
Overall I find your code a bit difficult to decipher. If I understand what you are trying to do, this is how I would go about it...
FOR i = 1 TO number_Y + 1
or...
FOR i = 0 TO number_Y
Note the statement "del j-1". It seems that GDL increments the loop once more than you might expect (apparently one last time when the condition is NOT met) this makes the number of transformations one less than the final value of the increment variable ("j" in this case).
One other thing, I generally try to avoid using the "del top" statement. It's fine for simple parts, but as scripts get long it should only be used between clearly distinct sections of code that you want to absolutely share no transformations. Otherwise it is good to get in the habit of counting out and deleting just the number of transformations necessary.
matsgherri wrote:This will only execute more than once if the combined length of the objects is twice or more times the maximum length. This may be what you intend but I don't quite understand the logic. Is your intention to only model complete rows and leave off the last partial one?
for e = 1 to int ( obj_nbr*obj_lenght/length_max)
if int (i * obj_lenght / length_max ) < 1 thenThe only integers less than one are zero and negative. This is a curious way to do this. It also means that on the second row it will only execute for (approximately) half of the blocks that fit in the max length, on the third row for only a third and so on. I doubt this is your intention.
Overall I find your code a bit difficult to decipher. If I understand what you are trying to do, this is how I would go about it...
block_lg = 1.0 block_wd = 0.5 block_ht = 0.25 max_lg = 10 total_blocks = 36 number_X = INT(max_lg/block_lg) number_Y = INT(total_blocks/number_X) FOR i = 1 TO number_Y FOR j = 1 TO number_X Block block_lg, block_wd, block_ht addx block_lg NEXT j del j-1 addy block_wd NEXT iThis code skips the last partial row (as yours appears intended to do). To model the partial row you can change line 12 above to read:
FOR i = 1 TO number_Y + 1
or...
FOR i = 0 TO number_Y
Note the statement "del j-1". It seems that GDL increments the loop once more than you might expect (apparently one last time when the condition is NOT met) this makes the number of transformations one less than the final value of the increment variable ("j" in this case).
One other thing, I generally try to avoid using the "del top" statement. It's fine for simple parts, but as scripts get long it should only be used between clearly distinct sections of code that you want to absolutely share no transformations. Otherwise it is good to get in the habit of counting out and deleting just the number of transformations necessary.
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2010-01-22 05:45 PM
ā2010-01-22
05:45 PM
really impressive how much it is clean the code!
now i'll try to read more about this script you suggest beacuse it doesn't make to stop blocks if they're less than a row or too much for an area.
i'm thinking to see if it is possible to make a second or more level with this kind of script.
now i'll try to read more about this script you suggest beacuse it doesn't make to stop blocks if they're less than a row or too much for an area.
i'm thinking to see if it is possible to make a second or more level with this kind of script.
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2010-01-25 04:24 PM
ā2010-01-25
04:24 PM
it is hard to get a script for a right tiling of boxes.
with the for..next loop it is only going to multiply the row if the boxes are more then the maximum of it.
i would like to make it stop with the exact number i put in the parameters.
is there any script that can tell to stop?
with the for..next loop it is only going to multiply the row if the boxes are more then the maximum of it.
i would like to make it stop with the exact number i put in the parameters.
is there any script that can tell to stop?
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2010-01-25 05:05 PM
ā2010-01-25
05:05 PM
now i made a transitional script as the one posted
is there any stop command as other languages? could end script help?
obj_width = 3i still got to think how to stop the script when it has got to 8 instead to make 9 boxes!
obj_lenght = 2
obj_height = 0.5
obj_total_number = 8
area_width = 10
area_length = 15
area_thickness = 0.1
x_objcts_on_area = int (area_width/obj_width)
y_objects_rows_on_area = int (obj_total_number/x_objcts_on_area)
for k = 0 to y_objects_rows_on_area step 1
for j = 1 to x_objcts_on_area step 1
block obj_width,obj_lenght,obj_height
addx obj_width
next j
del j-1
addy obj_lenght
next k
del top
mulz -1
block area_width,area_length,area_thickness
is there any stop command as other languages? could end script help?
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2010-01-27 10:31 AM
ā2010-01-27
10:31 AM
solved
obj_width = 3 obj_lenght = 2 obj_height = 0.5 obj_total_number = 2 area_width = 10 area_length = 15 area_thickness = 0.1 x_objcts_on_area = int (area_width/obj_width) y_objects_rows_on_area = int (obj_total_number/x_objcts_on_area) FOR k=1 TO obj_total_number BLOCK obj_width, obj_lenght, obj_height ADDx obj_width IF k MOD x_objcts_on_area <.001 THEN DEL x_objcts_on_area ADDy obj_width ENDIF NEXT k del top mulz -1 block area_width,area_length,area_thickness