We have added a pulldown using the external file for adding restricted parameters. I want to be able to add this to existing CREO files with jlink. Does anyone know if this is possible? I have tried just adding the parameter like you would a regular one and that does not seem to work. On Creo 3.0 M110. Thanks.
Solved! Go to Solution.
Yes, this is possible. My res. parameters file (RPF):
restricted_param.lst
RES_PARAMS = {
{
Name = model_color
Type = string
Default = 'blue'
Enum = { 'blue', 'red', 'green' }
}
}
The code to add parameter to model (part, or assembly):
Solid model = (Solid) session.GetCurrentModel();
ParamValue pv = pfcModelItem.CreateStringParamValue("blue");
model.CreateParam("model_color", pv);
If your RPF values will change often you can read this file before creating parameter and then create parameter with correct values.
I don't know this for a fact but I suspect it is not possible. Only the toolkit API can be used to modify the access level for a parameter. You can read more about this in the following PTC article (CS39947).
Mike
Mike,
I am not trying to modify it. I am trying to create the paramter. If it is not there I can go in an manually create it but I have not been able to create It via JLink.
Yes, this is possible. My res. parameters file (RPF):
restricted_param.lst
RES_PARAMS = {
{
Name = model_color
Type = string
Default = 'blue'
Enum = { 'blue', 'red', 'green' }
}
}
The code to add parameter to model (part, or assembly):
Solid model = (Solid) session.GetCurrentModel();
ParamValue pv = pfcModelItem.CreateStringParamValue("blue");
model.CreateParam("model_color", pv);
If your RPF values will change often you can read this file before creating parameter and then create parameter with correct values.
Thanks Skvarka, that worked perfectly. I think I might not have been setting the string value correctly so it was failing. Regardless, your answer works. Thanks again.