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 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"); } }
private void method_0(string string_5) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database workingDatabase = HostApplicationServices.WorkingDatabase; MessageFilter messageFilter = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(messageFilter); ProgressMeter progressMeter = new ProgressMeter(); ASCIISTL aSCIISTL = new ASCIISTL(); aSCIISTL.Read(string_5); editor.WriteMessage("\nSTL solid name : " + aSCIISTL.SolidName); editor.WriteMessage("\nNumber of triangles read : " + aSCIISTL.NumberOfTrianglesRead.ToString()); editor.WriteMessage("\nNumber of degenerate triangles: " + aSCIISTL.NumberOfDegenerateTriangles.ToString()); editor.WriteMessage("\nHas negative coordinates : " + aSCIISTL.HasNegativeCoordinates.ToString()); editor.WriteMessage("\nInconsistent facet normals : " + aSCIISTL.HasInconsitentNormals.ToString()); editor.WriteMessage("\n"); ObjectId layerId = DBManager.CurrentLayerId(); bool flag = false; string a; if ((a = CMD_STL.string_0) != null) { if (!(a == "S")) { if (!(a == "N")) { if (a == "C") { layerId = DBManager.CurrentLayerId(); } } else { string text = "0"; text = CommandLineQuerries.SpecifyLayerName(text); layerId = DBManager.CreateLayer(text, 7, false, ref flag); } } else { if (aSCIISTL.SolidName.Trim() == "") { aSCIISTL.SolidName = "Unnamed_solid"; } if (!DBManager.ValidateName(aSCIISTL.SolidName)) { return; } layerId = DBManager.CreateLayer(aSCIISTL.SolidName, 256, false, ref flag); editor.WriteMessage("Solid inserted on layer " + aSCIISTL.SolidName); } } 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); progressMeter.SetLimit(aSCIISTL.NumberOfTrianglesRead); progressMeter.Start("Writing database"); for (int i = 0; i < aSCIISTL.Triangles.Count; i++) { try { progressMeter.MeterProgress(); messageFilter.CheckMessageFilter((long)i, 1000); } catch (System.Exception ex) { progressMeter.Stop(); throw; } Point3d point3d = new Point3d(aSCIISTL.Triangles[i].Vertex1.X, aSCIISTL.Triangles[i].Vertex1.Y, aSCIISTL.Triangles[i].Vertex1.Z); Point3d point3d2 = new Point3d(aSCIISTL.Triangles[i].Vertex2.X, aSCIISTL.Triangles[i].Vertex2.Y, aSCIISTL.Triangles[i].Vertex2.Z); Point3d point3d3 = new Point3d(aSCIISTL.Triangles[i].Vertex3.X, aSCIISTL.Triangles[i].Vertex3.Y, aSCIISTL.Triangles[i].Vertex3.Z); Face face = new Face(point3d, point3d2, point3d3, true, true, true, true); face.LayerId = (layerId); blockTableRecord.AppendEntity(face); transaction.AddNewlyCreatedDBObject(face, true); } transaction.Commit(); progressMeter.Stop(); } }