public void setPlineBuldges(Autodesk.AutoCAD.Interop.Common.AcadLWPolyline pline, List <VTex> vertices) { for (int i = 0; i < vertices.Count; ++i) { pline.SetBulge(i, vertices[i].getBuldge()); } }
public Autodesk.AutoCAD.Interop.Common.AcadLWPolyline drawPline(List <MWCadNameSpace.VTex> Vertices) { double[] coords = new double[Vertices.Count * 2]; for (int i = 0; i < Vertices.Count; ++i) { coords.SetValue(Vertices[i].getPnt3d().getX(), 2 * i); coords.SetValue(Vertices[i].getPnt3d().getY(), 2 * i + 1); } Autodesk.AutoCAD.Interop.Common.AcadLWPolyline pLineObj = null; try { pLineObj = cadApp.ActiveDocument.ModelSpace.AddLightWeightPolyline(coords); pLineObj.color = Autodesk.AutoCAD.Interop.Common.ACAD_COLOR.acRed; } catch { MessageBox.Show("Error drawing polyline. Please try again."); } return(pLineObj); }
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); }
private void button2_Click_1(object sender, EventArgs e) { if (cadStuff != null && cadStuff.cadConnection() == true) { List <MWCadNameSpace.VTex> vertices = cadStuff.getPlineEnityCoords(); if (vertices.Count > 0) { MWCadNameSpace.SurveyBoundary boundary = new MWCadNameSpace.SurveyBoundary(vertices); MWCadNameSpace.pnt3d pickedPnt = cadStuff.getPickPoint(vertices[0].getPnt3d()); boundary.translateSegmentList(pickedPnt); //cadStuff.drawPline(boundary.getTranslatedCorrectedSegmentVertices()); Autodesk.AutoCAD.Interop.Common.AcadLWPolyline aPline = cadStuff.drawPline(boundary.getTranslatedCorrectedSegmentVertices()); cadStuff.setPlineBuldges(aPline, boundary.getTranslatedCorrectedSegmentVertices()); Grid1.Rows.Clear(); populateGrid1(boundary); Grid2.Rows.Clear(); populateGrid2(boundary); Grid3.Rows.Clear(); populateGrid3(boundary); } } else { MessageBox.Show("Connection Error"); } }
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); }
private void button5_Click(object sender, EventArgs e) { MWCadNameSpace.pnt3d origin = new MWCadNameSpace.pnt3d(); MWCadNameSpace.pnt3d pickPnt = null; try { pickPnt = cadStuff.getPickPoint(origin); } catch { MessageBox.Show("Cad Connection Error"); return; } List <MWCadNameSpace.VTex> vertices = new List <MWCadNameSpace.VTex>(); MWCadNameSpace.pnt3d lastEntPnt = null; for (int i = 0; i < deconstructedCallList.Count; ++i) { MWCadNameSpace.pnt3d startPnt = pickPnt; if (i > 0) { startPnt = lastEntPnt; } MWCadNameSpace.Segment aSegment = deconstructedCallList[i].extractAsSegment(startPnt); if (deconstructedCallList[i].getCurveLeftRight().Value == "Right" || deconstructedCallList[i].getCurveLeftRight().Value == "Left") { aSegment.setBuldgeFromRadius(deconstructedCallList[i].getRadius(), deconstructedCallList[i].getCurveLeftRight()); } vertices.Add(aSegment.getGStart()); lastEntPnt = aSegment.getGEnd().getPnt3d(); if (i == deconstructedCallList.Count - 1) { vertices.Add(aSegment.getGEnd()); } } Autodesk.AutoCAD.Interop.Common.AcadLWPolyline thePline = cadStuff.drawPline(vertices); cadStuff.setPlineBuldges(thePline, vertices); }