Hi everyone,
I am working on a macro to create a set of long section ppf's for each super alignment in a model. so far so good but I am having issues adding the special chainage files to the ppf's. Very new to macros and this has completely stumped me.
I have used the following to create each special chainage file based on the string names.
File file;
Text file_name, file_type;
file_name = string_name + ".spc";
file_type = "ccs=UNICODE";
File_open(file_name,"w",file_type,file);
The issue is in the below when trying to add the file to the ppf.
Element spc_file;
ppf_param_name = "chainage_selection_grid";
rv = Set_parameter(ppf_lsec,ppf_param_name,spc_file);
The macro compiles fine but when i run it, i get the following error
"Error setting PPF parameter <chainage_selection_grid> with value <A>
perhaps its not registering the ".spc" correctly? How do I go about adding this file with the chain?
Thanks in advance
Long Section plot ppf parameters
-
Alexander Cook
- Posts: 555
- Joined: Thu Feb 01, 2018 10:22 am
- Location: Toowoomba, Qld
Re: Long Section plot ppf parameters
How are you creating the ppf? Are you just manually writing all the parameters to a text file?
The spc files need to be numbered parameters in the format below.
The spc files need to be numbered parameters in the format below.
Code: Select all
chainage_special_1_file "file1.spc"
chainage_special_2_file "file2.spc"
......-
noah smolenaars
- Posts: 3
- Joined: Thu Jan 09, 2025 4:18 pm
Re: Long Section plot ppf parameters
I am creating it as below:
rv = Create_section_long_plot_parameter_file(ppf_lsec);
and then adding the parameters as below:
// ----------------------SPECIAL CHAINAGE FILE
File file;
Text file_name, file_type;
file_name = string_name + ".spc";
file_type = "ccs=UNICODE";
File_open(file_name,"w",file_type,file);
Element spc_file;
ppf_param_name = "chainage_selection_grid";
rv = Set_parameter(ppf_lsec,ppf_param_name,spc_file);
the special chainage file parameter in the ppf is a grid and i am not sure if this is why its not populating correctly with just text? is there something special i need to do to populate a grid parameter?
rv = Create_section_long_plot_parameter_file(ppf_lsec);
and then adding the parameters as below:
// ----------------------SPECIAL CHAINAGE FILE
File file;
Text file_name, file_type;
file_name = string_name + ".spc";
file_type = "ccs=UNICODE";
File_open(file_name,"w",file_type,file);
Element spc_file;
ppf_param_name = "chainage_selection_grid";
rv = Set_parameter(ppf_lsec,ppf_param_name,spc_file);
the special chainage file parameter in the ppf is a grid and i am not sure if this is why its not populating correctly with just text? is there something special i need to do to populate a grid parameter?
-
Alexander Cook
- Posts: 555
- Joined: Thu Feb 01, 2018 10:22 am
- Location: Toowoomba, Qld
Re: Long Section plot ppf parameters
I think this is your issue here.noah smolenaars wrote: ↑Thu Dec 18, 2025 7:53 am
ppf_param_name = "chainage_selection_grid";
rv = Set_parameter(ppf_lsec,ppf_param_name,spc_file);
the special chainage file parameter in the ppf is a grid and i am not sure if this is why its not populating correctly with just text? is there something special i need to do to populate a grid parameter?
If you only have a single spc file, try this instead:
Code: Select all
ppf_param_name = "chainage_special_1_file";
rv = Set_parameter(ppf_lsec,ppf_param_name,spc_file);
If you have more than 1 special chainage file, you need to do a for loop to add the parameters.
Some example code below to show creating your files, then adding the parameters to the ppf
Code: Select all
// Create your array of spc file names
Dynamic_Element strings_to_create_spcs;
Integer num_strings_to_spc;
// Add your required strings to this array
Get_number_of_items(strings_to_create_spcs, num_strings_to_spc)
Dynamic_Text spc_file_names;
for(Integer i =1; i <= num_strings_to_spc; i++)
{
Element string;
Text name;
Get_item(strings_to_create_spcs, i, string)
Get_name(string, name);
// Create your spc file here
Append(name + ".spc", spc_file_names);
}
// Now for the stuff with the ppf, which you could combine in the previous loop depending on your code flow.
Integer num_spc_files;
Get_number_of_items(spc_file_names, num_spc_files);
for(Integer i =1; i <= num_spc_files; i++)
{
Text spc_file;
Get_item(spc_file_names, i, spc_file);
ppf_param_name = "chainage_special_" + To_text(i) + "_file";
rv = Set_parameter(ppf_lsec,ppf_param_name,spc_file);
}
-
Phil Temple-Watts
- Posts: 392
- Joined: Thu Jun 27, 2019 10:49 am
- Location: Hobart
Re: Long Section plot ppf parameters
Do the special chainage files already exist, or are you trying to create them in the macro?
If you have another look through the macro manual you'll see there are multiple Set_parameter calls, each with its own set of parameters (arguments).
The one you actually want is the one that sets the parameter value as a Text type. The one with an Element type would be if you're trying to set the parameter for the string to profile, not to try to fill out the SPC grid.
So you need the name of the parameter, and the name of the file, i.e. "my string.spc", both of which should be of type Text.
Easiest way to find the name of the parameter is to save a long section ppf, then open the .project folder in your working folder, find the .lplotppf.ppf file you just saved, then open it with Notepad++.
I filled in a couple of dummy spc files in the Special chainages files node (in the ppf editor), and then searched for the file names (in Notepad++).
This gave me:
So the parameter name (for the first grid row) will be 'chainage_special_1_file'.
Then you need the file name.
Assuming you only have one SPC file per alignment (and they're consistently named), I would probably do something like:
That looks like it should compile, and work, but my Visual Studio Code isn't set up properly again yet, so I haven't tested it.
Finally, when including code snippets on the forum, if you select them and then click on the </> icon above the text box, it'll format them nicely.
If you have another look through the macro manual you'll see there are multiple Set_parameter calls, each with its own set of parameters (arguments).
The one you actually want is the one that sets the parameter value as a Text type. The one with an Element type would be if you're trying to set the parameter for the string to profile, not to try to fill out the SPC grid.
Code: Select all
Set_parameter(Plot_Parameter_File file,Text parameter_name,Text parameter_value);
Easiest way to find the name of the parameter is to save a long section ppf, then open the .project folder in your working folder, find the .lplotppf.ppf file you just saved, then open it with Notepad++.
I filled in a couple of dummy spc files in the Special chainages files node (in the ppf editor), and then searched for the file names (in Notepad++).
This gave me:
Code: Select all
chainage_special_1_file "SPC1.spc"
chainage_special_2_file "SPC2.spc"
Then you need the file name.
Assuming you only have one SPC file per alignment (and they're consistently named), I would probably do something like:
Code: Select all
Integer Populate_chainage_grid(Plot_Parameter_File &ppf, Element alignment)
{
Text string_name = "";
Get_name(alignment, string_name);
Text spc_file_name = string_name + " SPC.spc";
if (File_exists(spc_file_name) == 0)
{
return 1;
}
return Set_parameter(ppf, "chainage_special_1_file", spc_file_name);
}
Finally, when including code snippets on the forum, if you select them and then click on the </> icon above the text box, it'll format them nicely.
-
noah smolenaars
- Posts: 3
- Joined: Thu Jan 09, 2025 4:18 pm
Re: Long Section plot ppf parameters
Fantastic that has sorted it! thank you both Phil and Alexander!
I was using the ppf parameters that chains use which was the key issue so thanks for pointing out the actual parameter name! this will no doubt solve some future issues i might have too
and thank you both for the ideas on loops and naming the files.
Noted on the code snippet formatting too, I was wondering how that was done
I was using the ppf parameters that chains use which was the key issue so thanks for pointing out the actual parameter name! this will no doubt solve some future issues i might have too
and thank you both for the ideas on loops and naming the files.
Noted on the code snippet formatting too, I was wondering how that was done