Community
Hi,
I was jus browsing forums, found this post unanswered,
Any one who comes to this forum via Google search should find it helpful
public static void TraverseTorusesInBrep() { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; // Ask the user to select a solid PromptEntityOptions peo = new PromptEntityOptions("Select a 3D solid"); peo.SetRejectMessage("\nA 3D solid must be selected."); peo.AddAllowedClass(typeof(Solid3d), true); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) return; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { BlockTable bt = (BlockTable)tr.GetObject( db.BlockTableId, OpenMode.ForRead, false ); BlockTableRecord btr = (BlockTableRecord)tr.GetObject( bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false ); Solid3d sol = tr.GetObject( per.ObjectId, OpenMode.ForRead ) as Solid3d; // Check the solid for torus faces int torusCounter = 1; using (Brep brep = new Brep(sol)) { foreach (Complex cmp in brep.Complexes) { foreach (Shell shl in cmp.Shells) { foreach (BrFace fce in shl.Faces) { Autodesk.AutoCAD.Geometry.Surface surf = fce.Surface; ExternalBoundedSurface ebSurf = surf as ExternalBoundedSurface; if (ebSurf != null && ebSurf.IsTorus) { Torus torus = ebSurf.BaseSurface as Torus; if (torus != null) { double[] uAngles = torus.GetAnglesInU(); ed.WriteMessage("\n Torus number " + torusCounter + ":"); ed.WriteMessage("\n\tAngle min:" + uAngles[0]); ed.WriteMessage("\n\tAngle max:" + uAngles[1]); torusCounter++; } } } } } } } }