public void SimplifyPolylinesCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database arg_15_0 = HostApplicationServices.WorkingDatabase; try { //LicenseManager.CheckValid("FULL"); ObjectId[] array = CommandLineQuerries.SelectPolylines(false); PLine.double_0 = CommandLineQuerries.SpecifyDouble("Specify epsilon range", PLine.double_0, false, false, false, true); PLine.string_2 = CommandLineQuerries.KeywordYesNo("Keep original polylines", PLine.string_2, false, false); int num = 0; int num2 = 0; int num3 = 0; this.method_1(array, PLine.double_0, ref num, ref num2, ref num3); editor.WriteMessage(string.Concat(new string[] { "\nNumber of vertices before : ", num.ToString(), "\nNumber of vertices after : ", num2.ToString(), "\nNumber of polylines processed: ", array.Length.ToString(), "\nNumber of polylines failed : ", num3.ToString() })); } catch (System.Exception ex) { editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine); } }
public void GenerateSolidCommand() { ProgressMeter progressMeter = new ProgressMeter(); Database arg_0B_0 = HostApplicationServices.WorkingDatabase; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; this.messageFilter_0 = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(this.messageFilter_0); try { //LicenseManager.CheckValid("FULL"); ObjectId[] objectId_ = CommandLineQuerries.SelectFaces(false); CMD_FacesToSolid.string_1 = CommandLineQuerries.SpecifyReferencePlane(CMD_FacesToSolid.string_1); CoordinateSystem coordinateSystem = CoordinateSystem.Global(); if (CMD_FacesToSolid.string_1 == "U") { coordinateSystem = Conversions.GetUCS(); } if (CMD_FacesToSolid.string_1 == "3P") { coordinateSystem = CommandLineQuerries.Specify3PSystem(); } coordinateSystem.Orthonormalize(); CMD_FacesToSolid.double_0 = CommandLineQuerries.SpecifyDouble("Extrusion height in actual Z", CMD_FacesToSolid.double_0, false, true, false, false); bool flag = false; while (!flag) { CMD_FacesToSolid.string_2 = CommandLineQuerries.SpecifyString("Minimum projected edge length", CMD_FacesToSolid.string_2, false); if (Convert.ToDouble(CMD_FacesToSolid.string_2) >= 0.0001 && Convert.ToDouble(CMD_FacesToSolid.string_2) <= 1.0) { flag = true; } else { editor.WriteMessage("\nValue must be between 0.0001 and 1."); } } CMD_FacesToSolid.string_0 = CommandLineQuerries.KeywordYesNo("Union solids", CMD_FacesToSolid.string_0, false, false).ToUpper().Trim(); this.method_0(objectId_, progressMeter, coordinateSystem); } catch (System.Exception ex) { progressMeter.Stop(); editor.WriteMessage("\n" + ex.Message); } }
public void ContourCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { ObjectId[] objectId_ = CommandLineQuerries.SelectFaces(false); ContourLineComputation.string_0 = CommandLineQuerries.SpecifyReferencePlane(ContourLineComputation.string_0); CoordinateSystem coordinateSystem = CoordinateSystem.Global(); if (ContourLineComputation.string_0 == "U") { coordinateSystem = Conversions.GetUCS(); } if (ContourLineComputation.string_0 == "3P") { coordinateSystem = CommandLineQuerries.Specify3PSystem(); } coordinateSystem.Orthonormalize(); ContourLineComputation.startElevation = CommandLineQuerries.SpecifyDouble("Specify start elevation", ContourLineComputation.startElevation, false, true, false, true); ContourLineComputation.endElevation = Math.Max(ContourLineComputation.endElevation, ContourLineComputation.startElevation); bool flag = false; while (!flag) { ContourLineComputation.endElevation = CommandLineQuerries.SpecifyDouble("Specify end elevation", ContourLineComputation.endElevation, false, true, false, true); if (ContourLineComputation.startElevation > ContourLineComputation.endElevation) { editor.WriteMessage("\nStart elevation must be less or equal end elevation."); } else { flag = true; } } ContourLineComputation.spacing = CommandLineQuerries.SpecifyDouble("Specify spacing", ContourLineComputation.spacing, false, false, false, false); ContourLineComputation.whatCADData = CommandLineQuerries.InsertOnLayer_Current_Face_Elevation_Index(ContourLineComputation.whatCADData); if (ContourLineComputation.whatCADData != "F" && ContourLineComputation.whatCADData != "C") { ContourLineComputation.prefix = CommandLineQuerries.SpecifyPrefixString(ContourLineComputation.prefix); } this.genContour(objectId_, coordinateSystem); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message + "\n"); } }
public void QSelectFacesCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database workingDatabase = HostApplicationServices.WorkingDatabase; ProgressMeter progressMeter = new ProgressMeter(); try { //LicenseManager.CheckValid("FULL"); CMD_QSelectFaces.string_0 = CommandLineQuerries.SpecifyTargetProperty(CMD_QSelectFaces.string_0); CMD_QSelectFaces.string_1 = CommandLineQuerries.SpecifyOperator(CMD_QSelectFaces.string_1); double num = CommandLineQuerries.SpecifyDouble("Specify criterion", 0.0, false, true, false, true); List <Triangle> list = Conversions.ToCeometricAcDbTriangleList(DBManager.GetAllFaces()); int num2 = 0; progressMeter.SetLimit(list.Count); progressMeter.Start("Selecting faces"); using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1); BlockTableRecord arg_BE_0 = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1); List <ObjectId> list2 = new List <ObjectId>(); int count = list.Count; for (int i = 0; i < count; i++) { if (list[i].Area < num) { Face face = (Face)transaction.GetObject(list[i].AcDbFace.ObjectId, (OpenMode)1); list2.Add(face.ObjectId); num2++; } progressMeter.MeterProgress(); } transaction.Commit(); } progressMeter.Stop(); editor.WriteMessage("Number of faces selected: " + num2); } catch (System.Exception ex) { progressMeter.Stop(); editor.WriteMessage("\n" + ex.Message); } }
public void BlurPointsCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); ObjectId[] objectId_ = CommandLineQuerries.SelectPoints(false); double num = CommandLineQuerries.SpecifyDouble("Specify blur radius", PointBlurring.double_0, false, false, false, false); if (num != -1.0) { PointBlurring.double_0 = num; this.method_0(objectId_); } } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
public void EliminatePoints2dCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database arg_15_0 = HostApplicationServices.WorkingDatabase; new List <IdPoint>(); try { //LicenseManager.CheckValid("FULL"); ObjectId[] pointIDs = CommandLineQuerries.SelectPoints(false); PointElimination.double_0 = CommandLineQuerries.SpecifyDouble("Specify snap radius", PointElimination.double_0, false, false, false, true); PointElimination.string_0 = CommandLineQuerries.KeepIfMultiple(PointElimination.string_0); int num = 0; IdPoint.EraseDublicates2d(pointIDs, PointElimination.double_0, PointElimination.string_0, ref num); editor.WriteMessage("\nNumber of points erased: " + num); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
public void DevelopmentCommand() { Database arg_05_0 = HostApplicationServices.WorkingDatabase; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); PromptEntityOptions promptEntityOptions = new PromptEntityOptions("Select polyline"); promptEntityOptions.SetRejectMessage("\nNo polyline selected"); promptEntityOptions.AddAllowedClass(typeof(Polyline3d), true); promptEntityOptions.AddAllowedClass(typeof(Polyline2d), true); promptEntityOptions.AddAllowedClass(typeof(Polyline), true); promptEntityOptions.AllowNone = (false); PromptEntityResult entity = editor.GetEntity(promptEntityOptions); if (entity.Status == (PromptStatus)(-5002)) { CommandLineQuerries.OnCancelled(); } if (entity.Status != (PromptStatus)5100) { CommandLineQuerries.OnNotOK(); } CMD_Development.string_2 = CommandLineQuerries.KeywordYesNo("Reverse polyline", CMD_Development.string_2, false, false); CMD_Development.string_3 = CommandLineQuerries.KeywordYesNo("Specify range", CMD_Development.string_3, false, false); if (CMD_Development.string_3 == "Y") { CMD_Development.double_0 = CommandLineQuerries.SpecifyDouble("Specify start arc length", CMD_Development.double_0, false, false, false, true); CMD_Development.double_1 = CommandLineQuerries.SpecifyDouble("Specify end arc length", CMD_Development.double_1, false, false, false, true); } CMD_Development.double_2 = CommandLineQuerries.SpecifyDouble("Specify z-scaling", CMD_Development.double_2, false, false, false, false); CMD_Development.string_5 = CommandLineQuerries.KeywordYesNo("Include first derivative (slope)", CMD_Development.string_5, false, false); if (CMD_Development.string_5 == "Y") { CMD_Development.double_3 = CommandLineQuerries.SpecifyDouble("Specify z-scaling for derivative", CMD_Development.double_3, false, false, false, false); } CMD_Development.string_4 = CommandLineQuerries.SpecifyOutfileType(CMD_Development.string_4); CommandLineQuerries.SpecifyFileNameForWrite(ref CMD_Development.string_0, ref CMD_Development.string_1, CMD_Development.string_4); bool reverse = CMD_Development.string_2 == "Y"; double startBGL = 0.0; double endBGL = 1.7976931348623157E+308; if (CMD_Development.string_3 == "Y") { startBGL = CMD_Development.double_0; endBGL = CMD_Development.double_1; } List <Point> list = this.DevelopPolyline(entity.ObjectId, reverse, startBGL, endBGL); List <Point> points = new List <Point>(); if (CMD_Development.string_5 == "Y") { points = this.Derivative(list); } CMD_Development.Result result = new CMD_Development.Result(list, startBGL); editor.WriteMessage("\n" + result.ToString()); Database database = new Database(true, true); using (Transaction transaction = database.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(database.BlockTableId, (OpenMode)1); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1); bool flag = false; ObjectId layerId = DBManager.CreateLayer("profile", 7, false, ref flag, database); Point3dCollection point3dCollection = Conversions.ToPoint3dCollection(list); Polyline3d polyline3d = new Polyline3d(0, point3dCollection, false); point3dCollection.Dispose(); polyline3d.LayerId = (layerId); blockTableRecord.AppendEntity(polyline3d); transaction.AddNewlyCreatedDBObject(polyline3d, true); if (CMD_Development.string_5 == "Y") { bool flag2 = false; ObjectId layerId2 = DBManager.CreateLayer("slope", 4, false, ref flag2, database); Point3dCollection point3dCollection2 = Conversions.ToPoint3dCollection(points); Polyline3d polyline3d2 = new Polyline3d(0, point3dCollection2, false); point3dCollection2.Dispose(); polyline3d2.LayerId = (layerId2); blockTableRecord.AppendEntity(polyline3d2); transaction.AddNewlyCreatedDBObject(polyline3d2, true); } transaction.Commit(); polyline3d.Dispose(); } DBManager.SaveDrawing(database, CMD_Development.string_0, CMD_Development.string_4, (DwgVersion)29); } catch (System.Exception ex) { editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine); } }
public void ColorizeFacesCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database workingDatabase = HostApplicationServices.WorkingDatabase; ProgressMeter progressMeter = new ProgressMeter(); MessageFilter messageFilter = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(messageFilter); try { ObjectId[] faceIDs = CommandLineQuerries.SelectFaces(false); CMD_Colorize.string_0 = CommandLineQuerries.SpecifyTargetProperty(CMD_Colorize.string_0); CMD_Colorize.string_1 = CommandLineQuerries.KeywordYesNo("Reverse color order", CMD_Colorize.string_1, false, false); CMD_Colorize.int_0 = CommandLineQuerries.SpecifyInteger("Specify number of colors", CMD_Colorize.int_0, 2, 32768, false, false); CMD_Colorize.double_0 = CommandLineQuerries.SpecifyDouble("Specify lower cutoff percentage", CMD_Colorize.double_0, false, true, false, true); CMD_Colorize.double_1 = CommandLineQuerries.SpecifyDouble("Specify upper cutoff percentage", CMD_Colorize.double_1, false, false, false, false); Global.SuspendEpsilon(0.0, 0.0); List <Triangle> list = Conversions.ToCeometricAcDbTriangleList(faceIDs); Global.ResumeEpsilon(); double num = 1.7976931348623157E+308; double num2 = -1.7976931348623157E+308; string formatFromLUPREC = DBManager.GetFormatFromLUPREC(); string a; if ((a = CMD_Colorize.string_0) != null) { if (!(a == "AN")) { if (!(a == "AR")) { if (!(a == "CZ")) { if (!(a == "MINZ")) { if (!(a == "MAXZ")) { goto IL_714; } Triangle.Sort(list, Triangle.SortOrder.MaxZ); num = list[0].MaximumZ; num2 = list[list.Count - 1].MaximumZ; editor.WriteMessage("\nMinimum maximum Z: " + num.ToString(formatFromLUPREC)); editor.WriteMessage("\nMaximum maximum Z: " + num2.ToString(formatFromLUPREC)); } else { Triangle.Sort(list, Triangle.SortOrder.MinZ); num = list[0].MinimumZ; num2 = list[list.Count - 1].MinimumZ; editor.WriteMessage("\nMinimum minimum Z: " + num.ToString(formatFromLUPREC)); editor.WriteMessage("\nMaximum minimum Z: " + num2.ToString(formatFromLUPREC)); } } else { Triangle.Sort(list, Triangle.SortOrder.CenterZ); num = list[0].Center.Z; num2 = list[list.Count - 1].Center.Z; editor.WriteMessage("\nMinimum center Z: " + num.ToString(formatFromLUPREC)); editor.WriteMessage("\nMaximum center Z: " + num2.ToString(formatFromLUPREC)); } } else { Triangle.Sort(list, Triangle.SortOrder.Area); num = list[0].Area; num2 = list[list.Count - 1].Area; editor.WriteMessage("\nMinimum area: " + num.ToString(formatFromLUPREC)); editor.WriteMessage("\nMaximum area: " + num2.ToString(formatFromLUPREC)); } } else { Triangle.Sort(list, Triangle.SortOrder.MinimumAngle); num = list[0].MinimumAngle; num2 = list[list.Count - 1].MinimumAngle; editor.WriteMessage("\nMinimum minimum angle: " + (num * 180.0 / 3.1415926535897931).ToString(formatFromLUPREC) + " deg."); editor.WriteMessage("\nMaximum minimum angle: " + (num2 * 180.0 / 3.1415926535897931).ToString(formatFromLUPREC) + " deg."); } progressMeter.SetLimit(list.Count); progressMeter.Start("Colorizing property"); using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1); BlockTableRecord arg_3D7_0 = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1); int i = 0; while (i < list.Count) { try { progressMeter.MeterProgress(); messageFilter.CheckMessageFilter((long)i, 1000); } catch (System.Exception ex) { progressMeter.Stop(); throw; } string a2; if ((a2 = CMD_Colorize.string_0) != null) { double num3; if (!(a2 == "AN")) { if (!(a2 == "AR")) { if (!(a2 == "CZ")) { if (!(a2 == "MINZ")) { if (!(a2 == "MAXZ")) { goto IL_6F4; } num3 = list[i].MaximumZ; } else { num3 = list[i].MinimumZ; } } else { num3 = list[i].Center.Z; } } else { num3 = list[i].Area; } } else { num3 = list[i].MinimumAngle; } int num4 = CMD_Colorize.int_0 - 1; double num5 = Math.Abs((num3 - num) / (num2 - num)); if (100.0 * num5 <= CMD_Colorize.double_0) { num5 = 0.0; } else if (100.0 * num5 >= CMD_Colorize.double_1) { num5 = 1.0; } else { num5 = num5 * 100.0 / (CMD_Colorize.double_1 - CMD_Colorize.double_0) - CMD_Colorize.double_0 / (CMD_Colorize.double_1 - CMD_Colorize.double_0); } num5 = Math.Round((double)num4 * num5, 0) / (double)num4; if (CMD_Colorize.string_1 == "Y") { num5 = 1.0 - num5; } double num6 = 0.2; byte b = 0; byte b2 = 0; byte b3 = 0; if (num5 < 0.2) { b3 = (byte)(255.0 * (num5 - 0.0 * num6) / num6); b2 = 255; } else if (num5 < 2.0 * num6) { b3 = 255; b2 = (byte)(255.0 - 255.0 * (num5 - 1.0 * num6) / num6); } else if (num5 < 3.0 * num6) { b = (byte)(255.0 * (num5 - 2.0 * num6) / num6); b3 = 255; } else if (num5 < 4.0 * num6) { b = 255; b3 = (byte)(255.0 - 255.0 * (num5 - 3.0 * num6) / num6); } else { b = 255; b2 = (byte)(255.0 * (num5 - 4.0 * num6) / num6); } Face face = (Face)transaction.GetObject(list[i].AcDbFace.ObjectId, (OpenMode)1); face.Color = (Color.FromRgb(b, b3, b2)); i++; continue; } IL_6F4: throw new System.Exception("Invalid target property"); } transaction.Commit(); goto IL_71F; } goto IL_714; IL_71F: progressMeter.Stop(); return; } IL_714: throw new System.Exception("Invalid target property"); } catch (System.Exception ex) { progressMeter.Stop(); editor.WriteMessage("\n" + ex.Message); } }
internal PointSet method_0() { Editor arg_0F_0 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database arg_15_0 = HostApplicationServices.WorkingDatabase; PointGeneration.string_0 = CommandLineQuerries.SpecifyEntityType(PointGeneration.string_0); string key; if ((key = PointGeneration.string_0) != null) { if (PrivateImplementationDetails40B.method0x60001441 == null) { PrivateImplementationDetails40B.method0x60001441 = new Dictionary <string, int>(10) { { "A", 0 }, { "ALL", 1 }, { "C", 2 }, { "E", 3 }, { "F", 4 }, { "L", 5 }, { "P", 6 }, { "S", 7 }, { "T", 8 }, { "SO", 9 } }; } int num; if (PrivateImplementationDetails40B.method0x60001441.TryGetValue(key, out num)) { ObjectId[] objectIDs; switch (num) { case 0: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.ARC); break; case 1: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.ArcLineTextCircleEllipseFaceSplinePline); break; case 2: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.CIRCLE); break; case 3: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.ELLIPSE); break; case 4: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.FACE); break; case 5: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.LINE); break; case 6: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.PLINES); break; case 7: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.SPLINE); break; case 8: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.TEXT); break; case 9: objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.SOLID3D); break; default: goto IL_1B1; } if (objectIDs == null) { return(null); } if (!(PointGeneration.string_0 == "T") && !(PointGeneration.string_0 == "F")) { PointGeneration.double_0 = CommandLineQuerries.SpecifyDouble("Enter maximum subdivision distance or 0 for no subdivision", PointGeneration.double_0, false, false, false, true); return(this.method_1(objectIDs, PointGeneration.double_0)); } return(this.method_1(objectIDs, 0.0)); } } IL_1B1: throw new ArgumentException("Invalid option keyword."); }