public void STLASCIIOutCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); CommandLineQuerries.SpecifyFileNameForWrite(ref CMD_STL.string_2, ref CMD_STL.string_4, "stl"); CMD_STL.string_1 = CommandLineQuerries.SpecifySTLType(CMD_STL.string_1); ObjectId[] array = CommandLineQuerries.SelectFaces(false); Global.SuspendEpsilon(0.0, 0.0); List <Triangle> list = Conversions.ToCeometricAcDbTriangleList(array); Global.ResumeEpsilon(); string a; if ((a = CMD_STL.string_1) != null) { if (!(a == "A")) { if (a == "B") { BinarySTL binarySTL = new BinarySTL(); binarySTL.Triangles = list; for (int i = 0; i < list.Count; i++) { BinarySTL.STLColor sTLColor = new BinarySTL.STLColor(); sTLColor.R = (byte)Math.Floor((double)list[i].AcDbFace.Color.Red / 8.0); sTLColor.G = (byte)Math.Floor((double)list[i].AcDbFace.Color.Green / 8.0); sTLColor.B = (byte)Math.Floor((double)list[i].AcDbFace.Color.Blue / 8.0); sTLColor.IsValid = true; sTLColor._cDef = binarySTL.ColorDefinition; binarySTL.Colors.Add(sTLColor); } binarySTL.Write(CMD_STL.string_2); editor.WriteMessage("\nNumber of triangles written : " + binarySTL.NumberOfTrianglesWritten.ToString()); editor.WriteMessage("\nNumber of degenerate triangles: " + binarySTL.NumberOfDegenerateTriangles.ToString()); editor.WriteMessage("\nHas negative coordinates : " + binarySTL.HasNegativeCoordinates.ToString()); editor.WriteMessage("\nSTL file in binary format written to " + CMD_STL.string_2); } } else { string layerNameOfEntity = DBManager.GetLayerNameOfEntity(array[0]); string solidName = CommandLineQuerries.SpecifyString("Specify STL solid name", layerNameOfEntity, true); ASCIISTL aSCIISTL = new ASCIISTL(); aSCIISTL.Triangles = list; aSCIISTL.SolidName = solidName; aSCIISTL.Write(CMD_STL.string_2); editor.WriteMessage("\nNumber of triangles written : " + aSCIISTL.NumberOfTrianglesWritten.ToString()); editor.WriteMessage("\nNumber of degenerate triangles: " + aSCIISTL.NumberOfDegenerateTriangles.ToString()); editor.WriteMessage("\nHas negative coordinates : " + aSCIISTL.HasNegativeCoordinates.ToString()); editor.WriteMessage("\nSTL file in ASCII format written to " + CMD_STL.string_2); } } } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
public void XMLOUT() { try { ////LicenseManager.CheckValid("FULL"); ObjectId[] objectId_ = CommandLineQuerries.smethod_4(true); CommandLineQuerries.SpecifyFileNameForWrite(ref IO2.string_0, ref IO2.string_8, "xml"); this.method_1(objectId_); } catch (System.Exception ex) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine); } }
public void XYZOUT() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ObjectId[] array = null; try { ////LicenseManager.CheckValid("FULL"); IO2.string_6 = CommandLineQuerries.SpecifyEntitiesBySelectionOrByLayer(IO2.string_6); if (IO2.string_6 == "S") { array = CommandLineQuerries.SelectPoints(true); } else if (IO2.string_6 == "L") { IO2.string_7 = CommandLineQuerries.SpecifyLayerName(IO2.string_7); if (!DBManager.ExistsLayer(IO2.string_7)) { throw new ArgumentException("Layer does not exist."); } array = DBManager.GetPointsOnLayer(IO2.string_7); if (array == null) { throw new ArgumentException("No points selected."); } editor.WriteMessage(Environment.NewLine + array.Length + " points selected."); } CommandLineQuerries.SpecifyFileNameForWrite(ref IO2.string_5, ref IO2.string_8, "xyz"); IO2.string_9 = CommandLineQuerries.SpecifyDelimiter(IO2.string_9); IO2.int_0 = CommandLineQuerries.SpecifyColumnWidth(IO2.int_0); IO2.int_1 = CommandLineQuerries.SpecifyDecimalDigits(IO2.int_1); this.WriteXYZ(array); } catch (System.Exception ex) { editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine); } }
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); } }