Exemplo n.º 1
0
 public void Generate(Document doc, GateParameter gatePara)
 {
     try
     {
         ObjectId null5   = ObjectId.Null;
         ObjectId null7   = ObjectId.Null;
         ObjectId null9   = ObjectId.Null;
         ObjectId null11  = ObjectId.Null;
         Vector3d vector3 = gatePara.GateHeight * Vector3d.YAxis;
         Vector3d vector2 = gatePara.GateWidth * Vector3d.XAxis;
         using (Transaction transaction = doc.Database.TransactionManager.StartTransaction())
         {
             null5  = DBHelper.InsertBlockRefByDWGFile(doc, transaction, new Constants().DWG_CORNER_PATH, oPoint, null, gatePara.LCornerBlockName);
             null7  = DBHelper.InsertBlockRefByDWGFile(doc, transaction, new Constants().DWG_CORNER_PATH, oPoint + vector2, null, gatePara.RCornerBlockName);
             null9  = DBHelper.InsertBlockRefByDWGFile(doc, transaction, new Constants().DWG_CORNER_PATH, oPoint + vector3, null, gatePara.LUCornerBlockName);
             null11 = DBHelper.InsertBlockRefByDWGFile(doc, transaction, new Constants().DWG_CORNER_PATH, oPoint + vector3 + vector2, null, gatePara.RUCornerBlockName);
             Entity en7   = transaction.GetObject(null5, OpenMode.ForRead) as Entity;
             Entity en6   = transaction.GetObject(null9, OpenMode.ForRead) as Entity;
             Entity en5   = transaction.GetObject(null7, OpenMode.ForRead) as Entity;
             Entity en4   = transaction.GetObject(null11, OpenMode.ForRead) as Entity;
             Line   line7 = new Line(oPoint, oPoint + vector3);
             Line   line6 = new Line(oPoint + vector2, oPoint + vector2 + vector3);
             Line   line5 = new Line(oPoint, oPoint + vector2);
             Line   line4 = new Line(oPoint + vector3, oPoint + vector2 + vector3);
             CutLineStart(en7, ref line7);
             CutLineEnd(en6, ref line7);
             CutLineStart(en5, ref line6);
             CutLineEnd(en4, ref line6);
             CutLineStartX(en7, ref line5);
             CutLineEndX(en5, ref line5);
             CutLineStartX(en6, ref line4);
             CutLineEndX(en4, ref line4);
             line7.Color = Color.FromRgb(255, 0, 0);
             line6.Color = Color.FromRgb(255, 0, 0);
             line5.Color = Color.FromRgb(255, 0, 0);
             line4.Color = Color.FromRgb(255, 0, 0);
             line7.ToSpace(doc.Database);
             line6.ToSpace(doc.Database);
             line5.ToSpace(doc.Database);
             line4.ToSpace(doc.Database);
             transaction.Commit();
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Exemplo n.º 2
0
    public void Generate(Document doc, GateParameter gatePara)
    {
        double rectangleMinX = gatePara.RectangleMinX;
        double rectangleMinY = gatePara.RectangleMinY;
        double rectangleMaxX = gatePara.RectangleMaxX;
        double rectangleMaxY = gatePara.RectangleMaxY;

        using (Transaction transaction = doc.Database.TransactionManager.StartTransaction())
        {
            Polyline polyline = new Polyline();
            polyline.AddVertexAt(polyline.NumberOfVertices, new Point2d(rectangleMinX, rectangleMinY), 0.0, 0.0, 0.0);
            polyline.AddVertexAt(polyline.NumberOfVertices, new Point2d(rectangleMaxX, rectangleMinY), 0.0, 0.0, 0.0);
            polyline.AddVertexAt(polyline.NumberOfVertices, new Point2d(rectangleMaxX, rectangleMaxY), 0.0, 0.0, 0.0);
            polyline.AddVertexAt(polyline.NumberOfVertices, new Point2d(rectangleMinY, rectangleMaxY), 0.0, 0.0, 0.0);
            polyline.Closed = true;
            polyline.Color  = Color.FromRgb(0, 255, 0);
            polyline.ToSpace(doc.Database);
            transaction.Commit();
        }
    }
Exemplo n.º 3
0
        public void Generate(Document doc, GateParameter gatePara)
        {
            double borderBaseX = gatePara.BorderBaseX;
            double borderBaseY = gatePara.BorderBaseY;
            double w           = gatePara.BorderWidth;
            double h           = gatePara.BorderHeight;

            using (Transaction transaction = doc.Database.TransactionManager.StartTransaction())
            {
                Polyline polyline = new Polyline();
                polyline.AddVertexAt(polyline.NumberOfVertices, new Point2d(borderBaseX, borderBaseY), 0.0, 0.0, 0.0);
                polyline.AddVertexAt(polyline.NumberOfVertices, new Point2d(borderBaseX + w, borderBaseY), 0.0, 0.0, 0.0);
                polyline.AddVertexAt(polyline.NumberOfVertices, new Point2d(borderBaseX + w, borderBaseY + h), 0.0, 0.0, 0.0);
                polyline.AddVertexAt(polyline.NumberOfVertices, new Point2d(borderBaseX, borderBaseY + h), 0.0, 0.0, 0.0);
                polyline.Closed  = true;
                polyline.LayerId = DBHelper.AddLayer(doc.Database, new Constants().BorderlayerName);
                polyline.ToSpace(doc.Database);
                transaction.Commit();
            }
        }
Exemplo n.º 4
0
 public void Generate(Document doc, GateParameter gatePara)
 {
     try
     {
         using (var trans = doc.Database.TransactionManager.StartTransaction())
         {
             if (string.IsNullOrEmpty(gatePara.FitXoffset) || string.IsNullOrEmpty(gatePara.FitYoffse))
             {
                 return;
             }
             var mtx = Matrix3d.Displacement(new Vector3d(gatePara.FitXoffset.StringToDouble(), gatePara.FitYoffse.StringToDouble(), 0));
             DBHelper.InsertBlockRefByDWGFile(doc, trans, new Constants().DWG_BLOCK_PATH, Point3d.Origin, mtx, gatePara.FitBlockName);
             trans.Commit();
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }