Hello, I'm trying to insert a face-hosted family that contains a void extrusion inside a generic specialty equipment family. The scenario is the following:
- In the "parent" family there is a rectangular extrusion placed with Z = 100 mm and height = 40mm; the extrusion is created programmatically
- I've a rfa with a simple void cylinder. This rfa is a Generic model family and I've set "Cut with voids" to true
- I want to insert an instance of this void family inside the parent family in order to pierce the extrusion.
The code I'm using is the following:
Options opt = _commandData.Application.Application.Create.NewGeometryOptions(); opt.ComputeReferences = true; var geo = shelf.get_Geometry(opt);//shelf is the extrusion //location = 0,-800,100 //width = 1000 //depth = 800 //height = 140 //all measures are mm PlanarFace pf = null; foreach (GeometryObject obj in geo) { Solid solid = obj as Solid; if (null != solid) { foreach (Face face in solid.Faces) { pf = face as PlanarFace; if (null != pf) { XYZ normal = pf.Normal.Normalize(); if (0.0 < normal.Z && normal.X < 1 && normal.Y < 1) { break; } } } } } if (pf != null) { var location = new XYZ(50D.ToRevitMeasure(), -100D.ToRevitMeasure(), 140D.ToRevitMeasure()); var referenceDirection = XYZ.BasisX; FamilySymbol symbol = null; RevitBaseUtilities.DoSomethingInsideTransaction(() => familyDocument.LoadFamilySymbol(holeFileName, Path.GetFileNameWithoutExtension(holeFileName), new FamilyLoadingDontOverwriteOption(), out symbol), familyDocument); FamilyInstance inst; RevitBaseUtilities.DoSomethingInsideTransaction(() => inst = familyDocument.FamilyCreate.NewFamilyInstance(pf, location, referenceDirection , symbol), familyDocument); familyDocument.SaveAs(resultFileName); familyDocument.Close(false);
The problem is that the cylinder is always placed in Z=0, attached you can find the hole family and the result I get.
Thank you!
Hello,
As the host face's Z coordinates is 0, the void family instance is based on the host face. I think that's why the Z coordinates is ignored.
Mmm..I think that the Z of the host face is not 0 but 140 mm..
Did you see the 0 in the attached file result.rfa (in the original post)? Where should I look for?
Thank you
Tobia