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,
I'm trying to set parameter value of assembly via J-link class.
We are using Wildfire 5.1.
I'm trying to set value of parameter PRO_MP_ALT_AREA under Alternate Mass Properties.
Session session = pfcGlobal.GetProESession ();
Model model = session.GetCurrentModel();
Parameter param = model.GetParam("PRO_MP_ALT_AREA");
double myValue = 1.0;
param.SetValue(pfcModelItem.CreateDoubleParamValue(myValue));
But all I get is XBadGetParamValue Exception.
(not be confused with it’s name, this Exception is thrown from set method too)
It seems that ParamValueType is PARAM_NOT_SET (Unknown in table below) and that causes the problem.
But how can i change it to PARAM_DOUBLE??? I’ve found no set method in API.
What am I doing wrong?
Any help will be appreciated.
Solved! Go to Solution.
Using of Relations did the trick.
stringseq relations = model.GetRelations();int relationRow = relations.getarraysize();
relations.set(relationRow, "PRO_MP_ALT_AREA = 0");
model.SetRelations(relations);
model.RegenerateRelations();
relations.removerange(relationRow, relationRow + 1);
model.SetRelations(relations);
The type of a parameter cannot be changed. You can capture the value of an existing parameter, delete the parameter and create a new parameter of the same name with the type you want.
You will have to repair any places the previous parameter was used.
Alternatively, you can create a new parameter of the desired type with a new name; correct any places the old parameter was used to use the new parameter, then delete the old parameter and rename the new parameter to the name the old parameter had used.
I think your problem is that these parameters are set only by xtop.exe; they may not be accessible by outside software.
Thanks for your reply.
It looks like that "real" type of PRO_MP_ALT_AREA is double. With double i'll be pretty happy. When I enter any value manualy--there is desired type--PARAM_DOUBLE. Manual entering of String or Integer is not allowed or possible.
At this moment (with some value), parameter is accessible even with my class. Standard Set methods are working. But I'd like to make it automatic. I can not prompt user to activate parameter maualy.
Deleting of PRO_MP_ALT_AREA parameter (to be replaced by newly created) is not possible too. Working with main set (not PRO_MP or PRO_MP_ALT) of parameters looks easier.
I'd like to stick with PRO_MP_ALT because these parameters are unique for instances of family. In case of using standard main parameter it will be the same for all instances unless i make it table driven which is terrible idea.
1. So is there really no way how to assign value to Alternate Mass Properties set automatically?
2. Or is there any different way how to set this value? LST file or something? I have start part on my mind but I want to work with and fix legacy parts too...
Thanks for advices.
Using of Relations did the trick.
stringseq relations = model.GetRelations();int relationRow = relations.getarraysize();
relations.set(relationRow, "PRO_MP_ALT_AREA = 0");
model.SetRelations(relations);
model.RegenerateRelations();
relations.removerange(relationRow, relationRow + 1);
model.SetRelations(relations);