Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GetObject() without specify type entity.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
joantopo
585 Views, 5 Replies

GetObject() without specify type entity.

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.

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
5 REPLIES 5
Message 2 of 6
Jeff_M
in reply to: joantopo


@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;

 

 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 6
Jeff_M
in reply to: Jeff_M

Joan, casting the id.GetObject() as the base AutoCAD Entity type worked for me in a quick test.

Jeff_M, also a frequent Swamper
EESignature
Message 4 of 6
joantopo
in reply to: Jeff_M

 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.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 5 of 6
norman.yuan
in reply to: joantopo

Maybe this:

 

[CivilCustomEntity].ObjectId.ObjectClass.DxfName?

Norman Yuan

Drive CAD With Code

EESignature

Message 6 of 6
joantopo
in reply to: norman.yuan

Yes, or this:

if (entRes.GetType() == typeof(Autodesk.Civil.DatabaseServices.Alignment)) 
{
}

 

Thanks.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report