public void Contour(UserCmd cmd, string refrencePlan, double startElevation, double endElevation, double spacing, string whatCADData, string prefix) { this.cmd = cmd; MyDB2 mydb = cmd.mydb; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //ObjectId[] objectId_ = CommandLineQuerries.SelectFaces(false); ObjectId[] faceIDs = Selection.getFaceIds(mydb.getFaceLayerName()); ContourLineComputation.string_0 = refrencePlan; CoordinateSystem coordinateSystem = CoordinateSystem.Global(); if (ContourLineComputation.string_0 == "U") { coordinateSystem = Conversions.GetUCS(); } if (ContourLineComputation.string_0 == "3P") { coordinateSystem = CommandLineQuerries.Specify3PSystem(); } coordinateSystem.Orthonormalize(); ContourLineComputation.startElevation = startElevation; ContourLineComputation.endElevation = Math.Max(ContourLineComputation.endElevation, ContourLineComputation.startElevation); bool flag = false; while (!flag) { ContourLineComputation.endElevation = endElevation; if (ContourLineComputation.startElevation > ContourLineComputation.endElevation) { editor.WriteMessage("\nStart elevation must be less or equal end elevation."); } else { flag = true; } } ContourLineComputation.spacing = spacing; ContourLineComputation.whatCADData = whatCADData;//CommandLineQuerries.InsertOnLayer_Current_Face_Elevation_Index(ContourLineComputation.whichLayer); if (ContourLineComputation.whatCADData != "F" && ContourLineComputation.whatCADData != "C") { ContourLineComputation.prefix = prefix;// CommandLineQuerries.SpecifyPrefixString(ContourLineComputation.prefix); } this.genContour2(faceIDs, coordinateSystem); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message + "\n"); } }
public static void Colorize(MyDB2 mydb, List <System.Drawing.Color> cl, FaceColorizeType type) { TEDictionary ted = mydb.TEDicList[mydb.Resolution]; 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 = Selection.getFaceIds(mydb.getFaceLayerName()); List <Triangle> triList = Conversions.ToCeometricAcDbTriangleList(faceIDs); Global.SuspendEpsilon(0.0, 0.0); //List<Triangle> triList = ted.TriangleList; Global.ResumeEpsilon(); double num = 1.7976931348623157E+308; double num2 = -1.7976931348623157E+308; string formatFromLUPREC = DBManager.GetFormatFromLUPREC(); string a; double range; if (type == FaceColorizeType.CenterZ) { range = ted.maxCZ - ted.minCZ; } else if (type == FaceColorizeType.MaxZ) { range = ted.maxMaxZ - ted.minMaxZ; } else { throw new System.Exception("无效的颜色类型"); } double sec = range / cl.Count; progressMeter.SetLimit(triList.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 < triList.Count) { try { progressMeter.MeterProgress(); messageFilter.CheckMessageFilter((long)i, 1000); } catch (System.Exception ex) { progressMeter.Stop(); throw; } int colorIndex; if (type == FaceColorizeType.CenterZ) { colorIndex = (int)Math.Floor((triList[i].Center.Z - ted.minCZ) / sec); } else if (type == FaceColorizeType.MaxZ) { colorIndex = (int)Math.Floor((Math.Max(Math.Max(triList[i].Vertex1.Z, triList[i].Vertex2.Z), triList[i].Vertex3.Z) - ted.minMaxZ) / sec); } else { throw new System.Exception("无效的类型"); } if (colorIndex >= cl.Count) { colorIndex = cl.Count - 1; } Face face = (Face)transaction.GetObject(triList[i].AcDbFace.ObjectId, (OpenMode)1); face.Color = Autodesk.AutoCAD.Colors.Color.FromColor(cl[colorIndex]); i++; continue; } transaction.Commit(); } progressMeter.Stop(); return; throw new System.Exception("Invalid target property"); } catch (System.Exception ex) { progressMeter.Stop(); editor.WriteMessage("\n" + ex.Message); } }