Example #1
0
        public AcBlockRef AddBlockRef(Point3d pos, AcTransaction trans)
        {
            //Create the block reference...
            var blockRef = new BlockReference(pos, this.ObjectId);

            blockRef.SetDatabaseDefaults(); // Default/Active layer, color, ...
            trans.AddEntity(blockRef);      // Do it before blockRef.AttributeCollection.AppendAttribute(attRef);

            var attrRefs = new List <AttributeReference>();

            foreach (var attrDef in this.Attributes)
            {
                // this BlockDef could be initialized throught other (closed) Transaction, the same with this.Attributes
                var attDefObj = attrDef.GetAcObject(trans); // trans.GetObject<AttributeDefinition>(attrDef.ObjectId); //  attrDef.AcObject;
                var attRef    = new AttributeReference();
                attRef.SetAttributeFromBlock(attDefObj, blockRef.BlockTransform);
                attRef.SetDatabaseDefaults();

                if (!attDefObj.Constant)
                {
                    attRef.TextString = attDefObj.TextString;
                }

                blockRef.AttributeCollection.AppendAttribute(attRef);
                trans.AddNewlyCreatedDBObject(attRef, true);
                attrRefs.Add(attRef);
            }

            return(new AcBlockRef(blockRef, trans, attrRefs));
        }
Example #2
0
        public static DBText AddText(this AcTransaction trans, Point3d pos, string text)
        {
            DBText txt = new DBText();

            txt.Position   = pos;
            txt.TextString = text;
            trans.AddEntity(txt);

            return(txt);
        }
Example #3
0
        public static ObjectId AddCircle(this AcTransaction trans, Point3d center, double radius)
        {
            Vector3d normal = new Vector3d(0.0, 0.0, 1.0);

            return(trans.AddEntity(new Circle(center, normal, radius)));
        }
Example #4
0
 public static ObjectId AddLine(this AcTransaction trans, Point3d startPnt, Point3d endPnt)
 {
     return(trans.AddEntity(new Line(startPnt, endPnt)));
 }