Péter Baksa

Forum Replies Created

Viewing 15 posts - 181 through 195 (of 224 total)
  • Author
    Posts
  • in reply to: Write text file to embedded library #4301
    Péter Baksa
    Keymaster

    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

    in reply to: Write text file to embedded library #4299
    Péter Baksa
    Keymaster

    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

    in reply to: Write text file to embedded library #4295
    Péter Baksa
    Keymaster

    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

    in reply to: Write text file to embedded library #4292
    Péter Baksa
    Keymaster

    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 scripts

    channel = OPEN ("TEXT", "data.txt", "SEPARATOR = ' ', MODE = WO, LIBRARY")
    OUTPUT channel, row, column, value
    close channel
    

    Péter Baksa
    Library Platform, Software Engineer
    GRAPHISOFT SE

    in reply to: Writing to a text file #4268
    Péter Baksa
    Keymaster

    Try 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 SE

    in reply to: Writing to a text file #4266
    Péter Baksa
    Keymaster

    Hi,

    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 SE

    in reply to: Trying to understand autoscripted groups #4249
    Péter Baksa
    Keymaster

    The 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 SE

    in reply to: PRISM defined by user #4099
    Péter Baksa
    Keymaster

    Hi,

    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 SE

    Péter Baksa
    Keymaster

    Hi,

    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 SE

    Péter Baksa
    Keymaster

    I 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 SE

    Péter Baksa
    Keymaster

    Sorry, this is an infinite loop if the file doesn’t contain a line starting with “EF-25”.
    use until pos = 1 or n = -1 to terminate. INPUT returns -1 when end of file is reached.

    Péter Baksa
    Library Platform, Software Engineer
    GRAPHISOFT SE

    Péter Baksa
    Keymaster

    Yes, rewritesarray[j] = var to if pos # 1 then sarray[j] = var

    Péter Baksa
    Library Platform, Software Engineer
    GRAPHISOFT SE

    Péter Baksa
    Keymaster

    Hi,

    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 SE

    Péter Baksa
    Keymaster

    This 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 SE

    in reply to: Stop adding rows based on what the row text contains #4001
    Péter Baksa
    Keymaster

    Hi,

    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

Viewing 15 posts - 181 through 195 (of 224 total)