马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
How to add dimension entities to a block object?
ID 48357
Applies to: AutoCAD 2000
This document is part of Dimensions Block Reference COM-ActiveX Interfaces VBA
Question
The AddDimAligned method of Block object produces incorrect dimension objects.
How can I add dimension entities to a Block object?
Answer
The AddDimAligned method as well as other AddDimxxx methods of adding dimension
entities to a Block object results in dimension objects that are incorrect.
This is a known problem. Use the following workaround to add dimension entities
to a block object:
1. Create a Dimension entity in model space.
2. Use the CopyObject method to copy the Dimension entity to a Block object.
3. Delete the original Dimension entity from model space.
The following sample code creates a block "test", adds a DimRotated entity to
the block, and then inserts the block into model space.

- [FONT=courier new]
- Sub f_SolAddDiminBlocks()
- 'Workaround for Adding dimensions to block AutoCAD 2000.
- Dim po_rotDim As AcadDimAligned
- Dim po_block As AcadBlock
- Dim pd_ext1(0 To 2) As Double
- Dim pd_ext2(0 To 2) As Double
- Dim pd_lineLoc(0 To 2) As Double
- Dim po_array(0) As Object
- pd_ext1(0) = 3: pd_ext1(1) = 3: pd_ext1(2) = 0
- pd_ext2(0) = 10: pd_ext2(1) = 3: pd_ext2(2) = 0
- pd_lineLoc(0) = 5: pd_lineLoc(1) = 4: pd_lineLoc(2) = 0
- 'create dimeionsion object
- Set po_rotDim = ThisDrawing.ModelSpace.AddDimAligned(pd_ext1, pd_ext2,
- pd_lineLoc)
- 'create a new block by name test
- Set po_block = ThisDrawing.Blocks.Add(pd_ext1, "test")
- 'insert a block reference
- ThisDrawing.ModelSpace.InsertBlock pd_ext1, "test", 1, 1, 1, 0
- 'copy dimension object
- Set po_array(0) = po_rotDim
- ThisDrawing.CopyObjects po_array, po_block
- po_rotDim.Delete
- 'release the references
- Set po_block = Nothing
- Set po_rotDim = Nothing
- End Sub[/FONT]
|