Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
I am trying to set the value of a parameter called DRAWNBY using the value of the environment variable %USERNAME% I have tried adding the following line to both the parametric.psf file and the config.pro file, but in both cases, the parameter had a blank value after starting Creo. I have verified the environment variable by going to the command prompt and typing ECHO %USERNAME% and it returns the current user of the PC.
Are you using a PLM system with Creo?
How are you assigning the parameter DRAWNBY's value to %username%?
Look in your parameters and see if there is an existing one for that shows the username.
Sorry, I forgot to paster the line I used to try and set the value in the parametric.psf and config.pro files.
ENV=DRAWNBY=%USERNAME% where DRAWNB is a custom property associated with the model.
In the psf file you can only define environment parameters, not Creo parameters. In Creo, you can not use environment variables in relations. This would also be tricky, only opening a component on a different computer will already change the component if the environment variable has a different value.
However, it is possible to create a mapkey to automatically set the parameter value to the value of a particular environment variable.
The way I do this kind of thing is:
(1) For new files, I have start parts, start assemblies, start manufacturing assemblies, etc. that have identifying parameters set to my name. Stuff like DesignBy, or other things that apply to the design stage. The DrawnBy type stuff might not be done by me. Someone else might end up doing the drawings, so that is initially set to a "-" or dash.
(2) I have a mapkey that sets the DrawnBy stuff to my name. I use this if I'm the person doing a drawing. I open the pertinent part/assembly file, hit that mapkey, and the values are set.
I don't know of any way to use Environment variables to set Creo parameters. Undoubtably one could use a Toolkit to build a custom add-on that would let you access this stuff. It's a common enough thing to do in general programming. I've used in applications I've written.
No matter what you do, though, you want to have it be something that sets the value and is done. You don't want it to be something that is applied every time a model is regenerated. That will likely cause havoc as the value is set to a different value everytime someone else opens one of the models. They might not even know they are changing things, but the next time someone opens the drawing it will possibly be incorrect, etc.