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.
Solved! Go to Solution.
Solved by FRFR1426. Go to Solution.
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 -
Thanks. My workaround was to use the ToPolyline method and use the GeometricExtents of the resulting polyline.