I get an "Illegal Parameter Exception" when I run this code. Any idea why? PG_TEXT as a paramter works fine if I set that instead of PG_LENGTH.
FamilyParameter fpp = famDoc.FamilyManager.get_Parameter(pname);
if (fpp == null)
{
if (lm != null)
fpp = famDoc.FamilyManager.AddParameter(pname, BuiltInParameterGroup.PG_LENGTH, ParameterType.Length, false);
else if (r != null)
fpp = famDoc.FamilyManager.AddParameter(pname, BuiltInParameterGroup.PG_TEXT, ParameterType.Number, false);
Solved! Go to Solution.
Solved by gopinath.taget. Go to Solution.
Hello,
I believe the problem is what the exception says. You are trying to add a parameter to a group that it does not belong to. I do not see it in AddParameter method's documentation but FamilyManager.ReplaceParameter method has this explanation:
Autodesk.Revit.Exceptions.ArgumentException: Thrown when the input argument-"familyParameter"-is invalid, or the input argument-"parameterGroup"-is illegal, or the input name string contains illegal characters, or duplicated with existing parameter name.
I will need more information on the if we need to determine why a specific parameter cannot be added to this group. What kind of parameter is it?
Thanks
Gopinath
Hi,
If you open the attached family document, then run the code you see the exception. If you could please explain how to get this family parameter created in the dimension group instead of text it would be appreciated.
Thanks,
Jon
Hello,
I have enquired with my engineering colleagues on this. I will get back to you as soon as I hear something.
Thanks for your patience.
Best Regards
Gopinath
Hello,
Sincere apologies for the delay in getting back to you. I have a couple of responses from engineering team:
You can validate parameter group by this method which was newly introduced in Revit 2015:
FamilyManager. IsUserAssignableParameterGroup(BuiltInParameterGroup parameterGroup);
And:
When I changed BuiltInParameterGroup.PG_LENGTH to BuiltInParameterGroup.PG_STRUCTURAL (category that exist in family) I was successful to create new parameter
My advice is to try to add parameter to group that already exist for family.
Hope this helps.
Best Regards
Gopinath
Can't find what you're looking for? Ask the community or share your knowledge.