Message 1 of 4
Set Elevation of NewFamilyInstance Hosted Family
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've read other forum posts that discuss the troubles with NewFamilyInstance(Reference, XYZ, XYZ, FamilySymbol)
I've been able to place a family instance, but am unable to set the element at the proper elevation. I'm able to set an already placed element's elevation parameter like this:
ElementId tmpID = new ElementId(5901554); Element tmpE = document.GetElement(tmpID);
Parameter paramtmp_height = tmpE.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM);
double tmpD = 4.9321;
paramtmp_height.Set(tmpD);
When I place the hosted element and try to set the elevation parameter, the code breaks. Any ideas on a workaround?
// NewFamilyInstance params XYZ p1 = null; Util.GetFamilyInstanceLocation(out p1, familyInstance.Key); XYZ p2 = new XYZ(p1.X, p1.Y, p1.Z); Reference r = familyInstance.Key.HostFace; ElementId linkDocElementID = new ElementId(1152842); Element linkedDocElement = document.GetElement(linkDocElementID); RevitLinkInstance rvtlink = linkedDocElement as RevitLinkInstance; r = r.CreateLinkReference(rvtlink); // create instance var instance = creation_doc.NewFamilyInstance(r, p2, new XYZ(0, 0, 0), pSelection.FamilySymbolObject); // get main model parameters to update ElementId placed_id = instance.Id; Element placed = document.GetElement(placed_id); // modify placed instance elevation Parameter paramMain_height = placed.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM); double tmp = 4.3; paramMain_height.Set(tmp); // CODE BREAKS HERE :-(