edit/add family parameters

edit/add family parameters

Lucavox
Contributor Contributor
6,713 Views
7 Replies
Message 1 of 8

edit/add family parameters

Lucavox
Contributor
Contributor

Hi at all,

I'm a student and i'm new to revit API.

 

I tried to modify elements instance parameters in a project document and it works, but can i modify a type parameter in the project document without entering the family editor?

 

thanks

0 Likes
Accepted solutions (1)
6,714 Views
7 Replies
Replies (7)
Message 2 of 8

saikat
Autodesk
Autodesk
Accepted solution

Hi

 

You should be able to set the value of the family instance's type (Symbol) parameter without having to get into Family Editor mode. Following minimal code snippet shows how to:

 

      using (Transaction trans = newTransaction(doc, "url"))

      {

        trans.Start();

 

        foreach (Element ele in uiApp.ActiveUIDocument.Selection.Elements)

        {

          FamilyInstance famInst = ele asFamilyInstance;

          famInst.Symbol.get_Parameter("URL").Set("www.autodesk.com");

        }

 

        trans.Commit();

      }

 

Hope this helps

 



Saikat Bhattacharya
Senior Manager - Technology Consulting
Message 3 of 8

Lucavox
Contributor
Contributor

i know this method but if i want to modify family type parameters? I tried to modify a family parameter in a project document but it doesn't work. is it possible? thank

0 Likes
Message 4 of 8

saikat
Autodesk
Autodesk

I think you mean 'modifying family parameter' and not 'type' parameter. A family instance's symbol (or Type) parameter can be modified as mentioned in my previous post.

 

To modify parameter of the family itself, you have to use the EditFamily and then access the parameters you wish you modify.

FamilyInstance -> FamilySymbol -> Family -> EditFamily.



Saikat Bhattacharya
Senior Manager - Technology Consulting
0 Likes
Message 5 of 8

Lucavox
Contributor
Contributor
 Selection sel = uidoc.Selection;
using (Transaction trans = new Transaction(document, "read parameter")) 
{
	trans.Start();


	foreach (Element ele in sel.Elements)
	{
		FamilyInstance faminst = ele as FamilyInstance;

		TaskDialog.Show("Element information", faminst.Symbol.get_Parameter("parameter").AsString());
		
	}
	trans.commit();
}

 This is the code. And this is the error: "Object reference not set to an instance of an object"

I open revit i select a wall and ask for Width but i recieved this error. I also tried with: 

What is wrong?

 

faminst.Symbol.Family.get_Parameter("parameter").AsString());
0 Likes
Message 6 of 8

Lucavox
Contributor
Contributor

ok....It works but only with Beams, Columns, Braces and Desks.

work in progress for wall. Declaring a wall it doesnt work 

0 Likes
Message 7 of 8

Lucavox
Contributor
Contributor

ok resolved.

 

for wall the code is the same but i must insert wall in place of familyinst...thankyou 🙂

 

0 Likes
Message 8 of 8

saikat
Autodesk
Autodesk

Great. Thanks for letting us know that the query is now resolved.

 

cheers



Saikat Bhattacharya
Senior Manager - Technology Consulting
0 Likes