我想用VB实现从一个文件中,让用户选择需要的对象后,再复制到另一个文件中去,代码如下:
Dim SelectExist As Boolean
Dim SelectionSet1 As Object
Dim DocSave As Object '建立新的Document对象
Dim MoSpaceSave As Object '建立新的Model Space 对象
Dim retObjects As Variant
Cnt = acaddoc.SelectionSets.Count - 1
SelectExist = False
For i = 0 To Cnt
If acaddoc.SelectionSets.Item(i).Name = "SavSelect" Then
Set SelectionSet1 = acaddoc.SelectionSets.Item(i)
SelectionSet1.Clear '清空该选择集,其不包含任何对象
SelectExist = True
Exit For
End If
Next
If Not SelectExist Then
Set SelectionSet1 = acaddoc.SelectionSets.Add("SavSelect")
End If
SelectionSet1.SelectOnScreen
Set DocSave = acadapp.Documents.Add '新增图形文件
DocSave.Activate '使新增文件为当前活动图形文件
Set MoSpaceSave = DocSave.ModelSpace '设MoSpaceSave为当前图形文件的模型空间