Forum Replies Created
-
AuthorPosts
-
Pé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 SEPéter BaksaKeymasterNo, 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 SEPéter BaksaKeymasterYes, 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 SEPéter BaksaKeymasterHello,
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 SEPéter BaksaKeymasterTry adding close ch1, maybe the data will be written only then. I haven’t tried it, just guessing.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEPéter BaksaKeymasterHi,
reading and writing to files from GDL is only good for communication with external programs.
The problem with communication between library parts is that the order in which the scripts run is not deterministic. There is no guarantee that the current parameters will be written to the file before the other libpart will try to read it.
The only way for communication between library parts is to write an Add-on that sets and reads parameters of the library parts based on their subtype.
This is beyond GDL, C++ programming experience is required. You can join the API developer community at https://archicadapi.graphisoft.com/start.Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEPéter BaksaKeymasterThe script is written by code that is prepared to handle SEO operations and keep the correct volume and surface of the model. A simple slab doesn’t have SEO operations on its own, but the GDL script is not optimized.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEPéter BaksaKeymasterHi,
short answer: yes.
But you can’t do it like eg. the slab tool, where the user can draw a polygon. You have to add parameters to control the number of sides, and each vertex’s coordinates. Use editable hotspots on the vertices to let the user change them easily.
Another possibility starting with AC21 is to use a profile parameter: the user can edit the profile in the profile editor as a drawing, and your object will change accordingly.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEPéter BaksaKeymasterHi,
According to this document it should be working, but looks like the inline definition gets written to the attributes only after using it by name in the 2D script, and is not accessible from 3D this way. We will check if this is a bug or some technical limitation.
You can put the definiton in a MASTER_GDL_….gdl file (plain text file). This way the attribute is created when the library is loaded, and you can use it in all libparts by name.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEApril 19, 2018 at 16:22 in reply to: Possible to use data from external text file as parameters? #4012Péter BaksaKeymasterI don’t clearly understand what is your goal, but it sounds complex.
You could try to read all of the file into an intermediate array, than filter the needed strings in one or more separate loops to another array.Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEApril 19, 2018 at 13:05 in reply to: Possible to use data from external text file as parameters? #4010Péter BaksaKeymasterSorry, this is an infinite loop if the file doesn’t contain a line starting with “EF-25”.
useuntil pos = 1 or n = -1
to terminate. INPUT returns -1 when end of file is reached.Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEApril 19, 2018 at 11:00 in reply to: Possible to use data from external text file as parameters? #4008Péter BaksaKeymasterYes, rewrite
sarray[j] = var
toif pos # 1 then sarray[j] = var
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEApril 19, 2018 at 08:01 in reply to: Possible to use data from external text file as parameters? #4004Péter BaksaKeymasterHi,
the example is just a small modification of your code:
DIM sarray[] var = "" filename = "ProjectNotes.txt" ch1 = OPEN ("text", filename, "MODE=RO, LIBRARY") j = 1 sarray[j]="" repeat n = INPUT (ch1, j, 1, var) pos = STRSTR (var, "EF-25") sarray[j] = var j = j + 1 until pos = 1 CLOSE ch1 VALUES "refnote" sarray
I haven’t tested it, I guess it should work 🙂
The easiest way to debug GDL when you don’t know what is happening is to use PRINT commands. Or, you can use BREAKPOINT with the debugger, as explained here.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEApril 18, 2018 at 10:54 in reply to: Possible to use data from external text file as parameters? #4002Péter BaksaKeymasterThis is also a nice solution, you need
until pos = 1
, meaning the string was found at position 1.STRSUB returns the substring from position 1 to pos.
var = prefix
is only true if var is exactly prefix, not longer.Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SEPéter BaksaKeymasterHi,
This will force the for loop to end:
if strsub(var, 1, 5) = "EF_25" then z = x1
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
AuthorPosts