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: 

edit/add family parameters

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Lucavox
6068 Views, 7 Replies

edit/add family parameters

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

7 REPLIES 7
Message 2 of 8
saikat
in reply to: Lucavox

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
in reply to: saikat

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

Message 4 of 8
saikat
in reply to: Lucavox

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
Message 5 of 8
Lucavox
in reply to: saikat

 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());
Message 6 of 8
Lucavox
in reply to: Lucavox

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

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

Message 7 of 8
Lucavox
in reply to: Lucavox

ok resolved.

 

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

 

Message 8 of 8
saikat
in reply to: Lucavox

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

 

cheers



Saikat Bhattacharya
Senior Manager - Technology Consulting

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