
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have migrating tom ARX code into .NET from a plugin I'm still not familiar, which convert drawings to SVG. This function gets the polyline centroid and is using some ideas from the link https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-NET/files/GUI...
Once in a while, especially when I'm trying to convert all layers I see this eInvalidInput exception. (An unhandled exception of type 'Autodesk.AutoCAD.Runtime.Exception' occurred in AcdbMgd.dll)
Not sure why this my be happening.
FYI I'm using this plugin with Autocad 2013 and .NET 4.5.2
Any help will be much appreciated.
public static SPointF GetPolyCentroid(this Polyline pline)
{
DBObjectCollection plineCollection = new DBObjectCollection();
DBObjectCollection regionCollection = new DBObjectCollection();
plineCollection.Add(pline);
regionCollection = Region.CreateFromCurves(plineCollection);<----Here the exception occurs
Region region = regionCollection[0] as Region;
Point3d centroid;
using (region)
{
//TODO
//https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-NET/files/GUI...
using (Solid3d solid = new Solid3d())
{
solid.Extrude(region, 2.0, 0.0);
Point3d solidCentroid = solid.MassProperties.Centroid;
centroid = solidCentroid.TransformBy(Matrix3d.Displacement(region.Normal.Negate()));
}
}
if (centroid != null)
return new SPointF(centroid.X, centroid.Y);
else return null;
}
Solved! Go to Solution.