Design forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Object help using FOR NEXT Loop

Michele
Newcomer
Is everyone still using GDL talk or is this supposed to take the place of that too?

I'll just post in both places hoping someone can help.

I made an adjustable shelf object but I want the object to make some calculations for the user. I want the standards to calculate their spacing. I want the standards to start at 6" from one end of the shelf and stop at 6" from the other end and I want the spacing to be 2'-0" max. I've included some of the code from my object. Thanks for any help.

Michele


!Standards
PEN spen
MATERIAL stmat
ADDz bshigt
FOR k=1 TO nstand
ADDx sfromcorn
BLOCK 1",.5",shigt
DEL 1
ADDx stspace
NEXT k
DEL nstand


!Shelf
PEN shpen
MATERIAL shmat
LINE_TYPE shline
ADDz 6"
BLOCK wid,dep,0.75"

IF nshelves=2.00 THEN GOSUB 500

IF nshelves=3.00 THEN GOSUB 600

IF nshelves=4.00 THEN GOSUB 700

IF nshelves=5.00 THEN GOSUB 800

IF nshelves>5.00 THEN nshelves=5.00
IF nshelves<2.00 THEN nshelves=2
DEL 1


END:!------------------------------------------------


200:!Standards
ADDz 6"
ADDx wid*0.5
BLOCK 1",0.5",shigt
DEL 2
RETURN


300:!Standards
ADDz 6"
ADDx wid*0.333
BLOCK 1",0.5",shigt
ADDx wid*0.666
BLOCK 1",0.5",shigt
DEL 3
RETURN
AC10/12 USA 11882156, OS XP 2 GB Ram
7 REPLIES 7

David Larrew
Booster
Michele,

Just glancing at your loop in the provided code... It looks like you have not accounted for all of your "ADD" commands in the loop.

You have 3 "ADD"s and 1 "DEL" within the loop and you are only deleting 1 more "ADD" per loop after the "NEXT".

You could either revise the loop or add to the DEL after the loop.
David Larrew, AIA, GDLA, GSRC

Architectural Technology Specialist

a r c h i S O L U T I O N S



WIN7-10/ OSX 10.15.7

AC 5.1-25 USA

