cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Loop and lines question

Anonymous
Not applicable
Hi,

Sorry for my newbie question but I can't find solution for my case:

I need to draw a line beetween two points given by a loop:
For k=0 TO 2 STEP 1

x= 5 * k
y= 10  * k

NEXT k
So the effect would be two sets of values for X and Y :
x1 = 5
y1= 10

x2= 10
y2= 20

And I want a line beetween x1, y2, x2, y2
line2 5,10,10,20 !!!! or ...
line2 x,y,x,y
How am I supposed to get those x1, y1, x2 and y2 ?
8 REPLIES 8
Barry Kelly
Moderator
I am not sure why exactly you want to do this but what you want is this...

DIM x []
DIM y []

For k=1 TO 2

x= 5 * k 
y= 10 * k 

NEXT k


line2 x[1],y[1],x[2],y[2]

Because your values for x & y are changing and you can't draw your line until you know both values you need to store them somewhere - and one method is in an array as I have done above.

Another way would be to PUT the values into a buffer and then GET them when you need them...
x = 0
y = 0

For k=1 TO 2

x= 5 * k 
y= 10 * k 

PUT x,y

NEXT k


line2 GET(NSP)
Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Anonymous
Not applicable
Hey Barry, thanks !

It works.

Quick question - if I would like to use for several times sets of x,y values can I use the PUT GET buffer system of only the array method ?

For the moment it looks like for me that after using once the value from buffer it is deleted from there...

In other words is it poosible to do this ? :
x = 0 
y = 0 

For k=1 TO 2 

x= 5 * k 
y= 10 * k 

PUT x,y 

NEXT k 

line2 GET(1), GET(1), GET(1), GET(1)  ! ----- First line x1, y1, x2, y2,
line2 0, 0, GET(1), GET(1)  ! ----- Second line 0,0, x1, y1
line2 GET(1), GET(1), 0,0  ! ----- Third line x2, y2, 0, 0
Anonymous
Not applicable
Hy,
GET will give you a value from the buffer removing it,
USE will acces the value but not delete it from the buffer.

In your case the array method is much more efficient because the buffer is a first in first out container and you can't read the second number without reading the first one.
Anonymous
Not applicable
Ilder wrote:
Hy,
In your case the array method is much more efficient because the buffer is a first in first out container and you can't read the second number without reading the first one.
And this the answer to my next question, thanks !
Barry Kelly
Moderator
GET will take the value from the buffer so it can only be used once.
However USE will leave the value in the buffer so it can be used again.

The problem is the buffer values must be used in the order that they are put in there.
So you would have to use some values, then use them again and discard them to use the next values that you need - could get very messy.


This is where the array is much better.
The values are stored in the array and can be used over and over and you can pick and choose easily which values you want to use.


DIM x [] 
DIM y [] 

For k=1 TO 2 

x= 5 * k 
y= 10 * k 

NEXT k 


line2 x[1], y[1], x[2], y[2]  ! ----- First line x1, y1, x2, y2, 
line2 0, 0, x[1], y[1]  ! ----- Second line 0,0, x1, y1 
line2 x[2], y[2], 0,0  ! ----- Third line x2, y2, 0, 0
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Barry Kelly
Moderator
Ilder beat me to it.
I had a blackout just as I was about to post.

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
David Maudlin
Rockstar
Barry wrote:
I had a blackout just as I was about to post.
Electrical or neurological?



David
David Maudlin / Architect
www.davidmaudlin.com
Digital Architecture
AC27 USA • iMac 27" 4.0GHz Quad-core i7 OSX11 | 24 gb ram • MacBook Pro M3 Pro | 36 gb ram OSX14
Barry Kelly
Moderator

Power blackout fortunately.

Self induced blackouts might be on the cards though seeing as I am on my Christmas break now.

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11