Block
Previous Topic  Next Topic 

 

 

         sdBlocks

 

Block is a collection of entities that can be associated together to form a single entity or block definition.

The Block(sdBlock) entity can be inserted into the drawing by assigning the block to the Insert(sdInsert) entity. After the block is assigned to the Insert entity, it can be scaled and rotated. The block entity can be exploded into its component entities.In SeeDraw, the sdBlock entity is created and store into a block collection called Blocks.

 

       private void Block()

        {     

             // Create a text

            sdText t = fDrawCtrl1.Document.AddText("text"new Point3D(0, 0, 0), 10);

            // Create a circle.

            sdCircle cir = fDrawCtrl1.Document.AddCircle(new Point3D(10, 0, 0), 10);

            // Create a line

            sdLine line = fDrawCtrl1.Document.AddLine(new Point3D(10, 10, 0), new Point3D(20, 10, 0));

            // Create a line

            sdLine line2 = fDrawCtrl1.Document.AddLine(new Point3D(15, 5, 0), new Point3D(15, 20, 0));

            // Create a Dimension.

            sdDimRotated dim = fDrawCtrl1.Document.AddDimensionRotated(new Point3D(0, 0, 0), new Point3D(10, 0, 0), new Point3D(5, 0, 0), 0);

 

            // Create a line

            sdLine line1 = fDrawCtrl1.Document.AddLine(new Point3D(15, 0, 0), new Point3D(15, 20, 0));

            // Create an Ellipse

            sdEllipse el = fDrawCtrl1.Document.AddEllipse(new Point3D(0, 0, 0), 30, 45, 30);

 

            string tmp = @"\P{\fTimes New Roman|b0|i0|c0|p18;MCM\P\PASSOCIATES}";

 

            // Create MText 

            sdMText mtext = fDrawCtrl1.Document.AddMText(tmp, new Point3D(0, 50, 0), 1);

 

            // Create a sdBase List.

            List<sdBase> m_selection = new List<sdBase>();

 

            // Add all the entities into a list.

            m_selection.Add(line1);

            m_selection.Add(dim);

            m_selection.Add(line);

            m_selection.Add(line2);

            m_selection.Add(t);

            m_selection.Add(cir);

            m_selection.Add(mtext);

            m_selection.Add(el);

 

            // If a block entity is created successfully, a block instance will be return and assign to pBlock.

            sdBlock pBlock = fDrawCtrl1.Document.AddBlock(m_selection, "testing"new Point3D(0, 0, 0), AddBlockType.delete);

 

            if (pBlock != null)

            {

                // If pBlock is not null, assign it to sdInsert object and add the sdInsert into the Entities collection.

                sdInsert ins = fDrawCtrl1.Document.AddInsert(pBlock);

                // Regenerate sdInsert object.

                ins.RegenAll();

            }

        }