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

How to center the feature?

0 REPLIES 0
Reply
Message 1 of 1
DeadOrc
350 Views, 0 Replies

How to center the feature?

Hi!

 

How I can find the center point of some feature in coordinate system context?

I need to highlight and center some feature.

For this I use the code:

            
using (Transaction t = _db.TransactionManager.StartTransaction())
{
    Entity ent = t.GetObject(obj, OpenMode.ForRead) as Entity; //obj - is ObjectId
    if (highlight)
    {
        ent.Highlight();
        using (ViewTableRecord acView = _doc.Editor.GetCurrentView())
        {
            double x = (ent.GeometricExtents.MaxPoint.X + ent.GeometricExtents.MinPoint.X) / 2;
            double y = (ent.GeometricExtents.MaxPoint.Y + ent.GeometricExtents.MinPoint.Y) / 2;
            acView.CenterPoint = new Autodesk.AutoCAD.Geometry.Point2d(x, y);
            _doc.Editor.SetCurrentView(acView);
        }
    }
    else
        ent.Unhighlight();
    t.Commit();
}

But it throws me in a completely different place. What am I doing wrong?

I use AutoCAD Map3d 2010.

Thanks in advance.

Tags (1)
0 REPLIES 0

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

Post to forums  

Autodesk Design & Make Report

”Boost