- 积分
- 4121
- 明经币
- 个
- 注册时间
- 2016-12-9
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2018-7-10 09:00:48
|
显示全部楼层
下面是一段VB代码,请参考!
Dim NoNamBlo As Object
Dim BasePnt As Variant
Dim Ent() As Object
Dim ownName As String
Dim ret As Variant
On Error Resume Next
Set sset = acadapp.ActiveDocument.SelectionSets.Item("ss1")
sset.Delete
Set sset = acadapp.ActiveDocument.SelectionSets.Add("ss1")
AppActivate acadapp.Caption
acadapp.ActiveDocument.Utility.Prompt "请选择要建立块的对象"
sset.SelectOnScreen
If CheckKey(VK_ESCAPE) = True Then
Exit Sub
End If
BasePnt = acadapp.ActiveDocument.Utility.GetPoint(, "请拾取块基点")
If CheckKey(VK_ESCAPE) = True Then
Exit Sub
End If
Set NoNamBlo = acadapp.ActiveDocument.Blocks.Add(BasePnt, "*u")
ownName = NoNamBlo.Name
ReDim Ent(sset.Count - 1)
For i = 0 To sset.Count - 1
Set Ent(i) = sset.Item(i)
Next
acadapp.ActiveDocument.CopyObjects Ent, NoNamBlo
sset.Erase
sset.Delete
acadapp.ActiveDocument.ModelSpace.InsertBlock BasePnt, ownName, 1, 1, 1, 0
acadapp.ActiveDocument.Utility.Prompt "块建立完成!块名称是:" & ownName & vbLf |
|