BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Gdl and read file

Anonymous
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
Graphisoft Alumni
Hi,

I still don't get what task you want to accomplish. Without you telling us we won't be able to give you actual help.

I rearranged your code a bit which fixed the lines and maybe the vertical columns a bit. Since I don't understand the goal, I cannot tell if it got better functionally but it definitely got better at readability.

One important fix was to separate the two usage of variable i. GDL is not case sensitive!

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

n = input (ch1, 1, 1,dummy, xOffset,yOffset,height,zRotAng,var5,var6) 
i = 1 

while n > 2 do 
	sum = xOffset+yOffset+height+zRotAng+var5+var6 

	IF sum=6 THEN 
		i = i+1
		n = input (ch1, i, 1, dummy, nRows)
		FOR j=1 TO nRows
			i = i+1
			n = input (ch1, i, 1, dummy,offset,height)
			ADDX offset/1000
			ROTZ -90
			CYLIND height,0.006
			DEL 2
		NEXT j
	ELSE
		ADDX xOffset/1000
		ADDY yOffset/1000
		if zRotAng <> 0 then
			ROTZ zRotAng
		else
			if yOffset<>var6 then
				ROTZ 90
			else
				rotz 0
			endif
		endif
		ROTY 90 
		CYLIND height/1000,0.006
		DEL 4
		LIN_ xOffset/1000,yOffset/1000,0, var5/1000,var6/1000, 0
	ENDIF 
	i = i+1 
	n = input (ch1, i, 1, dummy,xOffset,yOffset,height,zRotAng,var5,var6) 
endwhile

close ch1
One more advice: you should separate the two kinds of data into two data files. You don't have to go the tricky way to mark the border between them.

I'm getting curious about what we're scripting here:)

Regards,
Zsolt
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Anonymous
Not applicable
I keep writing it farther, but there were problems with a step in 200. How it to correct?

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

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

n = input (ch1, 1, 1,dummy, var1,var2,var3,var4,var5,var6) 
hight = var1
step1 = var2

FOR j1=1 TO step1
ADDZ -200
i = 1 

while n > 2 do 

sum=var1+var2+var3+var4+var5+var6
IF sum=6 THEN 

i = i+1  
n = input (ch1, i, 1, dummy,var7)

FOR j=1 TO var7
i = i+1  
n = input (ch1, i, 1, dummy,var8,var9)
ADDX var9/1000
ROTZ -90 
ROTY 90
CYLIND var8,0.006
DEL 3

NEXT j

ELSE 

      
      ADDX var1/1000 
      ADDY var2/1000 
      if var4 <> 0 then 
         ROTZ var4
      else 
         if var2<>var6 then 
            ROTZ 90 
         else 
            rotz 0 
         endif 
      endif 
      ROTY 90 
      CYLIND var3/1000,0.006 
      
DEL 4 

LINE2 var1/1000,var2/1000,var5/1000,var6/1000

ENDIF
  
i = i+1 
   n = input (ch1, i, 1, dummy,var1,var2,var3,var4,var5,var6) 

endwhile 
NEXT j1
close ch1 
text file:
K1170.00K5K6K1K1K1
K62.00K-30.00K5757.13K0.00K5819.13K-30.00
K267.00K-130.00K5493.25K0.00K5760.25K-130.00
K472.00K-230.00K5229.36K0.00K5701.36K-230.00
K932.00K-454.00K4638.25K0.00K5570.25K-454.00
K1137.00K-554.00K4374.36K0.00K5511.36K-554.00
K1341.00K-654.00K4111.27K0.00K5452.27K-654.00
K1K1K1K1K1K1
K8
K0.68K1403.00
K0.68K1903.00
K0.68K2403.00
K0.68K2903.00
K0.68K3935.00
K0.68K4435.00
K0.68K4935.00
K0.68K5435.00

After the start of script I think it will be clear for what it ^_^
ztaskai
Graphisoft Alumni
Graphisoft Alumni
Your for loop doesn't do anything since the inner while loop processes the whole file.

I still don't get what you're doing...

Regs,
Zsolt
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Anonymous
Not applicable
ztaskai wrote:
Your for loop doesn't do anything since the inner while loop processes the whole file.

I still don't get what you're doing...

Regs,
Zsolt
A figure appears in the loop (while endwhile). I want to draw that figure with displacement on the axis Z

It will be script of lay-out of armature for foundation
Anonymous
Not applicable
Thank you all! I succeeded to correct a script.When I'll finish with script , I'll show the result!
Learn and get certified!