Home › Forums › Problems and solutions in GDL › GDL add-ons › Write text file to embedded library
- This topic has 21 replies, 2 voices, and was last updated 5 years, 5 months ago by James Goode.
-
AuthorPosts
-
-
October 15, 2018 at 13:17 #4291James GoodeParticipant
Hello,
is it possible to write a text file to the embedded library?
Thanks
-
October 16, 2018 at 08:09 #4292Péter BaksaKeymaster
Hello,
yes it is possible, with limitations:
– new files can’t be created
– writing is only possible after version 17
– after version 18 writing is only possible from the UI, Parameter or Property scriptschannel = OPEN ("TEXT", "data.txt", "SEPARATOR = ' ', MODE = WO, LIBRARY") OUTPUT channel, row, column, value close channel
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
October 16, 2018 at 10:45 #4293James GoodeParticipant
For the object I’m creating, I want to be able to output the symb_pos_x & y of that object. Can that be sent to the embedded library?
-
October 16, 2018 at 11:03 #4294James GoodeParticipant
I also want to then read that value in a different file
-
October 16, 2018 at 11:25 #4295Péter BaksaKeymaster
Yes, it can. You have to add the “data.txt” (or other filename that you are using) to the embedded library first.
Another limitation is that in teamwork the user needs to reserve the file to be able to write to it.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
October 16, 2018 at 11:27 #4296James GoodeParticipant
I can’t seem to get my object to write the symb_pos_x and symb_pos_y to the file at all. My other object can definitely read the file though.
this is my code for OUTPUT
chOUT=OPEN ("TEXT", "SurveyPoint.txt", "separator =' ', MODE=WO, LIBRARY") OUTPUT chOUT, 1, 1, symb_pos_x OUTPUT chOUT, 2, 1, symb_pos_y OUTPUT chOUT, 3, 1, symb_pos_z close chOUT
-
October 16, 2018 at 11:58 #4297James GoodeParticipant
I’ve got it reading and writing correctly but I get error reports saying Cannot modify the file in embedded library in 2D script type, Nonexistent channel and Open error while operating on the file
-
October 16, 2018 at 13:06 #4298James GoodeParticipant
are you able to write to a library from within a pla?
-
October 16, 2018 at 13:38 #4299Péter BaksaKeymaster
No, in 2D / 3D script you can’t write. Only UI, Parameter or Property scripts.
.pla should work.Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
October 16, 2018 at 15:29 #4300James GoodeParticipant
Is it possible for me to output the symb_pos_x and y without the output being in the 2D script?
-
October 16, 2018 at 17:41 #4301Péter BaksaKeymaster
Previously I tested your idea with print commands, all worked nice, but now I see that the values don’t get written to the data file.
The problem is that even if the parameter script is run when you move the object, or open the settings, it runs in a sandboxed mode, and the changes won’t be applied unless any parameter changes.
If you change some hidden parameter, eg. increment a counter, it will work – interestingly, toggling a boolean isn’t enough, maybe because the param script runs even number of times.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE-
November 12, 2018 at 14:54 #4324Péter BaksaKeymaster
With further inspection I’ve found that this is not an usable solution:
the parameter script could be run not just for the placed object, but as a mockup-object of the settings dialog. This can overwrite data very easily, eg. changing the library part of the object tool, selecting another object on the floor plan, viewing favorites, or changing to a different tool.Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE
-
-
November 7, 2018 at 15:06 #4315James GoodeParticipant
Hello,
I have got this working perfectly apart from the fact that I receive an error when placing my object that writes the file.
It still works, but the error is stopping us from progressing with it. -
November 7, 2018 at 16:03 #4316Péter BaksaKeymaster
Hi, what is the error message?
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
November 7, 2018 at 16:05 #4317James GoodeParticipant
There are several. This issue is that it definitely works.
Nonexistent channel at line 68 in the 2D script of file Survey Point Output.gsm. Nonexistent channel at line 69 in the 2D script of file Survey Point Output.gsm. Nonexistent channel at line 70 in the 2D script of file Survey Point Output.gsm. Nonexistent channel at line 71 in the 2D script of file Survey Point Output.gsm. Cannot modify the file (filelog.TXT) in embedded library in 2D script type. Open error while operating on file 'filelog.TXT'. Nonexistent channel at line 68 in the 2D script of file Survey Point Output.gsm. Nonexistent channel at line 69 in the 2D script of file Survey Point Output.gsm. Nonexistent channel at line 70 in the 2D script of file Survey Point Output.gsm. Nonexistent channel at line 71 in the 2D script of file Survey Point Output.gsm. Cannot modify the file (filelog.TXT) in embedded library in 2D script type. Open error while operating on file 'filelog.TXT'. Cannot modify the file (filelog.TXT) in embedded library in 2D script type. Open error while operating on file 'filelog.TXT'. Cannot modify the file (filelog.TXT) in embedded library in 2D script type. Open error while operating on file 'filelog.TXT'. Cannot modify the file (filelog.TXT) in embedded library in 2D script type. Open error while operating on file 'filelog.TXT'. Cannot modify the file (filelog.TXT) in embedded library in 2D script type. Open error while operating on file 'filelog.TXT'. Cannot modify the file (filelog.TXT) in embedded library in 2D script type. Open error while operating on file 'filelog.TXT'.
-
November 8, 2018 at 08:58 #4318Péter BaksaKeymaster
Did you add “filelog.txt” to the embedded library?
New files cannot be created in the embedded library, you can only modify existing ones.Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
November 8, 2018 at 10:59 #4319James GoodeParticipant
Yes I have
The error only pops up if I select either the writing or reading gdl object. -
November 8, 2018 at 11:09 #4320James GoodeParticipant
I’ve also tried to get the file to write and read from a loaded library that isn’t the embedded but it still seems to try to write/read to the embedded library and throws up an error until I move it and then ctrl+shift+alt+R then it begins to work with both the reading object and the writing object. Here is the writing / reading code that I have in my objects;
Writing
chOUT=OPEN ("TEXT", "filelog.TXT", "MODE=WO, LIBRARY") OUTPUT chOUT, 1, 1, symb_pos_x OUTPUT chOUT, 2, 1, symb_pos_y OUTPUT chOUT, 3, 1, symb_pos_z close chOUT
Reading
chIN=OPEN ("TEXT", "filelog.TXT", "MODE=RO, LIBRARY") n = input (chIN,1, 1, zxzx) n1 = input (chIN,2, 1, zxzxz) n2 = input (chIN,3, 1, zxzxzx) close chIN
-
November 8, 2018 at 16:49 #4321Péter BaksaKeymaster
Sorry, I don’t know what is the problem, your examples work fine for me.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE-
November 8, 2018 at 17:24 #4322James GoodeParticipant
Is there any way I would be able to send you my files for you to take a look at?
Thanks
-
November 8, 2018 at 17:47 #4323James GoodeParticipant
or do you have an example file that uses my examples that I could take a look at?
Thanks
-
-
-
November 14, 2018 at 15:07 #4333James GoodeParticipant
Problem solved! As discussed, the issue was that I had the output in both the Parameter script and the 2D script. It was solved by removing the code from the 2D and keeping it in the parameter script.
-
-
AuthorPosts
- The forum ‘GDL add-ons’ is closed to new topics and replies.