public double[] getPlineCoords() { //works but needs honing// Autodesk.AutoCAD.Interop.AcadSelectionSets sSets = cadApp.ActiveDocument.SelectionSets; Autodesk.AutoCAD.Interop.AcadSelectionSet sSet = null; try { sSet = sSets.Add("set1"); } catch { int set1Index = 0; for (int i = 0; i < sSets.Count; ++i) { if (sSets.Item(i).Name == "set1") { set1Index = i; } } sSet = sSets.Item(set1Index); sSet.Clear(); } cadApp.Visible = true; sSet.SelectOnScreen(); Autodesk.AutoCAD.Interop.Common.AcadLWPolyline pline = null; for (int i = 0; i < sSet.Count; ++i) { //Console.WriteLine Autodesk.AutoCAD.Interop.Common.AcadEntity obj = sSet.Item(i) as Autodesk.AutoCAD.Interop.Common.AcadEntity; try { pline = cadApp.ActiveDocument.HandleToObject(obj.Handle); double[] test = pline.Coordinates as double[]; Console.WriteLine("Coord 3 " + test[3]); Console.WriteLine("The buldge 0 is " + pline.GetBulge(0)); Console.WriteLine("The buldge 1 is " + pline.GetBulge(1)); Console.WriteLine("The buldge 2 is " + pline.GetBulge(2)); Console.WriteLine("The buldge 3 is " + pline.GetBulge(3)); } catch { Console.WriteLine("entity type error"); } } return(pline.Coordinates); }
public List <VTex> getPlineEnityCoords() { List <VTex> returnVertices = new List <VTex>(); Object out1 = new object(); object out2 = new object(); try { cadApp.ActiveDocument.Utility.GetEntity(out out1, out out2, "Select polyline:"); if (out1 == null) { MessageBox.Show("Nothing Selected!"); } Autodesk.AutoCAD.Interop.Common.AcadLWPolyline pline = out1 as Autodesk.AutoCAD.Interop.Common.AcadLWPolyline; double[] coords = pline.Coordinates as double[]; for (int i = 0; i < (coords.Length + 1) / 2; ++i) { pnt3d pnt = new pnt3d(coords[2 * i], coords[2 * i + 1], 0); VTex v = new VTex(pnt, pline.GetBulge(i)); returnVertices.Add(v); } } catch { MessageBox.Show("Error Selecting Entity!"); } return(returnVertices); }