若要以 3DEXPERIENCE 轉換任務執行巨集:
- 在 3DEXPERIENCE 轉換任務中,選擇您要用來執行巨集的檔案。請參閱產生 3DEXPERIENCE 轉換任務。
- 按一下下一步。
- 在選項對話方塊的自訂動作下,選擇執行巨集:。
- 瀏覽並找到 SOLIDWORKS 巨集 (.swp)。
- 按一下完成。
巨集會出現在任務排程器中,並顯示您為該任務設定的標題。
範例 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