<CommandMethod("Test")> _
Public Sub RotatedDimension()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim idDim As ObjectId = ObjectId.Null
Dim Ent As Entity
Dim x As Double
Using myTrans As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = myTrans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim btr As BlockTableRecord = myTrans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
''выбираем существующий размер
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ss As Autodesk.AutoCAD.EditorInput.SelectionSet = doc.Editor.GetSelection().Value
For Each id As ObjectId In ss.GetObjectIds()
Ent = myTrans.GetObject(id, OpenMode.ForRead, True)
If TypeOf Ent Is RotatedDimension Then
x = Ent.Bounds.Value.MinPoint.X ''''' обращаемся к свойству Bounds - работает прекрасно
End If
Next id
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' создаем размер
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim RotDim As RotatedDimension = New RotatedDimension()
RotDim.SetDatabaseDefaults(db)
RotDim.DimensionStyle = db.Dimstyle
RotDim.XLine1Point = New Point3d(0, 0, 0)
RotDim.XLine2Point = New Point3d(50, 0, 0)
RotDim.Rotation = 0
RotDim.DimLinePoint = New Point3d(25, 10, 0)
idDim = btr.AppendEntity(RotDim)
myTrans.AddNewlyCreatedDBObject(RotDim, True)
'x = RotDim.Bounds.Value.MinPoint.X ''''' обращаемся к свойству Bounds - не работает
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
myTrans.Commit()
End Using
' В другой транзакции получаем габариты размеров
Using myTrans As Transaction = db.TransactionManager.StartTransaction()
Ent = myTrans.GetObject(idDim, OpenMode.ForRead, True)
Dim x1 As Double = Ent.Bounds.Value.MinPoint.X
Dim x2 As Double = Ent.Bounds.Value.MaxPoint.X
myTrans.Commit()
End Using
End Sub