- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I have a problem that I can't seem to find a solution for. I am working with several Revit 2025 documents that have been split up by discipline. I have a mechanical model linked into a structural model. The mechanical model has face-based louvers that are hosted on the structural model's walls. In the structural model, we have to place another face-based family that cuts the opening for the louvers. I would like to automate the placing of the wall opening families.
My current code will prompt the user to select the louver from the linked mechanical model and then the face of the wall that will host the wall opening. Using parameters from the louver family I create a custom JHWallOpening object with all the parameters I need (and probably some I don't lol). I then pass the properties from the JHWallOpening to create a new instance of the wall opening family. I then try to adjust the height and width.
I currently have some half working code. I say half working because for some louver sizes it works, and for others it does not. I am pulling the height and width instance parameters from the louver and using that to set the height and width of the wall opening's instance parameters. It works for most of the sizes. However, it doesn't seem to work for 4'-0" or 2'-0" (and possibly others, I'm not sure). Whenever I pass these values through the two methods mentioned in the post's title, the wall opening doesn't set the parameters at all and keeps the default height and width.
I've tried passing in string, int (4 or 2), and double (4.0 or 2.0) hardcoded values and it doesn't work. I have tried passing in the value from Parameter.AsValueString with no luck. My code is below.
public static void JHWallOpening(Document doc, JHWallOpening wallOpening, Reference faceReference)
{
FamilySymbol opening = GetFamilySymbol(doc, "JH-WALL OPENING-RECTANULAR_R23", "Square");
Wall hostWall = doc.GetElement(faceReference) as Wall;
Face face = hostWall.GetGeometryObjectFromReference(faceReference) as Face;
BoundingBoxUV boundingBoxUV = face.GetBoundingBox();
UV center = (boundingBoxUV.Max + boundingBoxUV.Min) / 2;
XYZ normal = face.ComputeNormal(center);
XYZ origin = new XYZ(wallOpening.OriginX, wallOpening.OriginY, wallOpening.OriginZ);
XYZ direction = normal.CrossProduct(XYZ.BasisZ);
FamilyInstance instance = doc.Create.NewFamilyInstance(faceReference, origin, direction, opening);
Parameter height = instance.LookupParameter("Height");
Parameter width = instance.LookupParameter("Width");
Parameter thickness = instance.LookupParameter("Thickness");
height.SetValueString(wallOpening.Height);
width.SetValueString(wallOpening.Width);
thickness.SetValueString(wallOpening.Thickness);
}
public JHWallOpening(FamilyInstance family)
{
double Height = family.LookupParameter("Height").AsDouble();
LocationPoint? location = family.Location as LocationPoint;
this.OriginX = location.Point.X;
this.OriginY = location.Point.Y;
this.OriginZ = location.Point.Z - (Height / 2);
this.HostElementId = family.Host.UniqueId;
this.Height = family.LookupParameter("Height").AsValueString();
this.Width = family.LookupParameter("Width").AsValueString();
this.Thickness = family.LookupParameter("Wall Thickness").AsValueString();
this.DirectionX = family.FacingOrientation.X;
this.DirectionY = family.FacingOrientation.Y;
this.DirectionZ = family.FacingOrientation.Z;
this.LinkedElementId = Convert.ToInt32(family.HostFace.LinkedElementId.Value);
this.HostingFaceId = Convert.ToInt32(family.HostFace.ElementId.Value);
}
I'm at my wits end with this. Anyone have any ideas?
Thanks
Solved! Go to Solution.