Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi all,
I would like to be able to select / assign a material when I start a new part without having to go through file>properties>materials....
In short, I want to modify the models properties without having to go through the menus.
I tried adding a string parameter, but it did not work. So I must not be doing something right.
Thanks
Solved! Go to Solution.
Hello!
The easiest way would be to add both materials to your template and set the parameter PTC_MATERIAL_NAME to the desired value.
But it should be easier to create two templates, one for steel parts and another for aluminium parts. Isn't it ?
Hi Eileen,
I think you are mixing up the string parameter for the material in a part (or your template) with the actual material properties, means: the assigned .mat file. They are not necessarily linked, unless you use a relation to write the properties of your mat file into your string parameter.
I'd recommend a mapkey that jumps directly to the material section of the part properties and preselect your pro_material_dir. Couldn't live without it.
HTH
Andreas
Hi Andreas,
I was trying to apply a .mat file to the template and make it a choice between steel and aluminum. I though i could do it with a string parameter.
I just don't know how to write the relation part.
In the mean time I can always try the map key thing.
Thanks a lot
Hello!
The easiest way would be to add both materials to your template and set the parameter PTC_MATERIAL_NAME to the desired value.
But it should be easier to create two templates, one for steel parts and another for aluminium parts. Isn't it ?
Hi,
that's cool, this solution actually works. I had doubts if switching the material via the drop box would change the density but it does.
I haven't had a look at this parameter until now, 'cause we don't use it. We have a material parameter of our own because the file name of the mat file is not enough on a drawing. But I think I'll have a closer look what else I'v been missing there so far.
@Eileen: The relation you would need is something like
%mat%=material_param("BEND_TABLE") where %mat% stands for your material parameter, but the solution above is way smarter.
Hi Sylvain,
that is exactly what i wanted to do.
Thanks a lot for that solution.
And you are right, it would be easier to have two seperate templates, but i prefer to have only one and change the material easily in case the user did not choose the right template to start with.