public static ObjectId[] getAllLines() { ObjectId[] objectIDs = null; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { TypedValue[] filter = new TypedValue[] { new TypedValue(-4, "<or"), new TypedValue(0, "LINE"), new TypedValue(0, "LWPOLYLINE"), new TypedValue(0, "POLYLINE2D"), new TypedValue(0, "POLYLINE"), new TypedValue(-4, "or>") }; PromptSelectionResult selection = editor.SelectAll(new SelectionFilter(filter)); if (selection.Status == (PromptStatus.Cancel)) { CommandLineQuerries.OnCancelled(); } if (selection.Status != PromptStatus.OK) { return(null); } objectIDs = selection.Value.GetObjectIds(); //Region region= AddRegion(objectIDs); } catch (System.Exception ex) { } return(objectIDs); }
public static ObjectId[] GetObjectIDs(string dxfName, string layerName) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; if (layerName == null || layerName == "") { layerName = "*"; } TypedValue[] array = new TypedValue[0]; array = new TypedValue[] { new TypedValue(-4, "<or"), new TypedValue(-4, "<and"), new TypedValue((int)DxfCode.LayerName, layerName), new TypedValue((int)DxfCode.Start, dxfName), new TypedValue(-4, "and>"), new TypedValue(-4, "or>") }; PromptSelectionResult selection = editor.SelectAll(new SelectionFilter(array)); if (selection.Status == (PromptStatus.Cancel)) { CommandLineQuerries.OnCancelled(); } if (selection.Status != PromptStatus.OK) { return(null); } return(selection.Value.GetObjectIds()); }
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 STLInCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database arg_15_0 = HostApplicationServices.WorkingDatabase; try { //LicenseManager.CheckValid("FULL"); CommandLineQuerries.SpecifyFileNameForRead(ref CMD_STL.string_3, "stl"); string a = this.method_2(CMD_STL.string_3); if (a == "A") { editor.WriteMessage("\nASCII STL format file identified."); CMD_STL.string_0 = CommandLineQuerries.InsertOnLayer_Current_Name_STL(CMD_STL.string_0); this.method_0(CMD_STL.string_3); } else if (a == "B") { editor.WriteMessage("\nBinary STL format file identified."); if (CMD_STL.string_0 == "S") { CMD_STL.string_0 = "C"; } CMD_STL.string_0 = CommandLineQuerries.InsertOnLayer_Current_Name(CMD_STL.string_0); this.method_1(CMD_STL.string_3); } DBManager.ZoomExtents(); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
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 static PointSet getPointFromText(ScaleProp scale) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { PointSet pointSet = new PointSet(); TypedValue[] filter = null; filter = new TypedValue[] { new TypedValue(0, "TEXT") }; PromptSelectionResult selection = editor.SelectAll(new SelectionFilter(filter)); if (selection.Status == (PromptStatus)(-5002)) { CommandLineQuerries.OnCancelled(); } if (selection.Status != (PromptStatus)5100) { return(null); } ObjectId[] objectIDs = selection.Value.GetObjectIds(); if (objectIDs != null) { Database workingDatabase = HostApplicationServices.WorkingDatabase; using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { for (int i = 0; i < objectIDs.Length; i++) { DBText dbText = (DBText)transaction.GetObject(objectIDs[i], OpenMode.ForRead, true); string text = dbText.TextString; double z = 0; double.TryParse(text, out z); pointSet.Add(new ngeometry.VectorGeometry.Point(dbText.Position.X * scale.X, dbText.Position.Y * scale.Y, z * scale.Z)); } transaction.Commit(); } } else { editor.WriteMessage("没有选择到点.\n"); } return(pointSet); } catch (System.Exception ex) { } return(null); }
public void SliceLineCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database arg_15_0 = HostApplicationServices.WorkingDatabase; try { //LicenseManager.CheckValid("FULL"); ObjectId[] objectId_ = CommandLineQuerries.SelectLines(false); ngeometry.VectorGeometry.Plane planeNormalized = CommandLineQuerries.Specify3PSystem().GetPlaneNormalized(); int num = 0; while (num == 0) { Point left = new Point(); PromptPointResult promptPointResult = CommandLineQuerries.SpecifyPointOrKeepBothSides(); if (promptPointResult.Status == (PromptStatus)(-5005)) { num = 0; IL_F2_: this.method_0(objectId_, planeNormalized, num); return; } if (promptPointResult.Status == (PromptStatus)5100) { Point3d value = promptPointResult.Value; left = new Point(value.X, value.Y, value.Z); num = Math.Sign(ngeometry.VectorGeometry.Vector3d.Dot(planeNormalized.NormalVector, new ngeometry.VectorGeometry.Vector3d(left - planeNormalized.Point))); if (num == 0) { editor.WriteMessage("\nInvalid point: point is on plane."); } } else if (promptPointResult.Status == (PromptStatus)(-5002)) { CommandLineQuerries.OnCancelled(); } else if (promptPointResult.Status != (PromptStatus)5100) { CommandLineQuerries.OnNotOK(); } } goto IL_F2; IL_F2: { this.method_0(objectId_, planeNormalized, num); return; } } catch (System.Exception ex) { editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine); } }
public void XYZIN() { try { ////LicenseManager.CheckValid("FULL"); CommandLineQuerries.SpecifyFileNameForRead(ref IO2.string_4, "xyz"); this.method_4(); } catch (System.Exception ex) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine); } }
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 void Hull3dCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); ObjectId[] idArray = CommandLineQuerries.SelectPoints(false); this.ComputePrincipalAxisBoundingBox(idArray); } 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 GenerateSubDMeshCommand() { Database arg_05_0 = HostApplicationServices.WorkingDatabase; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { if (!Reg.Is2010OrHigher()) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("This method is supported only for version 2010 or higher."); } else { ObjectId[] array = CommandLineQuerries.SelectFaces(false); string text = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("SMOOTHMESHMAXFACE").ToString().Trim(); if (array.Length > Convert.ToInt32(text)) { throw new InvalidOperationException(string.Concat(new object[] { "\nERROR: you have selected ", array.Length.ToString(), " faces while an allowable maximum of ", text, " is specified in the SMOOTHMESHMAXFACE system variable. Please set the SMOOTHMESHMAXFACE system variable at least to ", array.Length, " or select fewer faces." })); } CMD_FacesToMesh.string_0 = CommandLineQuerries.KeywordYesNo("Delete original faces", CMD_FacesToMesh.string_0, false, false); List <Triangle> triangles = Conversions.ToCeometricAcDbTriangleList(array); List <List <Triangle> > list = this.method_0(triangles); for (int i = 0; i < list.Count; i++) { SubDMeshHandler subDMeshHandler = new SubDMeshHandler(list[i]); SubDMeshHandler.MeshGenerationResult meshGenerationResult = subDMeshHandler.GenerateSubDMesh(); editor.WriteMessage("\nMesh " + i.ToString().PadLeft(4) + ":\n" + meshGenerationResult.ToString()); } if (CMD_FacesToMesh.string_0 == "Y") { DBManager.EraseObjects(array, 100000); } } } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
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 DevelopmentCommand() { Database arg_05_0 = HostApplicationServices.WorkingDatabase; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); ObjectId[] objectId_ = CommandLineQuerries.SelectLines(false); CMD_ReconstructSurface.string_0 = CommandLineQuerries.InsertOnLayer_Current_Line(CMD_ReconstructSurface.string_0); CMD_ReconstructSurface.string_1 = CommandLineQuerries.SpecifyOutputType(CMD_ReconstructSurface.string_1); CMD_ReconstructSurface.int_0 = CommandLineQuerries.SpecifyInteger("Specify number of relevant decimal digits", CMD_ReconstructSurface.int_0, 0, 12, false, true); this.Reconstruct(objectId_); } catch (System.Exception ex) { editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine); } }
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 LinesToPolylines() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Database arg_15_0 = HostApplicationServices.WorkingDatabase; try { //LicenseManager.CheckValid("FULL"); ObjectId[] objectId_ = CommandLineQuerries.SelectLines(false); PLine.int_0 = CommandLineQuerries.SpecifyInteger("Specify number of relevant decimal digits", PLine.int_0, 0, 12, false, true); PLine.string_1 = CommandLineQuerries.KeywordYesNo("Eliminate zero length segments", PLine.string_1, false, false); PLine.string_0 = CommandLineQuerries.KeywordYesNo("Delete original lines", PLine.string_0, false, false); this.method_0(objectId_); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
public void LoadCommand() { Database arg_05_0 = HostApplicationServices.WorkingDatabase; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); ObjectId[] objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.SOLID3D, "Select 3d solids", false); double num = this.method_1(objectIDs); PromptDoubleOptions promptDoubleOptions = new PromptDoubleOptions("Maximum node spacing"); promptDoubleOptions.DefaultValue = (num / 100.0); double value = editor.GetDouble(promptDoubleOptions).Value; string text = CommandLineQuerries.KeywordYesNo("Show generated nodes", "N", false, false); PointSet pointSet = this.method_0(objectIDs, value); editor.WriteMessage("\n" + pointSet.Count + " points generated on solids."); ConvexHull3d convexHull3d = new ConvexHull3d(); convexHull3d.InitialPoints = pointSet; convexHull3d.ComputeHull(); BoundingBox boundingBox = convexHull3d.PrincipalAxesBoundingBox(); List <Triangle> surface = boundingBox.GetSurface(); if (text.Trim().ToUpper() == "Y") { DBManager.WriteListInDatabase <Point>(pointSet.ToList(), null, DBManager.EntityPropertiesAssignment.ByDialog, ObjectId.Null, ObjectId.Null); } DBManager.WriteListInDatabase <Triangle>(surface, null, DBManager.EntityPropertiesAssignment.ByDialog, ObjectId.Null, ObjectId.Null); editor.WriteMessage("\nPrincipal axes bounding box properties:"); editor.WriteMessage("\n---------------------------------------"); editor.WriteMessage("\nWidth : " + boundingBox.Width.ToString(DBManager.GetFormatFromLUPREC())); editor.WriteMessage("\nLength : " + boundingBox.Length.ToString(DBManager.GetFormatFromLUPREC())); editor.WriteMessage("\nHeight : " + boundingBox.Height.ToString(DBManager.GetFormatFromLUPREC())); editor.WriteMessage("\nVolume : " + boundingBox.Volume().ToString(DBManager.GetFormatFromLUPREC())); editor.WriteMessage("\nCenter : " + boundingBox.CoordinateSystem.Origin.ToString()); editor.WriteMessage("\nFirst basis vector : " + boundingBox.CoordinateSystem.BasisVector[0].ToString()); editor.WriteMessage("\nSecond basis vector: " + boundingBox.CoordinateSystem.BasisVector[1].ToString()); editor.WriteMessage("\nThird basis vector : " + boundingBox.CoordinateSystem.BasisVector[2].ToString()); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
public void moveText2interCmd() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; this.messageFilter_0 = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(this.messageFilter_0); try { PointSet pointSet = new PointSet(); ObjectId[] objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.TEXT, "选择点:", false); if (objectIDs != null) { Database workingDatabase = HostApplicationServices.WorkingDatabase; using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { for (int i = 0; i < objectIDs.Length; i++) { DBText text = (DBText)transaction.GetObject(objectIDs[i], OpenMode.ForWrite, true); Point3d newP = moveText2inter(text.Position); text.Position = newP; editor.WriteMessage("" + newP.X + newP.Y); } transaction.Commit(); } if (objectIDs.Length > 1) { } } else { editor.WriteMessage("没有选择到点.\n"); } } catch (System.Exception ex) { } }
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 scale() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; this.messageFilter_0 = new MessageFilter(); System.Windows.Forms.Application.AddMessageFilter(this.messageFilter_0); try { PointSet pointSet = new PointSet(); ObjectId[] objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.POINT, "选择点:", false); if (objectIDs != null) { Database workingDatabase = HostApplicationServices.WorkingDatabase; using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { for (int i = 0; i < objectIDs.Length; i++) { DBPoint dbPoint = (DBPoint)transaction.GetObject(objectIDs[i], OpenMode.ForWrite, true); dbPoint.Position = new Autodesk.AutoCAD.Geometry.Point3d(dbPoint.Position.X, dbPoint.Position.Y, dbPoint.Position.Z * 5); } transaction.Commit(); } string text = " triangulation point"; if (objectIDs.Length > 1) { text += "s"; } editor.WriteMessage(objectIDs.Length + text + " selected."); } else { editor.WriteMessage("没有选择到点.\n"); } } catch (System.Exception ex) { } }
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 TesselateCommand() { Database arg_05_0 = HostApplicationServices.WorkingDatabase; Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { //LicenseManager.CheckValid("FULL"); ObjectId[] objectIDs = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.SOLID3D, "Select 3d solids", false); double num = this.method_1(objectIDs); PromptDoubleOptions promptDoubleOptions = new PromptDoubleOptions("Maximum node spacing"); promptDoubleOptions.DefaultValue = (num / 100.0); double value = editor.GetDouble(promptDoubleOptions).Value; PointSet pointSet = this.method_0(objectIDs, value); editor.WriteMessage("\n" + pointSet.Count + " points generated on solids."); DBManager.WriteListInDatabase <Point>(pointSet.ToList(), null, DBManager.EntityPropertiesAssignment.ByDialog, ObjectId.Null, ObjectId.Null); } catch (System.Exception ex) { editor.WriteMessage("\n" + ex.Message); } }
public void InstallLicenseCommand() { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { CommandLineQuerries.SpecifyFileNameForRead(ref LicenseManager.string_0, "license"); if (!File.Exists(LicenseManager.string_0)) { editor.WriteMessage("\n" + LicenseManager.string_0 + " does not exist."); } else { Reg.SetComputationalCADRegistryValue("LICENSEFILE", LicenseManager.string_0); LicenseManager.Initialize(); } } catch (System.Exception ex) { 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 tri2() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; PointSet ps = PreProcess.getPointFromText(mydb.tcSetting.Scale); ObjectId[] ids = PreProcess.getAllLines(); List <Constraint> boundary = new List <Constraint>(); //int plCount = 0; ObjectId[] objectIDs3 = CommandLineQuerries.GetObjectIDs(CommandLineQuerries.EntityType.PLINES, "Select boundaries (polylines)", false); if (objectIDs3 != null) { string text3 = " boundary"; if (objectIDs3.Length > 1) { text3 += "s"; } //editor.WriteMessage(objectIDs3.Length + text3 + " selected."); //plCount = this.getPolylineCount(objectIDs3); List <Edge> list4 = Conversions.ToCeometricEdgeList(objectIDs3); for (int j = 0; j < list4.Count; j++) { boundary.Add(new Constraint(list4[j], Constraint.ConstraintType.Boundary)); } } else { //editor.WriteMessage("No boundaries selected.\n"); } Triangulate tri = new Triangulate(); //tri.TriangulateInternal(ps, new List<Constraint>(), new List<Constraint>()); tri.TriangulateInternal(ps, new List <Constraint>(), boundary, null); }
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 static ObjectId[] GetObjectIDs(CommandLineQuerries.EntityType type, string layerName) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; if (layerName == null || layerName == "") { layerName = "*"; } TypedValue[] array = new TypedValue[0]; switch (type) { case CommandLineQuerries.EntityType.Region: array = new TypedValue[] { new TypedValue(-4, "<or"), new TypedValue(-4, "<and"), new TypedValue((int)DxfCode.LayerName, layerName), new TypedValue((int)DxfCode.Start, "REGION"), new TypedValue(-4, "and>"), new TypedValue(-4, "or>") }; break; case CommandLineQuerries.EntityType.FACE: array = new TypedValue[] { new TypedValue(-4, "<or"), new TypedValue(-4, "<and"), new TypedValue((int)DxfCode.LayerName, layerName), new TypedValue(0, "3DFACE"), new TypedValue(-4, "and>"), new TypedValue(-4, "or>") }; break; case CommandLineQuerries.EntityType.PLINES: array = new TypedValue[] { new TypedValue(-4, "<or"), new TypedValue(-4, "<and"), new TypedValue((int)DxfCode.LayerName, layerName), new TypedValue(-4, "<or"), new TypedValue(0, "POLYLINE2D"), new TypedValue(0, "POLYLINE3D"), new TypedValue(0, "POLYLINE"), new TypedValue(-4, "or>"), new TypedValue(-4, "and>"), new TypedValue(-4, "or>") }; break; } PromptSelectionResult selection = editor.SelectAll(new SelectionFilter(array)); if (selection.Status == (PromptStatus.Cancel)) { CommandLineQuerries.OnCancelled(); } if (selection.Status != PromptStatus.OK) { return(null); } return(selection.Value.GetObjectIds()); }
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(); } }
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); } }