515 lines
28 KiB
HTML
515 lines
28 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<title>Task Add-in Sample</title>
|
|
<meta content="Tasks" name="MS-HKWD">
|
|
<meta content="VB.NET,add-ins" name="MS-HKWD">
|
|
<meta content="Add-ins,tasks " name="MS-HKWD">
|
|
<meta content="en-us" http-equiv="Content-Language">
|
|
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
|
|
<link href="ApiHelp.css" rel="stylesheet" type="text/css">
|
|
<style type="text/css">
|
|
.auto-style3 {
|
|
color: #2B91AF;
|
|
font-size: x-small;
|
|
}
|
|
.auto-style1 {
|
|
font-size: x-small;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1><span style="font-weight: normal; font-size: 7.5pt;">SOLIDWORKS PDM Professional
|
|
API Help</span></h1>
|
|
<h1>Task Add-in Sample</h1>
|
|
<div class="Section1">
|
|
<p><span lang="EN-US">The following shows the entire source code of a task add-in
|
|
written in VB.NET. The add-in:</span></p>
|
|
<ul>
|
|
<li class="kadov-P">Implements
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmAddIn5.html">IEdmAddIn5</a>.</li>
|
|
<li class="kadov-P">Creates custom pages in the Task property dialog box.</li>
|
|
<li class="kadov-P">Customizes the task details page.</li>
|
|
<li class="kadov-P">Displays a user interface on launch.</li>
|
|
</ul>
|
|
<p>NOTE: To populate the GUID attribute below, click <b>Tools > Create GUID</b>
|
|
in the IDE, select GUID Format 6, click <b>Copy</b>, and click <b>Exit</b>.
|
|
Replace <<span style="color: #2b91af;">Guid</span>(<span style="color: #a31515;">""</span>)>
|
|
with the copied string.</p>
|
|
<table>
|
|
<tr style="height: 11.3pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<p class="APICODE"><span class="SpellE">
|
|
<span lang="EN-US" style="font-size: 10.0pt; font-family: "Courier New";">
|
|
Imports EPDM.Interop.epdm<br></span></span><font face="Courier New" size="2">Imports System.Runtime.InteropServices</font></p>
|
|
<p class="APICODE" style="font-family: Courier New; font-size: 13; color: black; background: white"><<span style="color: #2b91af;">Guid</span>(<span style="color: #a31515;">""</span>)> _<br><<span style="color: #2b91af;">ComVisible</span>(<span style="color: blue;">True</span>)> _<span class="SpellE"><span lang="EN-US" style="font-size: 10.0pt; font-family: "Courier New";"><br />
|
|
Public Class TaskAddIn<br />
|
|
Implements </span></span>
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmAddIn5.html">IEdmAddIn5</a><span class="SpellE"><span lang="EN-US" style="font-size: 10.0pt; font-family: "Courier New";"><br />
|
|
<br />
|
|
Public Sub GetAddInInfo(ByRef poInfo As EdmAddInInfo, ByVal poVault
|
|
As <a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmVault5.html">IEdmVault5</a>,
|
|
ByVal poCmdMgr As
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmCmdMgr5.html">IEdmCmdMgr5</a>)
|
|
Implements IEdmAddIn5.GetAddInInfo<br />
|
|
On Error GoTo ErrHand<br />
|
|
<span style="color: #009900">' Fill in the add-in's description<br />
|
|
</span> poInfo.mbsAddInName = "Task Test Add-in"<br />
|
|
poInfo.mbsCompany = "SOLIDWORKS"<br />
|
|
poInfo.mbsDescription = "Add-in used to test the task execution system"<br />
|
|
poInfo.mlAddInVersion = 1<br />
|
|
<br />
|
|
<span style="color: #009900">' Minimum SOLIDWORKS PDM Professional version
|
|
needed for VB.NET add-ins is 2010<br />
|
|
</span> poInfo.mlRequiredVersionMajor = 10<br />
|
|
poInfo.mlRequiredVersionMinor = 0<br />
|
|
<br />
|
|
<span style="color: #009900">'Register this add-in as a task add-in<br />
|
|
</span> poCmdMgr.AddHook(EdmCmdType.EdmCmd_TaskRun)<br />
|
|
<span style="color: #009900">'Register this add-in as being able to append
|
|
its own property pages in the Administration tool<br />
|
|
</span> poCmdMgr.AddHook(EdmCmdType.EdmCmd_TaskSetup)<br />
|
|
<span style="color: #009900">'Register this add-in to be called when the
|
|
task is launched on the client computer<br />
|
|
</span> poCmdMgr.AddHook(EdmCmdType.EdmCmd_TaskLaunch)<br />
|
|
<span style="color: #009900">'Register this add-in to provide extra details
|
|
in the Details dialog box in the task list in the Administration tool<br />
|
|
</span> poCmdMgr.AddHook(EdmCmdType.EdmCmd_TaskDetails)<br />
|
|
<span style="color: #009900">'Register this add-in to be called when the
|
|
launch dialog box is closed<br />
|
|
</span> poCmdMgr.AddHook(EdmCmdType.EdmCmd_TaskLaunchButton)<br />
|
|
<span style="color: #009900">'Register this add-in to be called when the
|
|
set-up wizard is closed<br />
|
|
</span> poCmdMgr.AddHook(EdmCmdType.EdmCmd_TaskSetupButton)<br />
|
|
<br />
|
|
Exit Sub<br />
|
|
<br />
|
|
ErrHand:<br />
|
|
Dim v11 As </span></span>
|
|
<span style="font-family: Courier New; font-size: 10pt">
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmVault11.html">IEdmVault11</a></span><span class="SpellE"><span lang="EN-US" style="font-size: 10.0pt; font-family: "Courier New";"><br />
|
|
v11 = poVault<br />
|
|
MsgBox(v11.GetErrorMessage(Err.Number))<br />
|
|
End Sub<br />
|
|
</span></span></p>
|
|
</td>
|
|
</tr>
|
|
<tr style="height: 11.3pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<span style="font-family: Courier New; font-size: 10pt">Private Sub
|
|
OnTaskDetails(ByRef poCmd As EdmCmd, </span>
|
|
<span style="font-family: Courier New; ">
|
|
<span style="color:blue;" class="auto-style1">ByRef</span></span><span style="font-family: Courier New; font-size: 10pt"><span style="font-family: Courier New; " class="auto-style1"> ppoData <span style="color:blue;">As</span></span><font size="1"> <span class="auto-style3">EdmCmdData</span><span class="auto-style1">[]</span></font>)<br />
|
|
Dim inst As
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmTaskInstance.html">
|
|
IEdmTaskInstance</a></span><span style="font-size: 10pt"><span style="font-family: Courier New"><br />
|
|
inst = poCmd.mpoExtra<br />
|
|
<br />
|
|
<span style="color: #009900">'Create a custom page in the task properties
|
|
dialog box; TaskDetailsPage is a <br />
|
|
'user control; TaskDetailsPage::LoadData fills in some edit boxes with<br />
|
|
'values from IEdmTaskInstance::GetValEx<br />
|
|
</span> Dim myPage As TaskDetailsPage<br />
|
|
myPage = New TaskDetailsPage<br />
|
|
myPage.CreateControl()<br />
|
|
poCmd.mpoExtra = myPage<br />
|
|
<br />
|
|
poCmd.mlParentWnd = myPage.Handle.ToInt32<br />
|
|
poCmd.mbsComment = "My Test Page"<br />
|
|
<br />
|
|
myPage.LoadData(inst)<br />
|
|
<br />
|
|
End Sub</span><br />
|
|
</span></td>
|
|
</tr>
|
|
<tr style="height: 11.3pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<span style="font-family: Courier New; font-size: 10pt">Private Sub
|
|
OnTaskLaunch(ByRef poCmd As EdmCmd, </span>
|
|
<span style="font-family: Courier New; ">
|
|
<span style="color:blue;" class="auto-style1">ByRef</span></span><span style="font-family: Courier New; font-size: 10pt"><span style="font-family: Courier New; " class="auto-style1"> ppoData <span style="color:blue;">As</span></span><font size="1"> <span class="auto-style3">EdmCmdData</span><span class="auto-style1">[]</span></font>)<br />
|
|
<br />
|
|
<span style="color: #009900">'Display a message box </span></span>
|
|
<span style="color: #009900; font-family: Courier New; font-size: 10pt">
|
|
where the user types data that is </span>
|
|
<span style="font-family: Courier New; font-size: 10pt">
|
|
<span style="color: #009900"><br />
|
|
'</span></span><span style="color: #009900; font-family: Courier New; font-size: 10pt">passed
|
|
</span><span style="font-family: Courier New; font-size: 10pt">
|
|
<span style="color: #009900">to the task add-in via IEdmTaskInstance::SetValEx<br />
|
|
</span> Dim v11 As
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmVault11.html">IEdmVault11</a><br />
|
|
v11 = poCmd.mpoVault<br />
|
|
If v11.MsgBox(poCmd.mlParentWnd, "Hello!" + vbLf + "Are you sure you want
|
|
to launch the test task?", EdmMBoxType.EdmMbt_YesNo) <> EdmMBoxResult.EdmMbr_Yes
|
|
Then<br />
|
|
poCmd.mbCancel = True<br />
|
|
Exit Sub<br />
|
|
End If<br />
|
|
<br />
|
|
<span style="color: #009900">'Get the property interface used to access the
|
|
framework</span><br />
|
|
Dim inst As
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmTaskInstance.html">
|
|
IEdmTaskInstance</a></span><span style="font-size: 10pt"><span style="font-family: Courier New"><br />
|
|
inst = poCmd.mpoExtra<br />
|
|
inst.SetValEx("MyLaunchVar", "A launch value")<br />
|
|
<br />
|
|
End Sub</span><br />
|
|
</span></td>
|
|
</tr>
|
|
<tr style="height: 11.3pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<span style="font-size: 10pt">
|
|
<span style="font-family: Courier New">Private Sub OnTaskLaunchButton(ByRef
|
|
poCmd As EdmCmd,
|
|
</span><span style="color:blue;" class="auto-style1">ByRef</span><span style="font-size: 10pt"><span class="auto-style1"> ppoData <span style="color:blue;">As</span></span><font size="1"> <span class="auto-style3">EdmCmdData</span><span class="auto-style1">[]</span></font>)<br />
|
|
<br />
|
|
<span style="color: #009900"> 'If displaying a card for editing,
|
|
this is <br> 'called when the user clicks OK or Cancel in the
|
|
launch dialog box<br />
|
|
</span><br />
|
|
End Sub</span></span><span style="font-size: 10pt"><span style="font-size: 10pt"><br />
|
|
</span>
|
|
</span></td>
|
|
</tr>
|
|
<tr style="height: 11.3pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<span style="font-family: Courier New; font-size: 10pt">Private Sub
|
|
OnTaskRun(ByRef poCmd As EdmCmd, </span>
|
|
<span style="font-family: Courier New; ">
|
|
<span style="color:blue;" class="auto-style1">ByRef</span></span><span style="font-family: Courier New; font-size: 10pt"><span style="font-family: Courier New; " class="auto-style1"> ppoData <span style="color:blue;">As</span></span><font size="1"> <span class="auto-style3">EdmCmdData</span><span class="auto-style1">[]</span></font>)<br />
|
|
<br />
|
|
<span style="color: #009900">'Get the property interface used to access the
|
|
framework<br />
|
|
</span> Dim inst As
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmTaskInstance.html">
|
|
IEdmTaskInstance</a><br />
|
|
inst = poCmd.mpoExtra<br />
|
|
<br />
|
|
On Error GoTo ErrHand<br />
|
|
<span style="color: #009900">'Inform the framework that the task has started<br />
|
|
</span> inst.SetStatus(EdmTaskStatus.EdmTaskStat_Running)<br />
|
|
<br />
|
|
<span style="color: #009900">'Format a message to be displayed in the task
|
|
list</span><br />
|
|
Dim msg As String<br />
|
|
msg = "Test is running:"<br />
|
|
msg = msg + " MyTestSetupVar='" + CStr(inst.GetValEx("MyTestSetupVar"))<br />
|
|
msg = msg + "' MyLaunchVar='" + inst.GetValEx("MyLaunchVar")<br />
|
|
msg = msg + "' Idx="<br />
|
|
<br />
|
|
<span style="color: #009900">'This is the main worker loop that does all
|
|
of the important work; <br />
|
|
'it just beeps and sleeps<br />
|
|
</span> Dim idx As Integer<br />
|
|
idx = 1<br />
|
|
Dim maxPos As Integer<br />
|
|
maxPos = 200<br />
|
|
inst.SetProgressRange(maxPos, 0, msg + CStr(idx))<br />
|
|
While idx < maxPos<br />
|
|
<span style="color: #009900">'Update progress bar that shows in the
|
|
task list<br />
|
|
</span> inst.SetProgressPos(idx, msg + CStr(idx))<br />
|
|
idx = idx + 1<br />
|
|
<br />
|
|
<span style="color: #009900">'Do some important work here</span><br />
|
|
System.Media.SystemSounds.Beep.Play()<br />
|
|
System.Threading.Thread.Sleep(60000 / maxPos)<br />
|
|
<br />
|
|
<span style="color: #009900">'Handle the cancel button in the task
|
|
list</span><br />
|
|
If inst.GetStatus() = EdmTaskStatus.EdmTaskStat_CancelPending Then<br />
|
|
inst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneCancelled)<br />
|
|
Exit Sub<br />
|
|
End If<br />
|
|
<br />
|
|
<span style="color: #009900">'Handle temporary suspension of the task<br />
|
|
</span> If inst.GetStatus() = EdmTaskStatus.EdmTaskStat_SuspensionPending
|
|
Then<br />
|
|
inst.SetStatus(EdmTaskStatus.EdmTaskStat_Suspended)<br />
|
|
While inst.GetStatus() = EdmTaskStatus.EdmTaskStat_Suspended<br />
|
|
System.Threading.Thread.Sleep(1000)<br />
|
|
End While<br />
|
|
If inst.GetStatus() = EdmTaskStatus.EdmTaskStat_ResumePending
|
|
Then<br />
|
|
inst.SetStatus(EdmTaskStatus.EdmTaskStat_Running)<br />
|
|
End If<br />
|
|
End If<br />
|
|
End While<br />
|
|
<br />
|
|
<span style="color: #009900">'Inform the framework that the task has successfully
|
|
</span></span><span style="font-size: 10pt">
|
|
<span style="font-family: Courier New"><span style="color: #009900">
|
|
completed </span><br />
|
|
inst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneOK)<br />
|
|
Exit Sub<br />
|
|
<br />
|
|
ErrHand:<br />
|
|
<span style="color: #009900">'Return errors to the framework by failing the
|
|
task<br />
|
|
</span> inst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneFailed, Err.Number,
|
|
"The test task failed!")<br />
|
|
End Sub</span><br />
|
|
</span></td>
|
|
</tr>
|
|
<tr style="height: 11.3pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<span style="font-family: Courier New; font-size: 10pt">
|
|
<span style="color: #009900">'Store the custom set-up page here so it
|
|
can be accessed from both OnTaskSetup and OnTaskSetupButton</span><br />
|
|
Dim currentSetupPage As SetupPage</span></td>
|
|
</tr>
|
|
<tr style="height: 11.3pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<span style="font-family: Courier New; font-size: 10pt">Private Sub
|
|
OnTaskSetup(ByRef poCmd As EdmCmd, </span>
|
|
<span style="font-family: Courier New; ">
|
|
<span style="color:blue;" class="auto-style1">ByRef</span></span><span style="font-family: Courier New; font-size: 10pt"><span style="font-family: Courier New; " class="auto-style1"> ppoData <span style="color:blue;">As</span></span><font size="1"> <span class="auto-style3">EdmCmdData</span><span class="auto-style1">[]</span></font>)<br />
|
|
<span style="color: #009900">'Get the property interface used to access the
|
|
framework<br />
|
|
</span> Dim props As
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmTaskProperties.html">
|
|
IEdmTaskProperties</a><br />
|
|
props = poCmd.mpoExtra<br />
|
|
<br />
|
|
<span style="color: #009900">'Turn on some properties, e.g., the task can
|
|
be launched during a <br />
|
|
'state change, </span></span><span style="color: #009900; font-family: Courier New; font-size: 10pt">can
|
|
extend the details page, is called when the <br />
|
|
'task is </span><span style="font-size: 10pt">
|
|
<span style="font-family: Courier New"><span style="color: #009900">
|
|
launched, and supports scheduling<br />
|
|
</span> props.TaskFlags = EdmTaskFlag.EdmTask_SupportsChangeState
|
|
+ EdmTaskFlag.EdmTask_SupportsDetails + EdmTaskFlag.EdmTask_SupportsInitExec
|
|
+ EdmTaskFlag.EdmTask_SupportsScheduling<br />
|
|
<br />
|
|
<span style="color: #009900">'Set menu commands that launch this task from
|
|
File Explorer<br />
|
|
</span> Dim cmds(0) As EdmTaskMenuCmd<br />
|
|
cmds(0).mbsMenuString = "Run the test task"<br />
|
|
cmds(0).mbsStatusBarHelp = "This command runs the task add-in"<br />
|
|
cmds(0).mlCmdID = 1<br />
|
|
cmds(0).mlEdmMenuFlags = EdmMenuFlags.EdmMenu_Nothing<br />
|
|
props.SetMenuCmds(cmds)<br />
|
|
<br />
|
|
<span style="color: #009900">'Add a custom setup page; SetupPage is a user
|
|
control with an<br />
|
|
'edit box; SetupPage::LoadData populates the edit box from a<br />
|
|
'variable in IEdmTaskProperties; saving of properties is handled<br />
|
|
'by OnTaskSetupButton <br />
|
|
</span> currentSetupPage = New SetupPage<br />
|
|
currentSetupPage.CreateControl()<br />
|
|
currentSetupPage.LoadData(poCmd)<br />
|
|
<br />
|
|
Dim pages(0) As EdmTaskSetupPage<br />
|
|
pages(0).mbsPageName = "Test Add-in page"<br />
|
|
pages(0).mlPageHwnd = currentSetupPage.Handle.ToInt32<br />
|
|
pages(0).mpoPageImpl = currentSetupPage<br />
|
|
<br />
|
|
props.SetSetupPages(pages)<br />
|
|
End Sub</span><br />
|
|
</span></td>
|
|
</tr>
|
|
<tr style="height: 11.3pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<span style="font-family: Courier New; font-size: 10pt">
|
|
<span style="color: #009900">'Called when the user clicks OK or Cancel
|
|
in the <br>'task property dialog box<br />
|
|
</span>Private Sub OnTaskSetupButton(ByRef poCmd As EdmCmd,
|
|
</span>
|
|
<span style="font-family: Courier New; ">
|
|
<span style="color:blue;" class="auto-style1">ByRef</span></span><span style="font-family: Courier New; font-size: 10pt"><span style="font-family: Courier New; " class="auto-style1"> ppoData <span style="color:blue;">As</span></span><font size="1"> <span class="auto-style3">EdmCmdData</span><span class="auto-style1">[]</span></font>)<br />
|
|
<span style="color: #009900">'The custom set-up page in currentSetupPage
|
|
<br> 'was created in method OnTaskSetup;<br />
|
|
'StoreData saves the contents of the edit <br> 'box in the user control
|
|
to<br />
|
|
'IEdmTaskProperties in poCmd.mpoExtra<br />
|
|
</span> If poCmd.mbsComment = "OK" And Not currentSetupPage Is
|
|
Nothing Then<br />
|
|
currentSetupPage.StoreData(poCmd)<br />
|
|
End If<br />
|
|
currentSetupPage = Nothing<br />
|
|
End Sub<br />
|
|
</span></td>
|
|
</tr>
|
|
<tr style="height: 11.3pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<span style="font-size: 10pt; font-family: Courier New">
|
|
<span style="color: #009900">'Main entry point of the add-in; called
|
|
by SOLIDWORKS <br>'PDM Professional for all task-related events<br />
|
|
</span>Public Sub OnCmd(ByRef poCmd As EdmCmd, </span>
|
|
<span style="font-family: Courier New">
|
|
<span style="color:blue;" class="auto-style1">ByRef</span></span><span style="font-size: 10pt; font-family: Courier New"><span style="font-family: Courier New" class="auto-style1"> ppoData <span style="color:blue;">As</span></span><font size="1"> <span class="auto-style3">EdmCmdData</span><span class="auto-style1">[]</span></font>)
|
|
Implements IEdmAddIn5.OnCmd<br />
|
|
On Error GoTo ErrHand<br />
|
|
<br />
|
|
<span style="color: #009900">'Check the command type and call the right procedure</span><br />
|
|
Select Case poCmd.meCmdType<br />
|
|
Case EdmCmdType.EdmCmd_TaskDetails<br />
|
|
OnTaskDetails(poCmd, ppoData)<br />
|
|
Case EdmCmdType.EdmCmd_TaskLaunch<br />
|
|
OnTaskLaunch(poCmd, ppoData)<br />
|
|
Case EdmCmdType.EdmCmd_TaskLaunchButton<br />
|
|
OnTaskLaunchButton(poCmd, ppoData)<br />
|
|
Case EdmCmdType.EdmCmd_TaskRun<br />
|
|
OnTaskRun(poCmd, ppoData)<br />
|
|
Case EdmCmdType.EdmCmd_TaskSetup<br />
|
|
OnTaskSetup(poCmd, ppoData)<br />
|
|
Case EdmCmdType.EdmCmd_TaskSetupButton<br />
|
|
OnTaskSetupButton(poCmd, ppoData)<br />
|
|
End Select<br />
|
|
Exit Sub<br />
|
|
<br />
|
|
ErrHand:<br />
|
|
Dim v11 As </span>
|
|
<span style="font-family: Courier New; font-size: 10pt">
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmVault11.html">IEdmVault11</a></span><span style="font-size: 10pt; font-family: Courier New"><br />
|
|
v11 = poCmd.mpoVault<br />
|
|
MsgBox(v11.GetErrorMessage(Err.Number))<br />
|
|
End Sub<br />
|
|
<br />
|
|
End Class</span><br />
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<p style="background: white"><span lang="EN-US"><o:p><br />
|
|
The following is a resource template of the custom set-up page that is displayed
|
|
in the Task property dialog box by <strong>TaskAddIn::OnTaskSetup</strong>.
|
|
It is a user control in Visual Studio with an edit box named TextBox1 and a
|
|
button named TestButton.</o:p></span></p>
|
|
<p style="background: white"><span lang="EN-US">
|
|
<o:p><br />
|
|
<img ,="" alt="" src="SetupPage.png" /> <br />
|
|
</o:p></span></p>
|
|
<p style="background: white"><span lang="EN-US">
|
|
<o:p>The code behind the custom set-up page is as follows.<br />
|
|
</p>
|
|
<blockquote>
|
|
<p class="MsoNormal"><span class="SpellE">
|
|
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';">
|
|
Imports EPDM.Interop.epdm<br />
|
|
<br />
|
|
Public Class SetupPage<br />
|
|
<br />
|
|
<span style="color: #009900">'Button handler for a button on the page</span><br />
|
|
Private Sub TestButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
|
|
Handles TestButton.Click<br />
|
|
MsgBox("You pressed the test button")<br />
|
|
End Sub<br />
|
|
</p>
|
|
Public Sub LoadData(ByRef poCmd As
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.EdmCmd.html">EdmCmd</a>)<br />
|
|
<br />
|
|
<span style="color: #009900"> 'Get the property interface used to
|
|
access the framework<br />
|
|
</span> Dim props As
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmTaskProperties.html">IEdmTaskProperties</a><br />
|
|
props = poCmd.mpoExtra<br />
|
|
<br />
|
|
<span style="color: #009900"> 'Populate the edit box from a variable<br />
|
|
</span> TextBox1.Text = props.GetValEx("MyTestSetupVar")<span style="color: #009900"><br />
|
|
<br />
|
|
</span>End Sub<p><br />
|
|
</td>
|
|
</tr>
|
|
<tr style="font-size: 10pt">
|
|
<td style="border-right: white 1.5pt solid; padding-right: 3.5pt; border-top: white 1.5pt solid; padding-left: 3.5pt; background: #e0e0e0; padding-bottom: 0cm; border-left: white 1.5pt solid; width: 855pt; padding-top: 0cm; border-bottom: white 1.5pt solid; height: 11.3pt" valign="top" width="1140">
|
|
<span style="font-family: Courier New"><font size="2">Public Sub StoreData(ByRef
|
|
poCmd As <a href="EPDM.Interop.epdm~EPDM.Interop.epdm.EdmCmd.html">EdmCmd</a>)<br />
|
|
<br />
|
|
<span style="color: #009900">'Get the property interface used to access the
|
|
framework<br />
|
|
</span> Dim props As
|
|
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmTaskProperties.html">IEdmTaskProperties</a><br />
|
|
props = poCmd.mpoExtra<br />
|
|
<br />
|
|
<span style="color: #009900">'Make sure the user has typed a value in the
|
|
edit box</span><br />
|
|
If TextBox1.Text = "" Then<br />
|
|
MsgBox("Enter a test value for the add-in!")<br />
|
|
poCmd.mbCancel = True<br />
|
|
Exit Sub<br />
|
|
End If<br />
|
|
<br />
|
|
<span style="color: #009900">'Save the value entered by the user</span><br />
|
|
props.SetValEx("MyTestSetupVar", TextBox1.Text)<br />
|
|
<br />
|
|
End Sub<br />
|
|
<br />
|
|
End Class</font></span></p>
|
|
</blockquote>
|
|
<p><br />
|
|
<br />
|
|
</span><font face="Verdana" style="font-size: 8pt"><span lang="EN-US">The following
|
|
is the r</span></font><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';"><font face="Verdana" style="font-size: 8pt">esource
|
|
template of the extra details page added by <strong>TaskAddIn::OnTaskDetails</strong>.
|
|
<span lang="EN-US">
|
|
<o:p>It is a user control in Visual Studio </o:p></span>that displays two task variables:</font></p>
|
|
</span></span>
|
|
<blockquote>
|
|
<span class="SpellE">
|
|
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';">
|
|
<p><br />
|
|
<img ,="" alt="" src="TaskDetailsPage.png" /> <br />
|
|
</p>
|
|
</blockquote>
|
|
<p><font face="Verdana" style="font-size: 8pt">The code behind the extra details
|
|
page:</font><br />
|
|
</p>
|
|
</span></span>
|
|
<blockquote>
|
|
<span class="SpellE">
|
|
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';">
|
|
<p class="MsoNormal"><span class="SpellE">
|
|
<span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';">
|
|
Imports EPDM.Interop.epdm<br />
|
|
Public Class TaskDetailsPage<br />
|
|
<br />
|
|
Public Sub LoadData(ByRef inst As IEdmTaskInstance)<br />
|
|
<br />
|
|
'Populate the editboxes from the variables in the task<br />
|
|
TextBoxSetupVar.Text = CStr(inst.GetValEx("MyTestSetupVar"))<br />
|
|
TextBoxLaunchVar.Text = CStr(inst.GetValEx("MyLaunchVar"))<br />
|
|
<br />
|
|
End Sub<br />
|
|
End Class<br />
|
|
</span></span></p>
|
|
</blockquote>
|
|
<p><font face="Verdana" style="font-size: 8pt">The following is the set-up page
|
|
when the add-in is used in a task.</font></p>
|
|
<p><br />
|
|
<img ,="" alt="" src="SetupPageResult.png" /><br />
|
|
<br />
|
|
<font face="Verdana" style="font-size: 8pt">The following is the task details
|
|
page when opened from the task list.</font></p>
|
|
<p><br />
|
|
<img ,="" alt="" src="TaskDetailsPageResult.png" /></span></span></o:p><span class="SpellE"><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New';"></p>
|
|
<p></p>
|
|
<p class="MsoNormal" style="background: white"> </p>
|
|
<p style="background: white"><span lang="EN-US">
|
|
<o:p>The following is the task list during task execution.</o:p></span></p>
|
|
<p style="background: white"><span lang="EN-US">
|
|
<o:p><br />
|
|
<img ,="" alt="" src="TaskList.png" /></o:p></span></p>
|
|
<p class="MsoNormal" style="background: white"> </p>
|
|
<p class="MsoNormal" style="background: white"><strong>See Also</strong></p>
|
|
<p class="MsoNormal" style="background: white"><a href="tasks.htm">Programming
|
|
Tasks</a></p>
|
|
<p class="MsoNormal" style="background: white">
|
|
<a href="standardtaskaddin.htm">Standard Task Add-in</a></p>
|
|
<p class="MsoNormal" style="background: white">
|
|
<a href="TaskSample_CSharp.htm">Task Sample (C#)</a></p>
|
|
<p class="MsoNormal" style="background: white"><span lang="EN-US">
|
|
<o:p> <br />
|
|
</o:p></span></p>
|
|
</div>
|
|
</span></span></span>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|