无名块插入的程序,错在哪?- Sub Example_InsertBlock()
- ' This example creates a block containing a circle.
- ' It then inserts the block
- ' Create the block
- Dim blockObj As AcadBlock
- Dim insertionPnt(0 To 2) As Double
- insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
- Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "*u")
- ' Add a circle to the block
- Dim circleObj As AcadCircle
- Dim center(0 To 2) As Double
- Dim radius As Double
- center(0) = 0: center(1) = 0: center(2) = 0
- radius = 1
- Set circleObj = blockObj.AddCircle(center, radius)
- ' This example creates an attribute definition in model space.
- Dim attributeObj As AcadAttribute
- Dim height As Double
- Dim mode As Long
- Dim prompt As String
- Dim insertionPoint(0 To 2) As Double
- Dim tag As String
- Dim value As String
- ' Define the attribute definition
- height = 1#
- mode = acAttributeModeVerify
- prompt = "New Prompt"
- insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0
- tag = "New Tag"
- value = "New Value"
- ' Create the attribute definition object in model space
- Set attributeObj = blockObj.AddAttribute(height, mode, prompt, insertionPoint, tag, value)
- ' Insert the block
- Dim i As Long
- i = 0&
- Dim scaX As Double
- Dim scaY As Double
- Dim scaZ As Double
- scaX = 1#
- scaY = 1#
- scaZ = 1#
- Dim strname As String
- Dim strname1 As String
- Dim blockRefObj As AcadBlockReference
- For i = 1& To 10&
- scaX = scaX + i
- scaY = scaY + i
- scaZ = scaZ + i
- strname1 = Format(i, "")
- strname = "*u"
- MsgBox strname1
- strname = strname + strname1
- MsgBox strname
- insertionPnt(0) = 2# + i
- insertionPnt(1) = 2# + i
- insertionPnt(2) = 0#
- Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, strname, scaX, scaY, scaZ, 0)
- Next i
- ZoomAll
- End Sub
|