Michele
Newcomer
I had an object that worked but we had to put in how many standards & at what spacing and I wanted to see if I could give the objects some parameters like spacing not larger than 2'-0" and start spaing at 6" from both ends and have the object put in the amount of standards needed. I just don't know how to accomplish this part of it (which is really all of it isn't it .

Thanks for any help,
Michele
AC10/12 USA 11882156, OS XP 2 GB Ram

David Larrew
Booster
Oops - I glanced too quickly. The first tranformation is out of the loop. You might want to use this after the loop instead:

DEL k

It would help to know what is the code doing wrong. Is the overall height/length "Stretchy"? If it is, you will need to do a little calculation up-front (in the Master Script) before doing any geometry to allow for the stretchiness and lock-down the spacing.
David Larrew, AIA, GDLA, GSRC

Architectural Technology Specialist

a r c h i S O L U T I O N S



WIN7-10/ OSX 10.15.7

AC 5.1-25 USA

David Larrew
Booster
If I'm understanding you...
Michele wrote:
IF nshelves>5.00 THEN nshelves=5.00
IF nshelves<2.00 THEN nshelves=2
Should be placed ahead of the GOSUB calls if you are trying to control the "nshelves".
David Larrew, AIA, GDLA, GSRC

Architectural Technology Specialist

a r c h i S O L U T I O N S



WIN7-10/ OSX 10.15.7

AC 5.1-25 USA

Michele
Newcomer
Sorry to confuse anyone. Here is the complete code and please remember I am trying to muddle through coding. I starting making objects in the summer and I get to work on them about 1 hour every 2 weeks if I'm lucky. This object works but we have to put in how many standards & at what spacing and I wanted to see if I could give the objects some parameters like spacing not larger than 2'-0" and start spaing at 6" from both ends and have the object put in the amount of standards needed and at a spacing not larger than 2'-0" when I stretched it in plan. I just don't know how to accomplish this part of it (which is really all of it, isn't it ? It's strecthy in plan but I can't get it to calculate the no. of standards.

Thanks again,
Michele

Here's the code:

!Adjustable Shelves
!3D Script - Imperial
!with parameters
!Michele LaBucki July 2003

wid=A !Width
dep=B !Depth


!Standards
PEN spen
MATERIAL stmat
ADDz bshigt
FOR k=1 TO nstand
ADDx sfromcorn
BLOCK 1",.5",shigt
DEL 1
ADDx stspace
NEXT k
DEL nstand


!Shelf
PEN shpen
MATERIAL shmat
LINE_TYPE shline
ADDz 6"
BLOCK wid,dep,0.75"

IF nshelves=2.00 THEN GOSUB 500

IF nshelves=3.00 THEN GOSUB 600

IF nshelves=4.00 THEN GOSUB 700

IF nshelves=5.00 THEN GOSUB 800

IF nshelves>5.00 THEN nshelves=5.00
IF nshelves<2.00 THEN nshelves=2
DEL 1


END:!------------------------------------------------


200:!Standards
ADDz 6"
ADDx wid*0.5
BLOCK 1",0.5",shigt
DEL 2
RETURN


300:!Standards
ADDz 6"
ADDx wid*0.333
BLOCK 1",0.5",shigt
ADDx wid*0.666
BLOCK 1",0.5",shigt
DEL 3
RETURN


400:!Standards
ADDz 6"
ADDx wid*0.25
BLOCK 1",0.5",shigt
ADDx wid*0.5
BLOCK 1",.5",shigt
ADDx wid*0.75
BLOCK 1",.5",shigt
DEL 4
RETURN

500:!Shelf
LINE_TYPE shline
ADDz 1'-2"
BLOCK wid,dep,0.75"
DEL 1
RETURN


600:!Shelf
LINE_TYPE shline
ADDz 1'-2"
BLOCK wid,dep,0.75"
ADDz 1'-2"
BLOCK wid,dep,0.75"
DEL 2
RETURN


700:!Shelf
LINE_TYPE shline
ADDz 1'-2"
BLOCK wid,dep,0.75"
ADDz 1'-2"
BLOCK wid,dep,0.75"
ADDz 1'-2"
BLOCK wid,dep,0.75"
DEL 3
RETURN


800:!Shelf
LINE_TYPE shline
ADDz 1'-2"
BLOCK wid,dep,0.75"
ADDz 1'-2"
BLOCK wid,dep,0.75"
ADDz 1'-2"
BLOCK wid,dep,0.75"
ADDz 1'-2"
BLOCK wid,dep,0.75"
DEL 4
RETURN
AC10/12 USA 11882156, OS XP 2 GB Ram

Djordje
Advocate
Michele wrote:
Is everyone still using GDL talk or is this supposed to take the place of that too?
Both are equally valid; choose your prefered one.

IMHO GDL Talk is more frequented by the hard coders, while here the company is more generally minded.

Then, again, I might be wrong as usual
Djordje

ArchiCAD since 4.55 ... 1995

David Larrew
Booster
Michele,

Instead of your GOSUB routines try this FOR NEXT loop instead:

!_____________________________

!Shelf
PEN shpen
MATERIAL shmat
LINE_TYPE shline

leadspc=6.0" !start space from bottom of standards
spcng=(shigt-(leadspc*2))/nshelves !shelf spacing per overall height of standards
If spcng<6.0" then spcng=6.0"
If spcng>24.0" then spcng=24.0"

ADDz leadspc
FOR i=1 TO nshelves
ADDz spcng
BLOCK wid,dep,0.75"
NEXT i

DEL i+1
!_____________________________

This is a little cleaner code. FYI - Anytime you need to calculate quantities, lengths, numbers, etc. from the overall dimensions of an object - you should do the coding in the "Master Script".

Hope this gets you on the right track.
David Larrew, AIA, GDLA, GSRC

Architectural Technology Specialist

a r c h i S O L U T I O N S



WIN7-10/ OSX 10.15.7

AC 5.1-25 USA

Didn't find the answer? Start a new discussion

Labels

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!