Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FamilyMangager AddParameter Exception

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
GeomGym
698 Views, 5 Replies

FamilyMangager AddParameter Exception

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

5 REPLIES 5
Message 2 of 6
GeomGym
in reply to: GeomGym

The exception is actually "Illegal Parameter Group"
Message 3 of 6
SGPViewer
in reply to: GeomGym

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

Message 4 of 6
GeomGym
in reply to: SGPViewer

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

Message 5 of 6
gopinath.taget
in reply to: GeomGym

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

Message 6 of 6
gopinath.taget
in reply to: GeomGym

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.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community