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
Solved! Go to Solution.
Solved by saikat. Go to 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
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
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.
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());
ok....It works but only with Beams, Columns, Braces and Desks.
work in progress for wall. Declaring a wall it doesnt work
Great. Thanks for letting us know that the query is now resolved.
cheers