private double method_0(ngeometry.VectorGeometry.Vector3d vector3d_0, ngeometry.VectorGeometry.Vector3d vector3d_1) { double num = ngeometry.VectorGeometry.Vector3d.Angle(vector3d_0, vector3d_1); ngeometry.VectorGeometry.Vector3d b = ngeometry.VectorGeometry.Vector3d.Bisector(vector3d_0, vector3d_1); double num2 = ngeometry.VectorGeometry.Vector3d.Angle(vector3d_0, b); double num3 = ngeometry.VectorGeometry.Vector3d.OrientedAngle(vector3d_0, vector3d_1, ngeometry.VectorGeometry.Vector3d.Cross(vector3d_0, vector3d_1)); if (num3 > 3.1415926535897931) { num3 = 6.2831853071795862 - num3; } if (num > num2) { if (Math.Abs(num3 - num) > 0.001) { throw new System.Exception(); } return(num); } else { if (Math.Abs(num3 - num2) > 0.001) { throw new System.Exception(); } return(num2); } }
public static ngeometry.VectorGeometry.Ellipse ToCeometricEllipse(Autodesk.AutoCAD.DatabaseServices.Ellipse dbe) { ngeometry.VectorGeometry.Point center = new ngeometry.VectorGeometry.Point(dbe.Center.X, dbe.Center.Y, dbe.Center.Z); ngeometry.VectorGeometry.Vector3d semimajorAxis = new ngeometry.VectorGeometry.Vector3d(dbe.MajorAxis.X, dbe.MajorAxis.Y, dbe.MajorAxis.Z); ngeometry.VectorGeometry.Vector3d semiminorAxis = new ngeometry.VectorGeometry.Vector3d(dbe.MinorAxis.X, dbe.MinorAxis.Y, dbe.MinorAxis.Z); return(new ngeometry.VectorGeometry.Ellipse(center, semimajorAxis, semiminorAxis)); }
public static PointSet SubdivideLine(Autodesk.AutoCAD.DatabaseServices.Line dbl, double d) { PointSet result; try { PointSet pointSet = new PointSet(); ngeometry.VectorGeometry.Point point = new ngeometry.VectorGeometry.Point(dbl.StartPoint.X, dbl.StartPoint.Y, dbl.StartPoint.Z); ngeometry.VectorGeometry.Point point2 = new ngeometry.VectorGeometry.Point(dbl.EndPoint.X, dbl.EndPoint.Y, dbl.EndPoint.Z); double num = point.DistanceTo(point2); int num2 = Math.Max((int)Math.Ceiling(num / d), 1); ngeometry.VectorGeometry.Vector3d vector = point2.method_2() - point.method_2(); for (int i = 0; i <= num2; i++) { double scalar = (double)i / (double)num2; pointSet.Add(new Point(point.method_2() + scalar * vector)); } result = pointSet; } catch (System.Exception ex) { Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Can not subdivide line (handle: " + dbl.Handle.ToString() + ")\n"); result = null; } return(result); }
public static CoordinateSystem GetCeometricUcs() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Autodesk.AutoCAD.Geometry.Matrix3d currentUserCoordinateSystem = editor.CurrentUserCoordinateSystem; Point3d origin = currentUserCoordinateSystem.CoordinateSystem3d.Origin; Autodesk.AutoCAD.Geometry.Vector3d xaxis = currentUserCoordinateSystem.CoordinateSystem3d.Xaxis; Autodesk.AutoCAD.Geometry.Vector3d yaxis = currentUserCoordinateSystem.CoordinateSystem3d.Yaxis; Autodesk.AutoCAD.Geometry.Vector3d zaxis = currentUserCoordinateSystem.CoordinateSystem3d.Zaxis; ngeometry.VectorGeometry.Point originPoint = new ngeometry.VectorGeometry.Point(origin.X, origin.Y, origin.Z); ngeometry.VectorGeometry.Vector3d e = new ngeometry.VectorGeometry.Vector3d(xaxis.X, xaxis.Y, xaxis.Z); ngeometry.VectorGeometry.Vector3d e2 = new ngeometry.VectorGeometry.Vector3d(yaxis.X, yaxis.Y, yaxis.Z); ngeometry.VectorGeometry.Vector3d e3 = new ngeometry.VectorGeometry.Vector3d(zaxis.X, zaxis.Y, zaxis.Z); return(new ngeometry.VectorGeometry.CoordinateSystem(originPoint, e, e2, e3)); }
public void ProjectPointsCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); ObjectId[] objectId_ = CommandLineQuerries.SelectFaces(true); PointProjection.string_0 = CommandLineQuerries.SpecifyRasterBySelectionOrByLayer(PointProjection.string_0); ObjectId[] array = null; if (PointProjection.string_0 == "S") { array = CommandLineQuerries.SelectPoints(true); } else if (PointProjection.string_0 == "L") { PointProjection.string_1 = CommandLineQuerries.SpecifyLayerName(PointProjection.string_1); if (!DBManager.ExistsLayer(PointProjection.string_1)) { throw new ArgumentException("Layer does not exist."); } array = DBManager.GetPointsOnLayer(PointProjection.string_1); if (array == null) { throw new ArgumentException("No points selected."); } editor.WriteMessage(Environment.NewLine + array.Length + " points selected."); } PointProjection.string_4 = CommandLineQuerries.SpecifyProjectionDirection(PointProjection.string_4); ngeometry.VectorGeometry.Vector3d normalVector = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0); string a; if ((a = PointProjection.string_4.ToUpper()) != null) { if (!(a == "X")) { if (!(a == "Y")) { if (!(a == "Z")) { if (!(a == "U")) { if (!(a == "2P")) { goto IL_1E6; } normalVector = CommandLineQuerries.Specify2PDirection().BasisVector[2].Normalize(); } else { normalVector = Conversions.GetUCS().BasisVector[2].Normalize(); } } else { normalVector = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0); } } else { normalVector = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0); } } else { normalVector = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0); } Point point = new Point(0.0, 0.0, 0.0); ngeometry.VectorGeometry.Plane plane = new ngeometry.VectorGeometry.Plane(point, normalVector); CoordinateSystem coordinateSystem_ = new CoordinateSystem(plane); PointProjection.string_3 = CommandLineQuerries.InsertOnLayer_Current_Face_Point(PointProjection.string_3); PointProjection.string_2 = CommandLineQuerries.KeywordYesNo("Delete original points", PointProjection.string_2, false, false); PointProjection.string_5 = CommandLineQuerries.KeepIfMultiple(PointProjection.string_5); this.method_0(array, objectId_, coordinateSystem_); return; } IL_1E6: throw new System.Exception("Invalid option keyword."); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message + "\n"); } }
public List <Point> DevelopPolyline(ObjectId plineID, bool reverse, double startBGL, double endBGL) { Database workingDatabase = HostApplicationServices.WorkingDatabase; PointSet pointSet = new PointSet(); using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { DBObject @object = transaction.GetObject(plineID, (OpenMode)0, true); pointSet = PointGeneration.SubdividePolyline(@object, transaction, 0.0); } if (reverse) { pointSet.Reverse(); } PointSet pointSet2 = new PointSet(); double num = 0.0; double num2 = 0.0; double num3 = 0.0; for (int i = 0; i < pointSet.Count - 1; i++) { double num4 = pointSet[i].DistanceTo(pointSet[i + 1]); double num5 = pointSet[i].DistanceXY(pointSet[i + 1]); if (startBGL >= num && startBGL < num + num4) { ngeometry.VectorGeometry.Vector3d vector3d = new ngeometry.VectorGeometry.Vector3d(pointSet[i + 1] - pointSet[i]); vector3d.Norm = Math.Abs(startBGL - num); pointSet2.Add(pointSet[i] + vector3d.ToPoint()); num3 = num2 + pointSet[i].DistanceXY(pointSet[i] + vector3d.ToPoint()); } if (num > startBGL && num < endBGL) { pointSet2.Add(pointSet[i]); } if (endBGL > num && endBGL <= num + num4) { ngeometry.VectorGeometry.Vector3d vector3d2 = new ngeometry.VectorGeometry.Vector3d(pointSet[i + 1] - pointSet[i]); vector3d2.Norm = Math.Abs(endBGL - num); pointSet2.Add(pointSet[i] + vector3d2.ToPoint()); } num += num4; num2 += num5; } if (endBGL > num) { pointSet2.Add(pointSet[pointSet.Count - 1]); } PointSet pointSet3 = new PointSet(); double num6 = num3; for (int j = 0; j < pointSet2.Count; j++) { pointSet3.Add(new Point(num6, CMD_Development.double_2 * pointSet2[j].Z, 0.0)); if (j == pointSet2.Count - 1) { break; } num6 += pointSet2[j].DistanceXY(pointSet2[j + 1]); } return(pointSet3.ToList()); }
private void method_0(ObjectId[] objectId_0, ProgressMeter progressMeter_0, CoordinateSystem coordinateSystem_0) { Database workingDatabase = HostApplicationServices.WorkingDatabase; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; List <Solid3d> list = new List <Solid3d>(); double epsilon = Convert.ToDouble(CMD_FacesToSolid.string_2); bool flag = true; if (CMD_FacesToSolid.string_0 == "N") { flag = false; } DBManager.SetEpsilon(); List <Triangle> list2 = Conversions.ToCeometricAcDbTriangleList(objectId_0); if (!Conversions.IsWCS(coordinateSystem_0)) { Triangle.TransformCoordinates(list2, CoordinateSystem.Global(), coordinateSystem_0); } list2.Sort(new Triangle.CompareMinX()); int num = 0; double num2 = -1.7976931348623157E+308; double num3 = -1.7976931348623157E+308; double num4 = 1.7976931348623157E+308; double num5 = 1.7976931348623157E+308; for (int i = list2.Count - 1; i >= 0; i--) { if (list2[i].NormalVector.IsOrthogonalTo(new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0))) { list2.RemoveAt(i); num++; } else { double minimumX = list2[i].MinimumX; if (minimumX < num4) { num4 = minimumX; } double maximumX = list2[i].MaximumX; if (maximumX > num2) { num2 = maximumX; } double minimumY = list2[i].MinimumY; if (minimumY < num5) { num5 = minimumY; } double maximumY = list2[i].MaximumY; if (maximumY > num3) { num3 = maximumY; } } } ngeometry.VectorGeometry.Vector3d vector3d = new ngeometry.VectorGeometry.Vector3d(0.5 * (num4 + num2), 0.5 * (num5 + num3), 0.0); double num6 = 0.5 * Math.Max(Math.Abs(num2 - num4), Math.Abs(num3 - num5)); double num7 = Math.Ceiling(100000.0 / num6); for (int j = 0; j < list2.Count; j++) { list2[j] = list2[j].Move(-1.0 * vector3d); } SubDMeshHandler subDMeshHandler = new SubDMeshHandler(list2); subDMeshHandler.BuildDataStructure(false); int k = 2147483647; while (k > 0) { this.messageFilter_0.CheckMessageFilter(); k = subDMeshHandler.HealXY(epsilon); num += k; } editor.WriteMessage("\nDegenerate projections healed: " + num); Autodesk.AutoCAD.Geometry.Matrix3d matrix3d = Autodesk.AutoCAD.Geometry.Matrix3d.Scaling(num7, new Point3d(0.0, 0.0, 0.0)); Autodesk.AutoCAD.Geometry.Matrix3d matrix3d2 = Autodesk.AutoCAD.Geometry.Matrix3d.Scaling(1.0 / num7, new Point3d(0.0, 0.0, 0.0)); Autodesk.AutoCAD.Geometry.Matrix3d matrix3d3 = Autodesk.AutoCAD.Geometry.Matrix3d.Displacement(new Autodesk.AutoCAD.Geometry.Vector3d(vector3d.X, vector3d.Y, 0.0)); progressMeter_0 = new ProgressMeter(); progressMeter_0.SetLimit(objectId_0.Length); progressMeter_0.Start("Extruding objects"); int num8 = 0; int num9 = 0; for (int l = 0; l < subDMeshHandler.FaceVertexIndex1.Count; l++) { try { progressMeter_0.MeterProgress(); this.messageFilter_0.CheckMessageFilter((long)l, 1000); } catch (System.Exception ex) { for (int m = 0; m < list.Count; m++) { list[m].Dispose(); } progressMeter_0.Stop(); throw; } try { Face face = new Face(new Point3d(subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex1[l]].X, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex1[l]].Y, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex1[l]].Z), new Point3d(subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex2[l]].X, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex2[l]].Y, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex2[l]].Z), new Point3d(subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex3[l]].X, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex3[l]].Y, subDMeshHandler.Vertices[subDMeshHandler.FaceVertexIndex3[l]].Z), false, false, false, false); double z = face.GetVertexAt(0).Z; double z2 = face.GetVertexAt(1).Z; double z3 = face.GetVertexAt(2).Z; short num10; if (CMD_FacesToSolid.double_0 < 0.0) { if (z <= z2 && z <= z3) { num10 = 0; } else if (z2 <= z && z2 <= z3) { num10 = 1; } else { num10 = 2; } } else if (z >= z2 && z >= z3) { num10 = 0; } else if (z2 >= z && z2 >= z3) { num10 = 1; } else { num10 = 2; } Point3d vertexAt = face.GetVertexAt(num10); Point3d point3d = new Point3d(vertexAt.X, vertexAt.Y, vertexAt.Z + CMD_FacesToSolid.double_0); //point3d..ctor(vertexAt.X, vertexAt.Y, vertexAt.Z + CMD_FacesToSolid.double_0); Autodesk.AutoCAD.DatabaseServices.Line line = new Autodesk.AutoCAD.DatabaseServices.Line(vertexAt, point3d); Region region = this.method_2(subDMeshHandler, l); if (region == null) { num8++; } else { region.TransformBy(matrix3d); line.TransformBy(matrix3d); try { Solid3d solid3d = new Solid3d(); solid3d.ExtrudeAlongPath(region, line, 0.0); solid3d.SetPropertiesFrom(face); list.Add(solid3d); } catch (System.Exception ex) { num9++; } line.Dispose(); region.Dispose(); } } catch (System.Exception ex) { } } editor.WriteMessage("\nNumber of failed projections: " + num8.ToString()); editor.WriteMessage("\nNumber of failed extrusions : " + num8.ToString()); progressMeter_0.Stop(); if (flag && list.Count > 1) { progressMeter_0 = new ProgressMeter(); int limit = (int)Math.Ceiling(Math.Log((double)list.Count) / Math.Log(2.0)); progressMeter_0.SetLimit(limit); progressMeter_0.Start("Building solid"); this.method_1(ref list, ref progressMeter_0); } using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1); for (int n = 0; n < list.Count; n++) { list[n].TransformBy(matrix3d2); list[n].TransformBy(matrix3d3); CoordinateTransformator coordinateTransformator = new CoordinateTransformator(coordinateSystem_0, CoordinateSystem.Global()); if (!coordinateTransformator.bool_0) { list[n].TransformBy(coordinateTransformator.ToAcadTransformation()); } blockTableRecord.AppendEntity(list[n]); transaction.AddNewlyCreatedDBObject(list[n], true); } transaction.Commit(); } progressMeter_0.Stop(); }
public void method_0() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //TCPlugin.LicenseManager.CheckValid("FULL"); ObjectId[] objectId_ = CommandLineQuerries.SelectPoints(false); Class1.string_0 = CommandLineQuerries.SpecifyProjectionDirection(Class1.string_0); ngeometry.VectorGeometry.Vector3d vector3d = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0); string a; if ((a = Class1.string_0.ToUpper()) != null) { if (!(a == "X")) { if (!(a == "Y")) { if (!(a == "Z")) { if (!(a == "U")) { if (!(a == "2P")) { goto IL_150; } vector3d = CommandLineQuerries.Specify2PDirection().BasisVector[2]; vector3d = vector3d.Normalize(); } else { vector3d = Conversions.GetUCS().BasisVector[2].Normalize(); } } else { vector3d = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0); } } else { vector3d = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0); } } else { vector3d = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0); } Point point = new Point(0.0, 0.0, 0.0); ngeometry.VectorGeometry.Plane plane = new ngeometry.VectorGeometry.Plane(point, vector3d); CoordinateSystem coordinateSystem_ = new CoordinateSystem(plane); Class1.smethod_0(objectId_, coordinateSystem_); return; } IL_150: throw new System.Exception("Invalid option keyword."); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
public void MinAreaEnclosingRectnagleCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); ObjectId[] idArray = CommandLineQuerries.SelectPoints(false); CMD_MinAreaEnclosingRectangle.string_0 = CommandLineQuerries.SpecifyProjectionDirection(CMD_MinAreaEnclosingRectangle.string_0); ngeometry.VectorGeometry.Vector3d vector3d = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0); string a; if ((a = CMD_MinAreaEnclosingRectangle.string_0.ToUpper()) != null) { if (!(a == "X")) { if (!(a == "Y")) { if (!(a == "Z")) { if (!(a == "U")) { if (!(a == "2P")) { goto IL_150; } vector3d = CommandLineQuerries.Specify2PDirection().BasisVector[2]; vector3d = vector3d.Normalize(); } else { vector3d = Conversions.GetUCS().BasisVector[2].Normalize(); } } else { vector3d = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0); } } else { vector3d = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0); } } else { vector3d = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0); } Point point = new Point(0.0, 0.0, 0.0); ngeometry.VectorGeometry.Plane plane = new ngeometry.VectorGeometry.Plane(point, vector3d); CoordinateSystem actualCS = new CoordinateSystem(plane); CMD_MinAreaEnclosingRectangle.ComputeMinAreaEnclosingRectangle(idArray, actualCS); return; } IL_150: throw new System.Exception("Invalid option keyword."); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
public static ngeometry.VectorGeometry.Circle ToCeometricCircle(Autodesk.AutoCAD.DatabaseServices.Circle circle /*ng:类型存疑*/) { ngeometry.VectorGeometry.Point center = new ngeometry.VectorGeometry.Point(circle.Center.X, circle.Center.Y, circle.Center.Z); ngeometry.VectorGeometry.Vector3d normalVector = new ngeometry.VectorGeometry.Vector3d(circle.Normal.X, circle.Normal.Y, circle.Normal.Z); return(new ngeometry.VectorGeometry.Circle(center, circle.Radius, normalVector)); }
private void method_0(ObjectId[] objectId_0, ref ProgressMeter progressMeter_0, CoordinateSystem coordinateSystem_0) { Database workingDatabase = HostApplicationServices.WorkingDatabase; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; List <Region> list = new List <Region>(); double epsilon = Convert.ToDouble(CMD_Silhouette.string_1); DBManager.SetEpsilon(); List <Triangle> list2 = Conversions.ToCeometricAcDbTriangleList(objectId_0); if (!Conversions.IsWCS(coordinateSystem_0)) { Triangle.TransformCoordinates(list2, CoordinateSystem.Global(), coordinateSystem_0); } list2.Sort(new Triangle.CompareMinX()); int num = 0; double num2 = -1.7976931348623157E+308; double num3 = -1.7976931348623157E+308; double num4 = 1.7976931348623157E+308; double num5 = 1.7976931348623157E+308; for (int i = list2.Count - 1; i >= 0; i--) { if (list2[i].NormalVector.IsOrthogonalTo(new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0))) { list2.RemoveAt(i); num++; } else { Global.SuspendEpsilon(0.0, 0.0); list2[i].Vertex1.Z = 0.0; list2[i].Vertex2.Z = 0.0; list2[i].Vertex3.Z = 0.0; Global.ResumeEpsilon(); double minimumX = list2[i].MinimumX; if (minimumX < num4) { num4 = minimumX; } double maximumX = list2[i].MaximumX; if (maximumX > num2) { num2 = maximumX; } double minimumY = list2[i].MinimumY; if (minimumY < num5) { num5 = minimumY; } double maximumY = list2[i].MaximumY; if (maximumY > num3) { num3 = maximumY; } } } ngeometry.VectorGeometry.Vector3d vector3d = new ngeometry.VectorGeometry.Vector3d(0.5 * (num4 + num2), 0.5 * (num5 + num3), 0.0); double num6 = 0.5 * Math.Max(Math.Abs(num2 - num4), Math.Abs(num3 - num5)); double num7 = Math.Ceiling(100000.0 / num6); for (int j = 0; j < list2.Count; j++) { list2[j] = list2[j].Move(-1.0 * vector3d); } SubDMeshHandler subDMeshHandler = new SubDMeshHandler(list2); subDMeshHandler.BuildDataStructure(false); int k = 2147483647; while (k > 0) { this.messageFilter_0.CheckMessageFilter(); k = subDMeshHandler.Heal(epsilon); num += k; } editor.WriteMessage("\nDegenerate projections healed: " + num); Autodesk.AutoCAD.Geometry.Matrix3d matrix3d = Autodesk.AutoCAD.Geometry.Matrix3d.Scaling(num7, new Point3d(0.0, 0.0, 0.0)); Autodesk.AutoCAD.Geometry.Matrix3d matrix3d2 = Autodesk.AutoCAD.Geometry.Matrix3d.Scaling(1.0 / num7, new Point3d(0.0, 0.0, 0.0)); Autodesk.AutoCAD.Geometry.Matrix3d matrix3d3 = Autodesk.AutoCAD.Geometry.Matrix3d.Displacement(new Autodesk.AutoCAD.Geometry.Vector3d(vector3d.X, vector3d.Y, 0.0)); progressMeter_0 = new ProgressMeter(); progressMeter_0.SetLimit(subDMeshHandler.FaceVertexIndex1.Count); progressMeter_0.Start("Generating projections"); int num8 = 0; for (int l = 0; l < subDMeshHandler.FaceVertexIndex1.Count; l++) { try { progressMeter_0.MeterProgress(); this.messageFilter_0.CheckMessageFilter((long)l, 1000); } catch (System.Exception ex) { for (int m = 0; m < list.Count; m++) { list[m].Dispose(); } progressMeter_0.Stop(); throw; } Region region = this.method_2(subDMeshHandler, l); if (region == null) { num8++; } else { region.TransformBy(matrix3d); list.Add(region); } } editor.WriteMessage("\nNumber of failed projections: " + num8.ToString()); progressMeter_0.Stop(); progressMeter_0 = new ProgressMeter(); int limit = (int)Math.Ceiling(Math.Log((double)list.Count) / Math.Log(2.0)); progressMeter_0.SetLimit(limit); progressMeter_0.Start("Computing silhouette"); if (list.Count > 1) { this.method_1(ref list, ref progressMeter_0); } list[0].TransformBy(matrix3d2); list[0].TransformBy(matrix3d3); CoordinateTransformator coordinateTransformator = new CoordinateTransformator(coordinateSystem_0, CoordinateSystem.Global()); if (!coordinateTransformator.bool_0) { list[0].TransformBy(coordinateTransformator.ToAcadTransformation()); } using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1); blockTableRecord.AppendEntity(list[0]); transaction.AddNewlyCreatedDBObject(list[0], true); transaction.Commit(); } progressMeter_0.Stop(); }
public void ProjectLinesCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); ObjectId[] objectId_ = CommandLineQuerries.SelectFaces(false); ObjectId[] objectId_2 = CommandLineQuerries.SelectLines(false); LineProjection.string_2 = CommandLineQuerries.SpecifyProjectionDirection(LineProjection.string_2); //new Vector3d(0.0, 0.0, 1.0); ngeometry.VectorGeometry.Vector3d directionVector = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0); ngeometry.VectorGeometry.Vector3d directionVector2 = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0); string a; if ((a = LineProjection.string_2.ToUpper()) != null) { if (!(a == "X")) { if (!(a == "Y")) { if (!(a == "Z")) { if (!(a == "U")) { if (!(a == "2P")) { goto IL_267; } CommandLineQuerries.Specify2PDirection().BasisVector[2].Normalize(); } else { Conversions.GetUCS().BasisVector[2].Normalize(); } } else { directionVector = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0); directionVector2 = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0); //new Vector3d(0.0, 0.0, 1.0); } } else { directionVector = new ngeometry.VectorGeometry.Vector3d(1.0, 0.0, 0.0); directionVector2 = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0); //new Vector3d(0.0, 1.0, 0.0); } } else { directionVector = new ngeometry.VectorGeometry.Vector3d(0.0, 1.0, 0.0); directionVector2 = new ngeometry.VectorGeometry.Vector3d(0.0, 0.0, 1.0); //new Vector3d(0.0, 0.0, 1.0); } ngeometry.VectorGeometry.Point point = new ngeometry.VectorGeometry.Point(0.0, 0.0, 0.0); ngeometry.VectorGeometry.Plane plane = new ngeometry.VectorGeometry.Plane(point, directionVector, directionVector2); CoordinateSystem coordinateSystem_ = new CoordinateSystem(plane); LineProjection.string_1 = CommandLineQuerries.InsertOnLayer_Current_Face_Line(LineProjection.string_1); LineProjection.string_0 = CommandLineQuerries.KeywordYesNo("Delete original lines", LineProjection.string_0, false, false); this.method_0(objectId_2, objectId_, coordinateSystem_, true); return; } IL_267: throw new System.Exception("Invalid option keyword."); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message + "\n"); } }
public static PointSet SubdividePolyline3d(Polyline3d p3d, Transaction trans, double d) { PointSet result; try { PointSet pointSet = new PointSet(); if (d <= 0.0) { //using (IEnumerator enumerator = p3d.GetEnumerator()) { IEnumerator enumerator = p3d.GetEnumerator(); while (enumerator.MoveNext()) { ObjectId objectId = (ObjectId)enumerator.Current; PolylineVertex3d polylineVertex3d = (PolylineVertex3d)trans.GetObject(objectId, (OpenMode)0); Point point = new Point(polylineVertex3d.Position.X, polylineVertex3d.Position.Y, polylineVertex3d.Position.Z); if (pointSet.Count > 1) { if (pointSet[pointSet.Count - 1] != point) { pointSet.Add(point); } } else { pointSet.Add(point); } } goto IL_233; } } List <Point> list = new List <Point>(); foreach (ObjectId objectId2 in p3d) { PolylineVertex3d polylineVertex3d2 = (PolylineVertex3d)trans.GetObject(objectId2, (OpenMode)0); list.Add(new Point(polylineVertex3d2.Position.X, polylineVertex3d2.Position.Y, polylineVertex3d2.Position.Z)); } if (p3d.Closed) { list.Add(list[0]); } for (int i = 0; i < list.Count - 1; i++) { Point point2 = list[i]; Point point3 = list[i + 1]; ngeometry.VectorGeometry.Vector3d vector3d = new ngeometry.VectorGeometry.Vector3d(point3 - point2); double num = point2.DistanceTo(point3); double num2 = (double)((int)Math.Max(Math.Ceiling(num / d), 1.0)); double norm = num / num2; vector3d.Norm = norm; int num3 = 0; while ((double)num3 < num2) { pointSet.Add(point2 + (double)num3 * vector3d.ToPoint()); num3++; } } if (!p3d.Closed) { pointSet.Add(list[list.Count - 1]); } IL_233: result = pointSet; } catch (System.Exception ex) { Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Can not subdivide polyline3d (handle: " + p3d.Handle.ToString() + ")\n"); result = null; } return(result); }
public static PointSet SubdivideLWPolyline(Polyline lwp, double d) { PointSet result; try { PointSet pointSet = new PointSet(); int numberOfVertices = lwp.NumberOfVertices; if (d <= 0.0) { for (int i = 0; i < numberOfVertices; i++) { Point3d point3dAt = lwp.GetPoint3dAt(i); Point point = new Point(point3dAt.X, point3dAt.Y, point3dAt.Z); if (pointSet.Count > 1) { if (pointSet[pointSet.Count - 1] != point) { pointSet.Add(point); } } else { pointSet.Add(point); } } } else { List <Point> list = new List <Point>(); for (int j = 0; j < numberOfVertices; j++) { Point3d point3dAt2 = lwp.GetPoint3dAt(j); list.Add(new Point(point3dAt2.X, point3dAt2.Y, point3dAt2.Z)); } if (lwp.Closed) { list.Add(list[0]); } for (int k = 0; k < list.Count - 1; k++) { Point point2 = list[k]; Point point3 = list[k + 1]; ngeometry.VectorGeometry.Vector3d vector3d = new ngeometry.VectorGeometry.Vector3d(point3 - point2); double num = point2.DistanceTo(point3); int num2 = (int)Math.Max(Math.Ceiling(num / d), 1.0); double norm = num / (double)num2; vector3d.Norm = norm; for (int l = 0; l < num2; l++) { pointSet.Add(point2 + (double)l * vector3d.ToPoint()); } } if (!lwp.Closed) { pointSet.Add(list[list.Count - 1]); } } result = pointSet; } catch (System.Exception ex) { Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Can not subdivide polyline (handle: " + lwp.Handle.ToString() + ")\n"); result = null; } return(result); }