.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Spline geometric extents

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
FRFR1426
447 Views, 2 Replies

Spline geometric extents

Spline in drawing attached returns wrong extents. The magenta polyline match the returned extents.

 

Code to reproduce:

 

[CommandMethod("EXT")]
public void Ext()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;

    PromptEntityResult per = ed.GetEntity("\nSélectionnez une entité: ");
    if (per.Status == PromptStatus.Cancel) return;
    using (Transaction tr = db.TransactionManager.StartTransaction())
    {
        var currentSpace = (BlockTableRecord) tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

        var e = (Entity) tr.GetObject(per.ObjectId, OpenMode.ForRead);
        Extents3d extents = e.GeometricExtents;

        var pl = new Polyline(4) { ColorIndex = 6 };
        
        pl.AddVertexAt(0, new Point2d(extents.MinPoint.X, extents.MinPoint.Y), 0, 0, 0);
        pl.AddVertexAt(1, new Point2d(extents.MaxPoint.X, extents.MinPoint.Y), 0, 0, 0);
        pl.AddVertexAt(2, new Point2d(extents.MaxPoint.X, extents.MaxPoint.Y), 0, 0, 0);
        pl.AddVertexAt(3, new Point2d(extents.MinPoint.X, extents.MaxPoint.Y), 0, 0, 0);
        pl.Closed = true;

        currentSpace.AppendEntity(pl);

        tr.AddNewlyCreatedDBObject(pl, true);
        
        tr.Commit();
    }
}

 

The spline comes from Inventor.

 

 

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
2 REPLIES 2
Message 2 of 3
Alfred.NESWADBA
in reply to: FRFR1426

Hi,

 

first sorry, I can only confirm your result.

I also tried (as that sometimes brings up other results) to use the GetBoundingBox function (ActiveX) and yes, same result.

 

At least I have not found a solution but have some comment's that might help:

 

When you open the drawing, select the spline you see in the property window that the entity has 3 control points and the degree of spline = 2

Change the "Method" from "Control Vertices" and back to "Fit" ... now the degree of spline = 3 and the number of control vertices changed to 4

...and more important: now the extents are evaluated correct.

 

Not sure if that helps for your workflow, but I hope so! 😉

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 3
FRFR1426
in reply to: Alfred.NESWADBA

Thanks. My workaround was to use the ToPolyline method and use the GeometricExtents of the resulting polyline.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost