Read Name of Project

This topic contains 16 replies, has 3 voices, and was last updated by  Péter Baksa 1 month, 3 weeks ago.

  • Author
    Posts
  • #18405

    James Goode
    Participant

    Hello,

    Is it possible to read the name of project to then use it in a string. I don’t want to output it to plan but I’d like to use it to compare with another text.

    Eg if the start of the project name is 00001, I want to check if it matches another source of 00001 or not.

    I’ve tried name_of_plan but it can’t create a text string.

    Is there a way to achieve this?

    Thanks

  • #18406

    Péter Baksa
    Participant

    Hi, REQUEST (“Name_of_plan”, “”, name) should work. What is your exact code?

    Péter Baksa
    Software Engineer, Library Team
    GRAPHISOFT SE

  • #18407

    James Goode
    Participant

    Hello,

    It looks like it gives it a dummy value if entered into a parameter script.

    My script was basically the Name_of_plan request and then custom_parameter = name

    Is there any way to get around it?

    Thanks

  • #18408

    Péter Baksa
    Participant

    It doesn’t work in parameter script. The request page of the manual lists these exceptions.

    There is no way around. Why do you need to store it as parameter, why can’t you work with the current value (2d, 3d, ui scripts)?

    Péter Baksa
    Software Engineer, Library Team
    GRAPHISOFT SE

  • #18409

    James Goode
    Participant

    What I want to achieve involves cutting up the name of the project to get the first 5 numbers of the project name. I have no use for it to be outputted in 2D / 3D. It’s not necessarily needing to store it as a parameter but I do need to be able to use the string (like a parameter). I don’t know if there is a way of doing so?

  • #18410

    Péter Baksa
    Participant

    What are you planning to do with the parameter in which part of the name should be stored? Why can’t you use the request where you would use the parameter?

    Péter Baksa
    Software Engineer, Library Team
    GRAPHISOFT SE

  • #18445

    James Goode
    Participant

    I’d like to be able to get the full project name, eg. 00001-Project1-AC23

    but only use the first 5 characters (00001) to compare against 5 numbers that I call from a text file.

    So I would be able to do something like this:
    if (project_number = text_file_number) then
    match = 1
    else
    match = 0
    endif

    Thanks

  • #18446

    Péter Baksa
    Participant

    If this could be in a 2d, 3d or UI script, you could use request here, and set project_number as a variable, not a parameter.

    Péter Baksa
    Software Engineer, Library Team
    GRAPHISOFT SE

  • #18541

    James Goode
    Participant

    Hello,

    I managed to work around the problem above but I’ve come across the need for this functionality again. Is there any reason as to why we cannot access the requests from the parameter scripts? It would be so incredible useful to be able to – as well as project info. It seems like an unnecessary limitation.

    Thanks

  • #18542

    Péter Baksa
    Participant

    The reason is hotlinks – by design this is the name of the host project, but modules are read-only, they can’t change their contents’ parameters.

    Could you elaborate on the problem to solve? Why do you place the information to compare in the filename and a text file? Maybe other workflows are possible: embedded text file in the project, properties, library globals, model view options, etc…

    Péter Baksa
    Software Engineer, Library Team
    GRAPHISOFT SE

    • #18544

      James Goode
      Participant

      Basically, I wanted to get the name of the model and add it to a string to then complete a file path to search for a text document

      • #18551

        Péter Baksa
        Participant

        Why do you need to access the file in the parameter script?
        What kind of information is stored in the file, and why do you want to change parameters based on that?

        Péter Baksa
        Software Engineer, Library Team
        GRAPHISOFT SE

  • #18543

    Barry Kelly
    Participant
    rrr=REQUEST ("Name_of_plan", "", pname, pfullname, ppath)
    print pfullname
    
    file_numb = STRSUB(pfullname, 1, 5)
    print file_numb

    This works for me in the master script (also 2D & 3D but not parameter script).
    No you can’t save the outcome as a parameter (that would be nice though as we don’t all use modules).
    But you can use the outcome and can compere it to your text file number.

    Barry.

    Versions 6.5 to 22
    Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
    Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit

    • #18552

      James Goode
      Participant

      Yeah, unfortunately this doesn’t work as I needed to use the file name to make up the string for the FULLPATH to actually find the text file

      • #18555

        Barry Kelly
        Participant

        From this you can get the file path and the file name.
        You can then amend either/both to get the file path and name you require (merger the strings back together) to create or open the file you want.

        I do exactly this to save text files with the names I want for quants output in the job folder, or even a sub-folder of that job folder.

        Barry.

        Versions 6.5 to 22
        Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
        Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit

      • #18559

        James Goode
        Participant

        You can’t get the file path name and file path of the open project and then use it to make up the file path and name of a FULLPATH text doc from within the Parameter scripts. The parameter scripts are a crucial part as I need to then use the values from the text document lines to be able to do stuff with that data (parameter calculations etc).

      • #18560

        Péter Baksa
        Participant

        What you want is not exactly possible, but there are workarounds on where to place the file:

        – txt files can be added to the embedded library. It saves a copy of the file in the project, after data update it needs to be re-added.
        – Folders containing txt files can be added as a linked library.

        These are accessible with only a filename (no path), but duplicate filenames aren’t allowed. WHEN the libpart is run, it gets the most recent data from the file (without library reload), and the file gets archived in a pla.

        I do not recommend changing parameters based on an external file:
        Changing the file doesn’t force the parameter script to be run (even a library reload doesn’t guarantee that), user interaction (OK in settings dialog or hotspot edit) is needed.

        If you could solve that the file is only accessed in 2D/3D/UI script, a rebuild&regenerate would read the most recent data from the file.

        Péter Baksa
        Software Engineer, Library Team
        GRAPHISOFT SE

You must be logged in to reply to this topic.