AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Member
DeadOrc
Posts: 3
Registered: ‎01-19-2010
Message 1 of 1 (158 Views)

How to center the feature?

158 Views, 0 Replies
04-28-2011 06:43 AM

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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.