Home › Forums › Problems and solutions in GDL › Informations from the environment › Read Name of Project
Tagged: name of project
- This topic has 16 replies, 3 voices, and was last updated 5 years, 1 month ago by
Péter Baksa.
-
AuthorPosts
-
-
November 20, 2019 at 13:33 #18405
James Goode
ParticipantHello,
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
-
November 20, 2019 at 14:18 #18406
Péter Baksa
KeymasterHi, REQUEST (“Name_of_plan”, “”, name) should work. What is your exact code?
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
November 20, 2019 at 14:22 #18407
James Goode
ParticipantHello,
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
-
November 20, 2019 at 14:46 #18408
Péter Baksa
KeymasterIt 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
Library Platform, Software Engineer
GRAPHISOFT SE -
November 20, 2019 at 15:16 #18409
James Goode
ParticipantWhat 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?
-
November 20, 2019 at 15:52 #18410
Péter Baksa
KeymasterWhat 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
Library Platform, Software Engineer
GRAPHISOFT SE -
November 20, 2019 at 16:54 #18445
James Goode
ParticipantI’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
endifThanks
-
November 20, 2019 at 17:09 #18446
Péter Baksa
KeymasterIf 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
Library Platform, Software Engineer
GRAPHISOFT SE -
February 5, 2020 at 15:35 #18541
James Goode
ParticipantHello,
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
-
February 5, 2020 at 19:12 #18542
Péter Baksa
KeymasterThe 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
Library Platform, Software Engineer
GRAPHISOFT SE-
February 6, 2020 at 11:28 #18544
James Goode
ParticipantBasically, 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
-
February 12, 2020 at 08:25 #18551
Péter Baksa
KeymasterWhy 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
Library Platform, Software Engineer
GRAPHISOFT SE
-
-
-
February 6, 2020 at 02:33 #18543
Barry Kelly
Participantrrr=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-
February 12, 2020 at 11:17 #18552
James Goode
ParticipantYeah, 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
-
February 13, 2020 at 02:48 #18555
Barry Kelly
ParticipantFrom 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 -
February 13, 2020 at 13:14 #18559
James Goode
ParticipantYou 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).
-
February 13, 2020 at 15:29 #18560
Péter Baksa
KeymasterWhat 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®enerate would read the most recent data from the file.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE
-
-
-
-
AuthorPosts
- The forum ‘Informations from the environment’ is closed to new topics and replies.