Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; IList<Reference> references = uidoc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Face); IList<IList<IList<XYZ>>> all = new List<IList<IList<XYZ>>>(); foreach (Reference reference in references) { Face face = doc.GetElement(reference).GetGeometryObjectFromReference(reference) as Face; IList<IList<XYZ>> loopVertices = new List<IList<XYZ>>(); PlanarFace planarFace = face as PlanarFace; if(!planarFace.FaceNormal.IsAlmostEqualTo(XYZ.BasisZ)) { EdgeArrayArray edgeArrayArray = planarFace.EdgeLoops; foreach (EdgeArray ea in edgeArrayArray) { IList<XYZ> loops = new List<XYZ>(); foreach (Edge e in ea) { Curve c = e.AsCurve(); loops.Add(c.GetEndPoint(0)); } loopVertices.Add(loops); } } all.Add(loopVertices); } CreateTessellatedShape(doc, all, ElementId.InvalidElementId); return Result.Succeeded; }
public void CreateTessellatedShape(Document doc, IList<IList<IList<XYZ>>> all, ElementId materialId) { TessellatedShapeBuilder builder = new TessellatedShapeBuilder(); builder.OpenConnectedFaceSet(true); foreach (IList<IList<XYZ>> loopVertices in all) { TessellatedFace tessellatedFace = new TessellatedFace(loopVertices, materialId); if (builder.DoesFaceHaveEnoughLoopsAndVertices(tessellatedFace)) { builder.AddFace(tessellatedFace); } } builder.CloseConnectedFaceSet(); builder.Target = TessellatedShapeBuilderTarget.AnyGeometry; builder.Fallback = TessellatedShapeBuilderFallback.Mesh; builder.Build(); TessellatedShapeBuilderResult result = builder.GetBuildResult(); using (Transaction t = new Transaction(doc, "Create tessellated direct shape")) { t.Start(); DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_Floors)); ds.ApplicationId = "Application id"; ds.ApplicationDataId = "Geometry object id"; ds.SetShape(result.GetGeometricalObjects()); t.Commit(); } }
Hello friends,
I want to create one direct shape from selected floor faces
The bottom face of floor is ok but side faces are not created properly
How can I solve this
Thanks in advance..
Solved! Go to Solution.