要利用 3DEXPERIENCE Transition 任务运行宏:
- 在 3DEXPERIENCE Transition 任务中,选择要运行宏的文件。请参阅 创建 3DEXPERIENCE Transition 任务。
- 单击下一步。
- 在选项对话框的自定义操作下面,选择运行宏:。
- 浏览 SOLIDWORKS 宏 (.swp)。
- 单击完成。
宏将在 Task Scheduler 中显示为您为任务设置的标题。
示例 SOLIDWORKS 宏
要测试此功能,您可以将以下文本粘贴到 SOLIDWORKS 宏 (.swp) 中。
此示例宏将名为“Hello”、值为“Hello World”的属性添加到任务文件列表中的所有零件、装配体或工程图中。
- 对于零件和装配体,它会将配置特定的属性添加到活动配置中。
- 对于工程图,它会添加自定义属性,因为工程图不包含配置。
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim config As SldWorks.Configuration
Dim cusPropMgr As SldWorks.CustomPropertyManager
Dim lRetVal As Long
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
' If no model is currently loaded, then exit
Exit Sub
End If
If (swModel.GetType <> swDocDRAWING) Then
' Add a Configuration Property named "Hello" to the active configuration for a Part or Assembly
Set config = swModel.GetActiveConfiguration
Set cusPropMgr = config.CustomPropertyManager
lRetVal = cusPropMgr.Add3("Hello",
swCustomInfoType_e.swCustomInfoText, "Hello World",
swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd)
Else
' Add a Property named "Hello" for a Drawing
Set cusPropMgr = swModel.Extension.CustomPropertyManager("")
lRetVal = cusPropMgr.Add3("Hello",
swCustomInfoType_e.swCustomInfoText, "Hello World",
swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd)
End If
End Sub