void getJointsWithSelection() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Database db = Application.DocumentManager.MdiActiveDocument.Database; TransactionManager tm = db.TransactionManager; Transaction trans = tm.StartTransaction(); try { PromptEntityOptions entopts = new PromptEntityOptions("Select a wall "); entopts.SetRejectMessage("Must select a wall, please!"); entopts.AddAllowedClass(typeof(Wall), true); PromptEntityResult ent = null; try { ent = ed.GetEntity(entopts); } catch { ed.WriteMessage("You did not select a valid entity"); return; } if (ent.Status == PromptStatus.OK) { ObjectId entId = ent.ObjectId; Wall wall = trans.GetObject(entId, OpenMode.ForRead, false) as Wall; if (wall != null) { Manager mgr = new Manager(db); Graph theGraph = mgr.FindGraph(wall); Matrix3d mat = theGraph.WcsToEcsMatrix.Inverse(); for (int i = 0; i < theGraph.WallJointCount; i++) { Joint joint = theGraph.GetWallJoint(i); Point3d jointloc = new Point3d(joint.Location.X, joint.Location.Y, 0); Point3d jointlocTrans = jointloc.TransformBy(mat); DrawBlip(jointloc.TransformBy(mat), 3, 1, false); ed.WriteMessage("\n Joint at (ECS): " + joint.Location.ToString() + " (WCS): " + jointlocTrans.ToString()); } } else { ed.WriteMessage("\nSomething bad has happened..."); } } trans.Commit(); } catch (System.Exception e) { trans.Abort(); ed.WriteMessage(e.Message); } finally { trans.Dispose(); } }
void getSectionsWithSelection() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Database db = Application.DocumentManager.MdiActiveDocument.Database; TransactionManager tm = db.TransactionManager; Transaction trans = tm.StartTransaction(); try { PromptEntityOptions entopts = new PromptEntityOptions("Select a wall "); entopts.SetRejectMessage("Must select a wall, please!"); entopts.AddAllowedClass(typeof(Wall), true); PromptEntityResult ent = null; try { ent = ed.GetEntity(entopts); } catch { ed.WriteMessage("You did not select a valid entity"); return; } if (ent.Status == PromptStatus.OK) { ObjectId entId = ent.ObjectId; Wall wall = trans.GetObject(entId, OpenMode.ForRead, false) as Wall; Manager mgr = new Manager(db); Graph theGraph = mgr.FindGraph(wall); Matrix3d mat = theGraph.WcsToEcsMatrix.Inverse(); for (int i = 0; i < theGraph.WallJointCount; i++) { Joint joint = theGraph.GetWallJoint(i); ConnectionCollection connections = joint.Connections; foreach (Connection connection in connections) { Section section = connection.Section; int count = section.ComponentSetCount; ed.WriteMessage("\n Section in wall system for wall id: " + section.WallId + "\n component set count = " + count); ed.DrawVector(new Point3d(section.StartPoint.X, section.StartPoint.Y, 0).TransformBy(mat), new Point3d(section.EndPoint.X, section.EndPoint.Y, 0).TransformBy(mat), 4, true); } } } trans.Commit(); } catch (System.Exception e) { trans.Abort(); ed.WriteMessage(e.Message); } finally { trans.Dispose(); } }
void getConnectionsWithSelection() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Database db = Application.DocumentManager.MdiActiveDocument.Database; TransactionManager tm = db.TransactionManager; Transaction trans = tm.StartTransaction(); try { PromptEntityOptions entopts = new PromptEntityOptions("Select a wall "); entopts.SetRejectMessage("Must select a wall, please!"); entopts.AddAllowedClass(typeof(Wall), true); PromptEntityResult ent = null; try { ent = ed.GetEntity(entopts); } catch { ed.WriteMessage("You did not select a valid entity"); return; } if (ent.Status == PromptStatus.OK) { ObjectId entId = ent.ObjectId; Wall wall = trans.GetObject(entId, OpenMode.ForRead, false) as Wall; Manager mgr = new Manager(db); Graph theGraph = mgr.FindGraph(wall); Matrix3d mat = theGraph.WcsToEcsMatrix.Inverse(); for (int i = 0; i < theGraph.WallJointCount; i++) { Joint joint = theGraph.GetWallJoint(i); ConnectionCollection connections = joint.Connections; foreach (Connection connection in connections) { ed.WriteMessage("\nConnection in wall system for wall id: " + connection.Section.WallId.ToString()); ed.WriteMessage("\n Direction from here: " + connection.DirectionFromHere.ToString()); foreach (double elevation in connection.ElevationVariations) { ed.WriteMessage("\n Elevation Variations: " + elevation.ToString()); } ed.WriteMessage("\n Start Elevation: " + connection.StartElevation.ToString()); ed.WriteMessage("\n End Elevation: " + connection.EndElevation.ToString()); ed.WriteMessage("\n Section Starts Here: " + connection.SectionStartsHere.ToString()); } } } trans.Commit(); } catch (System.Exception e) { trans.Abort(); ed.WriteMessage(e.Message); } finally { trans.Dispose(); } }