public static LineDrawingObject Create(Database target, Point3d startPoint, Point3d endPoint)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            if (startPoint == null)
            {
                throw new ArgumentNullException(nameof(startPoint));
            }

            if (endPoint == null)
            {
                throw new ArgumentNullException(nameof(endPoint));
            }

            LineDrawingObject newLineDrawingObject = new LineDrawingObject();

            Transaction      trans  = target.TransactionManager.TopTransaction;
            BlockTableRecord record = (BlockTableRecord)trans.GetObject(target.CurrentSpaceId, OpenMode.ForWrite);

            using (Line acLine = new Line(startPoint, endPoint))
            {
                // Add the new object to the block table record and the transaction
                newLineDrawingObject.BaseObject = record.AppendEntity(acLine);
                trans.AddNewlyCreatedDBObject(acLine, true);
            }

            return(newLineDrawingObject);
        }
Beispiel #2
0
        public static LineDrawingObject Create(Database target, Point3d startPoint, Point3d endPoint)
        {
            LineDrawingObject newLineDrawingObject = new LineDrawingObject();

            Transaction      trans  = target.TransactionManager.TopTransaction;
            BlockTableRecord record = (BlockTableRecord)trans.GetObject(target.CurrentSpaceId, OpenMode.ForWrite);

            Line acLine = new Line(startPoint, endPoint);

            // Add the new object to the block table record and the transaction
            newLineDrawingObject.BaseObject = record.AppendEntity(acLine);
            trans.AddNewlyCreatedDBObject(acLine, true);

            return(newLineDrawingObject);
        }