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 XML Extension - Reading External File

Anonymous
Not applicable
Hello all,

The AC11 documentation is very difficult to understand when it comes to the XML extension and I have had no luck finding further information on the internet so I hope you can help.

I am trying to script a drawing title block object that opens an external XML file (a spreadsheet created with excel), searches for the current drawing number and returns several fields from that row (drawing title, revision number, etc)

Using the Data/Text I/O function it is fairly simple to return a field from a known row and column of a specific txt file. I would like to have the ability to search for a term in one column and return a value from the same row of another column.

I think my trouble is with the INPUT command. I need help setting the recordID and fieldID correctly:

ch1 = OPEN ("XML", "C:\Book1.xml", "f" )
INPUT (ch1, recordID, fieldID, var1, var2...)
close (ch1)

Any ideas?
1 REPLY 1
Richard Swann
Booster
Yes, the documentation on the XML extension is prosaic and I have not been able to fathom it so far so would be great if anyone can help. Stuff like:
"When we want to walk through the nodes of the tree, first we have to request a new position descriptor from
the extension. Originally a new descriptor points to the root element. The descriptor is in fact a 32 bit identification number whose value has no
interest for the GDL script. The position it refers to can be changed as we move from one node in the tree to another." (GDL reference manual)
Huh??
I find tab delimited text files work fine for most things. On a mac if you have 'Numbers' it will open directly into a spreadsheet ( but not save as text ). In XL these can also be imported.

To answer your question, you can search a column to find an identifier and select another row in that column in tab delimited text files. I have done this for titleblocks myself but don't have the script to hand

Here is another example :
DIM stpan [20] [4] !!! array for data
chst= OPEN ("TEXT", "solar_energy.txt" , " MODE = RO, LIBRARY" )
lincont=1
solinp=INPUT (chst, lincont ,1, val1, val2, val3, val4)
WHILE stlpan>0 DO
stpan[lincont] [1]=val1
stpan [lincont][2]=val2
stpan [lincont] [3]=val3
stpan[lincont] [4]=val4
lincont=lincont+1
solinp=INPUT (chst, lincont ,1, val1, val2, val3, val4)
ENDWHILE
CLOSE chst
!!!______________find the row of the identifier parameter
FOR linconti=1 TO lincont
IF stpan [linconti] [1]= identparam THEN !!!where identparam is your identifier
outcomeval= stpan[linconti] [3] !!! where the value to be read is in column 3 and outcomeval is the value.
ENDIF
NEXT linconti

Hope this helps. It is a bit clumsy because there is a problem inserting texti/o into for next loops directly- they don't work!( or last time I tried in AC9)
Richard Swann

MacOS 11.7 , Intel Imac 4k ArchiCAD 4.5-27 (Solo)