I have this to zoom object:
public static void ZoomObject(Autodesk.AutoCAD.DatabaseServices.ObjectId Id) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; // por si queremos preguntar o responder en la línea de comandos Database db = Application.DocumentManager.MdiActiveDocument.Database; // start transaction using (Transaction trans = db.TransactionManager.StartTransaction()) { // get the entity' extends Autodesk.Civil.DatabaseServices.SectionView ent= trans.GetObject(Id,OpenMode.ForRead) as SectionView; Extents3d extends = ent.GeometricExtents; // configure the new current view ZoomToWindow(new Autodesk.AutoCAD.Geometry.Point2d(extends.MinPoint.X, extends.MinPoint.Y), new Autodesk.AutoCAD.Geometry.Point2d(extends.MaxPoint.X, extends.MaxPoint.Y)); trans.Commit(); } }
this method receive one parameter -->ObjectId.
Have I do this for each type of entity (civil 3d object)?
Autodesk.Civil.DatabaseServices.SectionView ent= trans.GetObject(Id,OpenMode.ForRead) as SectionView;
Autodesk.Civil.DatabaseServices.Profile ent= trans.GetObject(Id,OpenMode.ForRead) as Profile;
I was trying to do this:
Autodesk.Civil.DatabaseServices.Entity ent= trans.GetObject(Id,OpenMode.ForRead) Extents3d extends = ent.GeometricExtents;
But this last doesn´t work.
I don´t like that I have to check every object to determine which type is Id parameter.
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
Solved by Jeff_M. Go to Solution.
@joantopo wrote:
I was trying to do this:
Autodesk.Civil.DatabaseServices.Entity ent= trans.GetObject(Id,OpenMode.ForRead) Extents3d extends = ent.GeometricExtents;But this last doesn´t work.
Have you tried the base AutoCAD Entity object?
Autodesk.AutoCAD.DatabaseServices.Entity ent= trans.GetObject(Id,OpenMode.ForRead) Extents3d extends = ent.GeometricExtents;
Hi again.
Is there a fast way to find out what civil object is from an objectId?
For example, if we ask to the user by prompt (command line):
"select in the drawing an alignment or profile view".
How can we know what object was selected by the user?
Thanks.
Yes, or this:
if (entRes.GetType() == typeof(Autodesk.Civil.DatabaseServices.Alignment)) { }
Thanks.