Example #1
0
        public static List <Triangle> ToCeometricCADDataTriangleList(ObjectId[] faceIDs)
        {
            Database        workingDatabase = HostApplicationServices.WorkingDatabase;
            List <Triangle> list            = new List <Triangle>();

            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                string     blockModelSpaceName = SymbolUtilityServices.BlockModelSpaceName;
                LayerTable arg_30_0            = (LayerTable)transaction.GetObject(workingDatabase.LayerTableId, (OpenMode)0);
                for (int i = 0; i < faceIDs.Length; i++)
                {
                    Autodesk.AutoCAD.DatabaseServices.Face face = (Autodesk.AutoCAD.DatabaseServices.Face)transaction.GetObject(faceIDs[i], (OpenMode)0, true);
                    LayerTableRecord layerTableRecord           = (LayerTableRecord)transaction.GetObject(face.LayerId, (OpenMode)0);
                    Autodesk.AutoCAD.Colors.Color color         = face.Color;
                    if (color.IsByLayer)
                    {
                        color = layerTableRecord.Color;
                    }
                    System.Drawing.Color empty = System.Drawing.Color.Empty;
                    short colorIndex           = 256;
                    Conversions.GetColors(color, ref empty, ref colorIndex);
                    CADData cADData = new CADData();
                    cADData.Layer.Name = layerTableRecord.Name;
                    cADData.Color      = empty;
                    cADData.ColorIndex = colorIndex;
                    cADData.BlockName  = blockModelSpaceName;
                    Point3d vertexAt  = face.GetVertexAt(0);
                    Point3d vertexAt2 = face.GetVertexAt(1);
                    Point3d vertexAt3 = face.GetVertexAt(2);
                    Point3d vertexAt4 = face.GetVertexAt(3);
                    ngeometry.VectorGeometry.Point point  = new ngeometry.VectorGeometry.Point(vertexAt.X, vertexAt.Y, vertexAt.Z);
                    ngeometry.VectorGeometry.Point point2 = new ngeometry.VectorGeometry.Point(vertexAt2.X, vertexAt2.Y, vertexAt2.Z);
                    ngeometry.VectorGeometry.Point point3 = new ngeometry.VectorGeometry.Point(vertexAt3.X, vertexAt3.Y, vertexAt3.Z);
                    ngeometry.VectorGeometry.Point point4 = new ngeometry.VectorGeometry.Point(vertexAt4.X, vertexAt4.Y, vertexAt4.Z);
                    if (point != point2 && point != point3 && point != point4 && point2 != point3 && point2 != point4 && point3 != point4)
                    {
                        list.Add(new Triangle(point, point2, point4, false)
                        {
                            CADData = cADData
                        });
                        list.Add(new Triangle(point2, point3, point4, false)
                        {
                            CADData = cADData
                        });
                    }
                    else
                    {
                        list.Add(new Triangle(point, point2, point3, false)
                        {
                            CADData = cADData
                        });
                    }
                }
            }
            return(list);
        }
Example #2
0
        public static List <Edge> ToCeometricCADDataEdgeList(ObjectId[] lineIDs)
        {
            Database    workingDatabase = HostApplicationServices.WorkingDatabase;
            List <Edge> list            = new List <Edge>();

            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                string     blockModelSpaceName = SymbolUtilityServices.BlockModelSpaceName;
                LayerTable arg_30_0            = (LayerTable)transaction.GetObject(workingDatabase.LayerTableId, (OpenMode)0);
                for (int i = 0; i < lineIDs.Length; i++)
                {
                    Autodesk.AutoCAD.DatabaseServices.Line line = (Autodesk.AutoCAD.DatabaseServices.Line)transaction.GetObject(lineIDs[i], (OpenMode)0, true);
                    LayerTableRecord layerTableRecord           = (LayerTableRecord)transaction.GetObject(line.LayerId, (OpenMode)0);
                    Autodesk.AutoCAD.Colors.Color color         = line.Color;
                    if (color.IsByLayer)
                    {
                        color = layerTableRecord.Color;
                    }
                    System.Drawing.Color empty = System.Drawing.Color.Empty;
                    short colorIndex           = 256;
                    Conversions.GetColors(color, ref empty, ref colorIndex);
                    CADData cADData = new CADData();
                    cADData.Layer.Name = layerTableRecord.Name;
                    cADData.Color      = empty;
                    cADData.ColorIndex = colorIndex;
                    cADData.BlockName  = blockModelSpaceName;
                    Point3d startPoint = line.StartPoint;
                    Point3d endPoint   = line.EndPoint;
                    ngeometry.VectorGeometry.Point startPoint2 = new ngeometry.VectorGeometry.Point(startPoint.X, startPoint.Y, startPoint.Z);
                    ngeometry.VectorGeometry.Point endPoint2   = new ngeometry.VectorGeometry.Point(endPoint.X, endPoint.Y, endPoint.Z);
                    list.Add(new Edge(startPoint2, endPoint2)
                    {
                        CADData = cADData
                    });
                }
            }
            return(list);
        }
Example #3
0
        public static PointSet ToCeometricCADDataPointList(ObjectId[] pointIDs)
        {
            Database workingDatabase = HostApplicationServices.WorkingDatabase;
            PointSet pointSet        = new PointSet();

            using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
            {
                string     blockModelSpaceName = SymbolUtilityServices.BlockModelSpaceName;
                LayerTable arg_30_0            = (LayerTable)transaction.GetObject(workingDatabase.LayerTableId, (OpenMode)0);
                for (int i = 0; i < pointIDs.Length; i++)
                {
                    DBPoint          dBPoint            = (DBPoint)transaction.GetObject(pointIDs[i], (OpenMode)0, true);
                    LayerTableRecord layerTableRecord   = (LayerTableRecord)transaction.GetObject(dBPoint.LayerId, (OpenMode)0);
                    Autodesk.AutoCAD.Colors.Color color = dBPoint.Color;
                    if (color.IsByLayer)
                    {
                        color = layerTableRecord.Color;
                    }
                    System.Drawing.Color empty = System.Drawing.Color.Empty;
                    short colorIndex           = 256;
                    Conversions.GetColors(color, ref empty, ref colorIndex);
                    CADData cADData = new CADData();
                    cADData.Layer.Name = layerTableRecord.Name;
                    cADData.Color      = empty;
                    cADData.ColorIndex = colorIndex;
                    cADData.BlockName  = blockModelSpaceName;
                    double x = dBPoint.Position.X;
                    double y = dBPoint.Position.Y;
                    double z = dBPoint.Position.Z;
                    pointSet.Add(new ngeometry.VectorGeometry.Point(x, y, z)
                    {
                        CADData = cADData
                    });
                }
            }
            return(pointSet);
        }