예제 #1
0
        public SubDMeshHandler.MeshGenerationResult GenerateSubDMesh()
        {
            if (this.list_4 == null)
            {
                throw new InvalidOperationException("Can not start SubDMesh handler: no triangles defined.");
            }
            if (this.list_4.Count < 1)
            {
                return(new SubDMeshHandler.MeshGenerationResult());
            }
            Database workingDatabase = HostApplicationServices.WorkingDatabase;
            Editor   arg_3C_0        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            SubDMeshHandler.MeshGenerationResult result;
            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                this.BuildDataStructure(true);
                Point3dCollection point3dCollection = new Point3dCollection();
                for (int i = 0; i < this.list_0.Count; i++)
                {
                    point3dCollection.Add(new Point3d(this.list_0[i].X, this.list_0[i].Y, this.list_0[i].Z));
                }
                Int32Collection int32Collection = new Int32Collection(3 * this.list_4.Count);
                for (int j = 0; j < this.list_4.Count; j++)
                {
                    int32Collection.Add(3);
                    int32Collection.Add(this.list_1[j]);
                    int32Collection.Add(this.list_2[j]);
                    int32Collection.Add(this.list_3[j]);
                }
                SubDMesh subDMesh = new SubDMesh();
                subDMesh.SetDatabaseDefaults();
                subDMesh.SetSubDMesh(point3dCollection, int32Collection, 0);
                subDMesh.SetPropertiesFrom(this.list_4[0].AcDbFace);
                BlockTable       blockTable       = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                blockTableRecord.AppendEntity(subDMesh);
                transaction.AddNewlyCreatedDBObject(subDMesh, true);
                transaction.Commit();
                result = new SubDMeshHandler.MeshGenerationResult
                {
                    objectId_0 = subDMesh.ObjectId,
                    int_0      = this.list_0.Count,
                    int_1      = this.list_4.Count,
                    string_0   = DBManager.GetLayerName(subDMesh.LayerId)
                };
            }
            return(result);
        }
예제 #2
0
        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);
            }
        }