作者: feelling2021 时间: 2023-11-22 12:46
不能乱贴啊,一个是VB,一个是C#,都不一样的语言啊 作者: DFFDSGG114485 时间: 2023-11-22 22:19
,我小白一枚,VB怎么表达?作者: DFFDSGG114485 时间: 2023-11-22 22:20
不好意思,VB怎么表达呀?作者: samult 时间: 2024-5-15 12:27
Dim swApp As Object
Dim swModel As Object
Dim swAsm As SldWorks.AssemblyDoc
Dim swCompTop() As Object
Dim swCompPart As Object
Dim mark As Boolean
Sub main()
mark = False
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If Not swModel Is Nothing Then
If swModel.GetType = 2 Then
Set swAsm = swModel
swCompTop = swAsm.GetComponents(True)
For Each swComp In swCompTop
Set swCompPart = swComp.GetModelDoc()
If swCompPart.GetType = 2 Then
mark = True
Exit For
End If
Next
If mark = False Then
MsgBox "当前装配体不存在子装配体!", vbOKOnly + vbSystemModal, "检查是否存在子装配体"
Else
MsgBox "当前装配体存在子装配体!", vbOKOnly + vbSystemModal, "检查是否存在子装配体"
End If
Else
MsgBox "当前打开的文件不是装配体,请确认打开的是装配体再运行此宏!", vbOKOnly + vbSystemModal, "检查是否存在子装配体"
Exit Sub
End If
End If