cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

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

ssuttle
10-Marble

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

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.

ACCEPTED SOLUTION

Accepted Solutions
sjuraj
15-Moonstone
(To:ssuttle)

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.



View solution in original post

4 REPLIES 4

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

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.

sjuraj
15-Moonstone
(To:ssuttle)

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.



ssuttle
10-Marble
(To:sjuraj)

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.

Announcements


Top Tags