马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
How to create/insert a block using pure ActiveX/VBA code
ID 47502
Applies to: AutoCAD 2000
This document is part of Block Reference COM-ActiveX Interfaces VBA
Question
How should I use the AutoCAD ActiveX Automation API to create a block and insert
it into model space?
Answer
The sequence of the block creation process in ActiveX is to add an AcadBlock
object to the AcadBlocks collection, then you add an AcadCircle, such as to the
AcadBlock. Note that you can add as many objects as you like to the AcadBlock.
When done, call InsertBlock() method to insert it into a particular space, such
as model space. The following example illustrates this:
- [FONT=courier new]
- Sub createInsertBlock()
- Dim blk As AcadBlock
- Dim pt(0 To 2) As Double
- Dim cir As AcadCircle
- Dim ctr(0 To 2) As Double
- Const blkName = "test"
-
- Set blk = ThisDrawing.Blocks.Add(pt, blkName)
- ctr(0) = 2: ctr(1) = 2
-
- Set cir = blk.AddCircle(ctr, 1.5)
-
- ThisDrawing.ModelSpace.InsertBlock pt, blkName, 1, 1, 1, 0
- End Sub[/FONT]
|