3DEXPERIENCE 遷移タスクでマクロを実行するには:
- 3DEXPERIENCE 遷移タスクで、マクロを実行するファイルを選択します。3DEXPERIENCE 遷移タスクの作成 を参照してください。
- 次へ(Next)をクリックします。
- オプション(Options) ダイアログ ボックスのカスタムアクション(Custom Actions)で、マクロを実行(Run macro)を選択します。
- SOLIDWORKS マクロ(.swp)を参照します。
- 完了(Finish)をクリックします。
マクロがタスク スケジューラに、タスクに設定したタイトル付きで表示されます。
サンプル SOLIDWORKS マクロ
この機能をテストするため、次のテキストを SOLIDWORKS マクロ(.swp)に貼り付けることができます。
このサンプル マクロは、タスク ファイルのリスト内のどの部品、アセンブリ、または図面にも、「Hello World」という値を持つ「Hello」 という名前のプロパティを追加します。
- 部品とアセンブリには、アクティブなコンフィギュレーションにコンフィギュレーション固有のプロパティが追加されます。
- 図面には、図面にコンフィギュレーションが含まれていないため、ユーザー定義プロパティが追加されます。
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