Skip to main content
June 6, 2017
Solved

Is it possible to add a parameter with jlink that uses an External File for Restricted Parameters?

  • June 6, 2017
  • 2 replies
  • 3054 views

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.

Best answer by sjuraj

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.



2 replies

MikePhillips
12-Amethyst
June 6, 2017

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).

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS39947&art_lang=en&posno=1&q=toolkit%20parameter%20access&Prod…

Mike

June 6, 2017

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.

sjuraj15-MoonstoneAnswer
15-Moonstone
June 7, 2017

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.



June 7, 2017

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.