- Dim blk As AcadBlockReference
- Private Sub CommandButton1_Click()
- '打开一个图幅
- If Len(Dir("E:\擦窗机总库\底架总成\180固定方管\513.8.dwg")) <> 0 Then
- ThisDrawing.Application.Documents.Open "E:\擦窗机总库\底架总成\180固定方管\513.8.dwg"
- '
- Else
- MsgBox "指定的文件不存在!"
- End If
- '选择该对应的主视图
- Dim filterType1(0 To 2) As Integer
- Dim filterData1(0 To 2) As Variant
- Dim ssetObj1 As AcadSelectionSet
- filterType1(0) = 2
- filterData1(0) = "180主视图"
- filterType1(1) = 100
- filterData1(1) = "AcDbBlockReference"
- Set ssetObj1 = CreateSelectionSet("180主视图")
- ssetObj1.SelectOnScreen filterType1, filterData1
-
- If ssetObj1.Count = 0 Then
- ThisDrawing.Utility.Prompt "用户取消放置状态,退出" & vbCrLf
- Exit Sub
- End If
-
-
-
- For Each elem In ssetObj1 '把指定动态块过滤出来
-
- Dim vv As Long
- If blk.IsDynamicBlock Then
- ' 获得动态块的自定义特性
-
- dyBlkPropCol = blk.GetDynamicBlockProperties
-
- For vv = 0 To UBound(dyBlkPropCol)
- Set DBlockProperties = dyBlkPropCol(vv)
-
- With DBlockProperties
- If .PropertyName = "底架轨距" Then
- .Value = CDbl(GJ)
- Exit For
- End If
- End With
- Next vv
-
- blk.Update
- End If
-
-
- Next
- End Sub
目的是想通过vba打开一个图幅,选择其中一个名叫“180主视图”动态块,对其中的一个自定义参数进行操作。
|