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.
SOLVED!

Writing parameter values to a text file.

JGoode
Advocate
Hello,

I was wondering how to go about writing parameter values to an external text file for another object to read. Is this possible? and if so, would it work if the values in the object worked?

Thanks
ArchiCAD 23

Windows 10
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
JGoode
Advocate
Hello,

I've got the text reading and writing correctly...
How do I make it go to a new line?

I currently have this in my output but it doesn't seem to write to 2 separate rows
dstr = ""
ch = OPEN ("DateTime", "", "%d/%m/%Y, %X")
n = INPUT (ch, "", "", dstr)
close ch
zzxzx = str(symb_pos_x*1000, 3, 2)
zzxzxz = str(symbol_pos_x*1000, 3, 2)
text2 0, 0, dstr + " " + zzxzx

name =""
nomplan = request("Name_of_plan", "", name)

chOUT=OPEN ("TEXT", "filelog.TXT", "MODE=WO")
	OUTPUT chOUT, 1, 1, zzxzx
	OUTPUT chOUT, 2, 1, zzxzxz
close chOUT
ArchiCAD 23

Windows 10

View solution in original post

11 REPLIES 11
Barry Kelly
Moderator
It is possible with the text and data input/output commands.
However it is not live.
You amend object A and it will write to the text file.
But then you have to re-build and re-generate to get object B to read the text file (or just open object B's settings dialogue).

Maybe look into using Model View Options global variables.
That way you can make a setting in the MVO and all objects that use that value will instantly respond.
For example the door and window level of detail (2D & 3D) uses MVO values in this way.

You can also add an option to your objects to allow them to use the MVO settings or not, so you can keep them independent if you want.

Barry
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
JGoode
Advocate
when you say you amend object A, do you mean in the GDL editor or in the settings?

What I'm trying to achieve is to export numerical values of a position from object A and then have object B read that rather than set a setting on / off so using MVO's don't really help.
ArchiCAD 23

Windows 10
Barry Kelly
Moderator
JGoode wrote:
when you say you amend object A, do you mean in the GDL editor or in the settings?
I mean when you amend the actual object in the model (not the GDL).
Any changes you make to object A will force the text file to be written to straight away.
But object B will not read it automatically.

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
JGoode
Advocate
This is definitely an option for what I want. Do you have any idea about how to use the OPEN, INPUT, OUTPUT etc... I have read about it in the Reference Guide but it's not very clear and doesn't provide as much information as I'd like.

Thanks very much
ArchiCAD 23

Windows 10
JGoode
Advocate
Hello,

I had a go but I can't seem to make it work. Here is my code...
ch1 = OPEN ("TEXT", "TEST123", "separator = ' ', MODE = WO")

string = "12345"
OUTPUT ch1, 1, 0, string 
what am I doing wrong?
ArchiCAD 23

Windows 10
Barry Kelly
Moderator
This should be working fine.
However it will be writing the file to the Archicad Data folder.
This should be (by default) in your user profile - but it may be a hidden file.
For me it is at ...
C:\Users\your_user_name_here\AppData\Local\Graphisoft\ArchiCAD-64 Data Folder\ARCHICAD-64 21.0.0 AUS R1

AppData may be a hidden folder so you will have to show it in the file and folder options of Windows Explorer.

It is possible to set the file path.
It can be a fixed path or you can request the path by ....
rrr=REQUEST ("Name_of_plan", "", pname, pfullname, ppath)

!print pname
!print pfullname
!print ppath

file_name_start = STRSTR(ppath, pfullname)

fold_path = STRSUB(ppath, 1, file_name_start-1)


fspec=fold_path+"TEST123.txt"

!print fspec

ch1 = open ("TEXT", fspec, "separator = '\n', mode = wo")
output ch1, 1, 0, "12345"
close ch1
But I am getting an error that says non-existent channel.
The folder path seems correct when I check it but for some reason it is not working.
It has been a long time since I have done this so maybe something has changed (I was testing in version 21) or I am just missing something obvious.

I will see if I can figure it out later.

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Barry Kelly
Moderator
I haven't had a really good look but I see in the reference manual ...
Using "DIALOG", "FULLPATH" or "LIBRARY" is supposed to give some control of the file location.
DIALOG works but you will get fed up with browsing all the time.
FULLPATH is not working for me.

But I actually have used DATA in/out rather than TEXT in the past.
Slightly different in that you can read and write individual entries in a file.
The objects I have doing this are still working fine, so maybe it is just a problem with the TEXT in/out.

Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Solution
JGoode
Advocate
Hello,

I've got the text reading and writing correctly...
How do I make it go to a new line?

I currently have this in my output but it doesn't seem to write to 2 separate rows
dstr = ""
ch = OPEN ("DateTime", "", "%d/%m/%Y, %X")
n = INPUT (ch, "", "", dstr)
close ch
zzxzx = str(symb_pos_x*1000, 3, 2)
zzxzxz = str(symbol_pos_x*1000, 3, 2)
text2 0, 0, dstr + " " + zzxzx

name =""
nomplan = request("Name_of_plan", "", name)

chOUT=OPEN ("TEXT", "filelog.TXT", "MODE=WO")
	OUTPUT chOUT, 1, 1, zzxzx
	OUTPUT chOUT, 2, 1, zzxzxz
close chOUT
ArchiCAD 23

Windows 10
Palawat
Advocate
Just tested your script and it works. Try opening the log file with WordPad or Notepad++, not just Notepad, to see that it actually creates a new line.
Archicad 26, Windows 10, Corei7 3.4 GHz, 16 GB Ram.
https://www.indigofigs.com
https://www.facebook.com/indigofigs
Learn and get certified!