<CommandMethod("Add_Line")>
        Public Shared Sub AddLine()
            Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim acCurDb As Database = acDoc.Database
            Dim Point1 As Point3d = GetPoint("Начальная точка")
            Dim Point2 As Point3d = GetPoint("Начало полки")
            Dim Point3 As Point3d = GetPoint("Направление полки")
            Dim Point4 As Point3d
            Dim Point5 As Point3d
            If Point2.X <= Point3.X Then
                Point4 = New Point3d(Point2.X + 9, Point2.Y, 0)
                Point5 = New Point3d(Point2.X + 4.5, Point2.Y, 0)
            ElseIf Point2.X > Point3.X Then
                Point4 = New Point3d(Point2.X - 9, Point2.Y, 0)
                Point5 = New Point3d(Point2.X - 4.5, Point2.Y, 0)
            End If
            Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
                Dim acBlkTbl As BlockTable
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
                Dim acBlkTblRec As BlockTableRecord
                acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                            OpenMode.ForWrite)
                Dim Line1 As Line = New Line(Point1, Point2)
                Line1.SetDatabaseDefaults()
                acBlkTblRec.AppendEntity(Line1)
                acTrans.AddNewlyCreatedDBObject(Line1, True)
                Dim Line2 As Line = New Line(Point2, Point4)
                Line2.SetDatabaseDefaults()
                acBlkTblRec.AppendEntity(Line2)
                acTrans.AddNewlyCreatedDBObject(Line2, True)
                acTrans.Commit()
            End Using
            Dim wtd As New fAddPosition
            wtd.AddPosition(Point5)
        End Sub
 
    Public Sub AddPosition(ipt As Point3d)
        Try
            If ipt = Nothing Then Exit Sub
            'Показываем форму для заполнения параметров. После ОК закрытия формы, вставляем блок и заполняем его параметры
            sQuants = ""
            Me.lblNaimLen.Text = "Символов: " & Len(Me.txtNaim.Text) & " (max - 250)"
            Me.ShowDialog()
            If Me.DialogResult <> Windows.Forms.DialogResult.OK Then Exit Sub
            'Вставляем позицию
            Dim extDB As New Database(False, True)
            Dim db As Database = HostApplicationServices.WorkingDatabase
            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
            Try
                If sMainDir.Length = 0 Then sMainDir = GetPrmFromIni("MAIN", "MAINDIR")
                Dim BlockFile As String = sMainDir & "\Base\xAsmPosLabel.dwg"
                extDB.ReadDwgFile(BlockFile, System.IO.FileShare.Read, True, "")
                Using tr As Transaction = extDB.TransactionManager.StartTransaction
                    Dim bt As BlockTable = tr.GetObject(extDB.BlockTableId, OpenMode.ForRead, False)
                    Dim blockIds As ObjectIdCollection = New ObjectIdCollection
                    blockIds.Add(bt.Item(BlockName))
                    Dim mapping As IdMapping = New IdMapping
                    extDB.WblockCloneObjects(blockIds, db.BlockTableId, mapping, DuplicateRecordCloning.Ignore, False)
                End Using
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                MsgBox(ex.Message & vbCr & ex.StackTrace)
                Exit Sub
            Finally
                extDB.CloseInput(True)
                extDB.Dispose()
            End Try
            Dim bref As BlockReference
            Using tr As Transaction = db.TransactionManager.StartTransaction
                Dim nScale As Double = Application.GetSystemVariable("DIMSCALE")
                Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
                Dim btr As BlockTableRecord = DirectCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, False), BlockTableRecord)
                Dim blk As BlockTableRecord = DirectCast(tr.GetObject(bt(BlockName), OpenMode.ForRead, False), BlockTableRecord)
                Dim blkId As ObjectId = blk.ObjectId
                bref = New BlockReference(ipt, blkId)
                bref.BlockUnit = UnitsValue.Millimeters
                bref.Rotation = 0
                bref.ScaleFactors = New Scale3d(nScale)
                btr.AppendEntity(bref)
                tr.AddNewlyCreatedDBObject(bref, True)
                AddEmptyAttributes(db, tr, bref)
                EditPosAttributes(db, tr, bref)
                ed.Regen()
                tr.Commit()
            End Using
        Catch ex As Autodesk.AutoCAD.Runtime.Exception
            MsgBox(ex.Message & vbCr & ex.StackTrace)
        End Try
    End Sub