找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 679|回复: 0

[VBA程序]:如何往“块对象”里面增加尺寸实体。

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-9-27 17:55:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
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.

  1. [FONT=courier new]
  2. Sub f_SolAddDiminBlocks()
  3. 'Workaround for Adding dimensions to block AutoCAD 2000.
  4. Dim po_rotDim As AcadDimAligned
  5. Dim po_block As AcadBlock
  6. Dim pd_ext1(0 To 2) As Double
  7. Dim pd_ext2(0 To 2) As Double
  8. Dim pd_lineLoc(0 To 2) As Double
  9. Dim po_array(0) As Object

  10. pd_ext1(0) = 3: pd_ext1(1) = 3: pd_ext1(2) = 0
  11. pd_ext2(0) = 10: pd_ext2(1) = 3: pd_ext2(2) = 0
  12. pd_lineLoc(0) = 5: pd_lineLoc(1) = 4: pd_lineLoc(2) = 0
  13. 'create dimeionsion object
  14. Set po_rotDim = ThisDrawing.ModelSpace.AddDimAligned(pd_ext1, pd_ext2,
  15. pd_lineLoc)

  16. 'create a new block by name test
  17. Set po_block = ThisDrawing.Blocks.Add(pd_ext1, "test")
  18. 'insert a block reference
  19. ThisDrawing.ModelSpace.InsertBlock pd_ext1, "test", 1, 1, 1, 0

  20. 'copy dimension object
  21. Set po_array(0) = po_rotDim
  22. ThisDrawing.CopyObjects po_array, po_block
  23. po_rotDim.Delete

  24. 'release the references
  25. Set po_block = Nothing
  26. Set po_rotDim = Nothing
  27. End Sub[/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-5 13:31 , Processed in 0.155974 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表