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.

Gdl and read file

Not applicable
Here TXT file filling:

K30.00K62.00K5757.13
K130.00K267.00K5493.25
K230.00K472.00K5229.36
K454.00K932.00K4638.25
K554.00K1137.00K4374.36
K654.00K1341.00K4111.27

And my script:

!--> file names added
f1= "ARMDATA.txt"

!--> LIBRARY keyword added
ch1 = open ("TEXT", f1, "mode = ro,LIBRARY" )

!--> script continues as before

1:
n = input (ch1, "K", 1, var1,var2,var3)
if n <> -1 then

ADDX var1/1000
ADDY var2/1000
ROTX 90
CYLIND 12,var3/1000
ROTX 270
IF VAR1/1000<0 then ADDX VAR1/1000
IF VAR1/1000>0 then ADDX -VAR1/1000
IF VAR2/1000<0 then ADDY VAR2/1000
IF VAR2/1000>0 then ADDY -VAR2/1000
IF VAR3/1000<0 then ADDX VAR3/1000
IF VAR3/1000>0 then ADDX -VAR3/1000

goto 1
else
goto 2
endif
2:
close ch1

But he does not want to build my figure.

24 REPLIES 24
ztaskai
Graphisoft Alumni
Hi,

Your script has two fundamental problems.
- The 'K' separator should be passed to the 'OPEN' command.
- The 'INPUT' command need a proper row number to read.

I created the following equivalent script but seeing the result I doubt that this is what you aim for.
!--> file names added 
f1= "ARMDATA.txt" 

ch1 = open ("TEXT", f1, "separator = 'K'; mode = ro,LIBRARY" ) 

n = input (ch1, 1, 1, var1,var2,var3)
i = 1

while n > 2 do
	ADDX var1/1000 
	ADDY var2/1000 
	ROTX 90 
	CYLIND 12, var3/1000
	ROTX 270
	add -abs(var1/1000)-abs(var3/1000), -abs(var2/1000), 0
	i = i+1
	n = input (ch1, i, 1, var1,var2,var3)
endwhile

close ch1 
HTH,
Zsolt
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Hi,

Similar problem.

Text file read write>

Is there any way (but using random no. generator) to get the "open" dialog box (always) when some switch is trigered?

And is there any way to create the file on saving via dialog box? (in database addon - it is possible but not in text addon) - the workaround is to create the new text file inside the save dialog (Win) - I do not know reliable workaround for Mac.

Best Regards,
Piotr
Not applicable
ztaskai wrote:
Hi,

Your script has two fundamental problems.
- The 'K' separator should be passed to the 'OPEN' command.
- The 'INPUT' command need a proper row number to read.

I created the following equivalent script but seeing the result I doubt that this is what you aim for.
!--> file names added 
f1= "ARMDATA.txt" 

ch1 = open ("TEXT", f1, "separator = 'K'; mode = ro,LIBRARY" ) 

n = input (ch1, 1, 1, var1,var2,var3)
i = 1

while n > 2 do
	ADDX var1/1000 
	ADDY var2/1000 
	ROTX 90 
	CYLIND 12, var3/1000
	ROTX 270
	add -abs(var1/1000)-abs(var3/1000), -abs(var2/1000), 0
	i = i+1
	n = input (ch1, i, 1, var1,var2,var3)
endwhile

close ch1 
HTH,
Zsolt
That not so works well, as I thought.
I did a verification script, but a condition malfunctions....

!--> file names added 
f1= "ARMDATA.txt" 

ch1 = open ("TEXT", f1, "separator = 'K'; mode = ro,LIBRARY" ) 

n = input (ch1, 1, 1, var1,var2,var3) 
 
 IF var1=30.00 THEN CYLIND 10,0.006
 IF var2=62.00 THEN CYLIND 10,0.006
 IF var3=5757.13 THEN CYLIND 10,0.006

close ch1 

ztaskai
Graphisoft Alumni
Alexonus wrote:
That not so works well, as I thought.
I did a verification script, but a condition malfunctions....

!--> file names added 
f1= "ARMDATA.txt" 

ch1 = open ("TEXT", f1, "separator = 'K'; mode = ro,LIBRARY" ) 

n = input (ch1, 1, 1, var1,var2,var3) 
 
 IF var1=30.00 THEN CYLIND 10,0.006
 IF var2=62.00 THEN CYLIND 10,0.006
 IF var3=5757.13 THEN CYLIND 10,0.006

close ch1 

Well, since you defined K as a separator and you begin your data lines with a K, the first value read is an empty string which is converted to 0.

You have 2 options: (1) drop the first K from the beginning of your lines in the data file, (2) read the starting 0s into a dummy variable like this: n = input (ch1, 1, 1, dummy,var1,var2,var3).

I still don't think this is the end result you'd like to get you may have got closer to it.

Regards,
Zsolt
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Not applicable
Is there a simple function for returning to the beginning of coordinate system?
Not applicable
Del top ?
Not applicable
flat system of co-ordinates of x=any number y=any number, add x... y.... then needed return in x=0 y=0 .Something simpler than "abs"
Not applicable
How to set the thickness of lines?

LINE2 x1, y1, x2, y2
David Maudlin
Rockstar
Alexonus wrote:
How to set the thickness of lines?
LINE2 x1, y1, x2, y2
Alexonus:

Use the PEN statement, this will set the pen by number, the thickness will depend on the thickness of that pen number set in the Pen Set, see the GDL Reference Guide for more information.

You should add a Signature to your Profile (click the Profile button near the top of this page) with your ArchiCAD version and operating system (see mine for an example) for more accurate help in this forum.

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