Initial Commit of the PDM project (ready for DWS migration)

This commit is contained in:
will
2026-04-20 08:42:38 -05:00
commit dda7b664e7
2721 changed files with 442772 additions and 0 deletions

View File

@@ -0,0 +1,181 @@
<html>
<head>
<title>Creating Add-in Hooks (VB.NET)</title>
<meta name=MS-HKWD content="Hooks">
<meta name=MS-HKWD content="Add-ins, hooks">
<meta name=MS-HKWD content="VB.NET, add-ins">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="ApiHelp.css">
<style>
<!--
div.Section1
{page:Section1;}
.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>Creating Add-in Hooks (VB.NET)</h1>
<div class=Section1>
<p><span lang=EN-US style='font-family:Verdana'>This
topic shows how to implement
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmAddIn5~GetAddInInfo.html"> IEdmAddIn5::GetAddInInfo</a>
and <a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmAddIn5~OnCmd.html"> IEdmAddIn5::OnCmd</a>
in your add-in to have SOLIDWORKS PDM Professional notify your add-in
whenever a file is added, checked out, or checked in.<br>
<br>
</span><span lang="en-us"><b><span style="font-family: Verdana">NOTE: </span></b></span>
<span lang=EN-US style='font-family:Verdana;
mso-ansi-language:EN-US'>Because SOLIDWORKS PDM Professional cannot force a reload of
add-ins if they are written in .NET, all client machines must be restarted to ensure that the latest version of the add-in is used.<o:p></o:p></span><span lang=EN-US><font face="Verdana"> </font> </span>
<span lang=EN-US style='font-family:Verdana'>&nbsp;</span></p>
<ol>
<li class="kadov-P"><span style="font-family: Verdana">C</span><span lang=EN-US style='font-family:Verdana'>all
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmCmdMgr5~AddHook.html">IEdmCmdMgr5::AddHook</a>
</span><span lang=EN-US style='font-family:Verdana'>from your add-in's GetAddInInfo
method
for each activity you want your add-in to know about. Implement IEdmAddIn5::GetAddInInfo
in your add-in as follows:</span></li>
<blockquote>
<p class=MsoNormal>
<span style="font-size: 10pt; font-family: Courier New" lang="EN-US">Public Sub
GetAddInInfo(ByRef poInfo As EdmAddInInfo, ByVal poVault As IEdmVault5,
ByVal poCmdMgr As IEdmCmdMgr5) Implements IEdmAddIn5.GetAddInInfo<br />
<br /><span style="color: #009900">&nbsp; </span></span><span class="GramE">
<font size="2" color="#008000"><span style="font-family: Courier New">'</span></font></span><span style="font-size: 10pt; font-family: Courier New" lang="EN-US"><font color="#008000"><span class="GramE">Specify
add-in information</span></font><span style="color: #009900"><br /></span>&nbsp;
poInfo.mbsAddInName = &quot;My first add-in&quot;<br />&nbsp;
poInfo.mbsCompany = &quot;The name of my company&quot;</span></p>
<p class="MsoNormal">
<span style="font-size: 10pt; font-family: Courier New" lang="EN-US">&nbsp;
poInfo.mbsDescription = &quot;This is a very nice add-in.&quot;<br />&nbsp;
poInfo.mlAddInVersion = 1<br>
<br>
&nbsp; </span><span class="GramE"><font size="2" color="#008000">
<span style="font-family: Courier New">'</span></font></span><SPAN class=SpellE><SPAN class=GramE><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New; mso-ansi-language:EN-US"><font color=green>Specify
minimum version of SOLIDWORKS PDM Professional</font></SPAN></SPAN></SPAN><span style="font-size: 10pt; font-family: Courier New" lang="EN-US"><br />&nbsp;
poInfo.mlRequiredVersionMajor = 5<br />&nbsp;
poInfo.mlRequiredVersionMinor = 2<br /></span></p>
<p class="MsoNormal">
<span style="font-size: 10pt; font-family: Courier New" lang="EN-US">&nbsp;
</span><span lang="EN-US">
<span style="font-size: 10pt; font-family: Courier New">
<span style="color: #009900">'Notify when a file has been added<br />
</span>&nbsp; poCmdMgr.AddHook(EdmCmdType.EdmCmd_PostAdd)<br /><br />&nbsp;
<span style="color: #009900">'Notify when a file has been checked out<br />
</span>&nbsp; poCmdMgr.AddHook(EdmCmdType.EdmCmd_PostLock)<br /><br />&nbsp;
<span style="color: #009900">'Notify when a file is about to be checked in<br />
</span>&nbsp; poCmdMgr.AddHook(EdmCmdType.EdmCmd_PreUnlock)<br /><br />
<span style="color: #009900">&nbsp; 'Notify when a file has been checked in<br />
</span>&nbsp; poCmdMgr.AddHook(EdmCmdType.EdmCmd_PostUnlock)<br /><br />End Sub</span>
</span></p>
</blockquote>
<li class="kadov-P">
<p style='background:white'><span style="font-family: Verdana">Implement
IEdmAddIn5::</span><span lang=EN-US style='font-family:Verdana'>OnCmd in
your add-in as follows:</span></p></li>
<blockquote>
<p style='background:white'>
<span lang=EN-US style="font-size:10pt;font-family:Courier New">Public Sub OnCmd(ByRef
poCmd As EdmCmd, </span>
<span lang=EN-US style="font-family:Courier New">
<span style="color:blue;" class="auto-style1">ByRef</span></span><span lang=EN-US style="font-size:10pt;font-family:Courier New"><span lang=EN-US style="font-family:Courier New" class="auto-style1">&nbsp;ppoData&nbsp;<span style="color:blue;">As</span></span><font size="1">&nbsp;<span class="auto-style3">EdmCmdData</span><span class="auto-style1">[]</span></font>) Implements IEdmAddIn5.OnCmd<br />
<br />&nbsp; <span style="color: #009900">'Check the type of hook that
triggered this call<br />
</span>&nbsp; Dim name As String<br />&nbsp;
Select Case poCmd.meCmdType<br />&nbsp; &nbsp; Case EdmCmdType.EdmCmd_PostAdd&nbsp;<br />&nbsp; &nbsp; &nbsp; name = &quot;PostAdd&quot;<br />&nbsp; &nbsp; Case EdmCmdType.EdmCmd_PostLock&nbsp;<br />&nbsp; &nbsp; &nbsp; name = &quot;PostLock&quot;<br />&nbsp; &nbsp; Case EdmCmdType.EdmCmd_PreUnlock&nbsp;<br />&nbsp; &nbsp; &nbsp; name = &quot;PreUnlock&quot;<br />&nbsp; &nbsp; Case EdmCmdType.EdmCmd_PostUnlock&nbsp;<br />&nbsp; &nbsp; &nbsp; name = &quot;PostUnlock&quot;<br />&nbsp; &nbsp; Case Else&nbsp;<br />&nbsp; &nbsp; &nbsp; name = &quot;?&quot;<br />&nbsp; End Select<br />
<br />&nbsp;<span style="color: #009900"> 'Check the upper and lower bounds
of the array<br />
</span>&nbsp; Dim message As String<br />&nbsp; message = ""<br />&nbsp; Dim index As Long<br />&nbsp;
index = LBound(ppoData)<br />&nbsp; Dim last As Long<br />&nbsp;
last = UBound(ppoData)<br /><br />&nbsp;<span style="color: #009900"> </span></span>
<span class="SpellE"><span style="background-position: 0 0">
<font size="2" color="#008000"><span style="font-family: Courier New">'</span></font></span><SPAN lang=EN-US
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN-US"><o:p><font color=green>Append the paths of all files to a string</font></o:p></SPAN></span><span lang=EN-US style="font-size:10pt;font-family:Courier New"><br />&nbsp; While index &lt;= last<br />&nbsp; &nbsp; message = message + ppoData(index).mbsStrData1 + vbLf<br />&nbsp; &nbsp; index = index + 1<br />&nbsp; End While<br />
<br />&nbsp; <span style="color: #009900">'Display a message to the user<br />
</span>&nbsp;
message = &quot;The following files were affected by a &quot; + name + &quot;
hook:&quot; + vbLf + message<br /><br />&nbsp;
Dim vault As EdmVault5<br />&nbsp; vault = poCmd.mpoVault<br />&nbsp; vault.MsgBox(poCmd.mlParentWnd, message)<br />
<br />End Sub</span></p>
</blockquote>
<p style='background:white'><span lang=EN-US style='font-family:Verdana'>OnCmd
is called for each of the
hooks registered in GetAddInInfo. You can tell which hook triggered the call to
OnCmd by
inspecting the meCmdType
member of the <a href="EPDM.Interop.epdm~EPDM.Interop.epdm.EdmCmd.html">EdmCmd</a> structure
that is passed as poCmd in OnCmd. meCmdType contains an EdmCmdType constant
that indicates the triggering hook.<o:p></o:p></span></p>
<p style='background:white'><span lang=EN-US style='font-family:Verdana'>The second argument to OnCmd
is an array of <a href="EPDM.Interop.epdm~EPDM.Interop.epdm.EdmCmdData.html">EdmCmdData</a> structures. There is
one element in the array for each file that is affected by the call. The
contents of the structure members&nbsp;vary depending on the type of hook that
is executed. See EdmCmdData for a complete list
of members and their descriptions.<o:p></o:p></span></p>
<li class="kadov-P">
<p class=MsoNormal style='line-height:11.3pt'>
<span lang=EN-US style='mso-ansi-language:EN-US'>Click <b>Build &gt; Build
Solution</b> to build the add-in.</span></p></li>
<li class="kadov-P"><span lang="en-us">I</span><span lang=EN-US style='mso-ansi-language:EN-US'>nstall
the add-in through the SOLIDWORKS PDM Professional
Administration tool: <br>&nbsp;</span><ol style="font-family: Verdana; font-size: 8pt">
<li><span lang="en-us">Open</span><span lang=EN-US style='mso-ansi-language:EN-US'> the SOLIDWORKS
PDM Professional Administration tool.<br>&nbsp;</span></li>
<li><span lang=EN-US style='mso-ansi-language:EN-US'>Expand the vault where
you want to install this add-in and log in as Admin.<br>&nbsp;</span></li>
<li><span lang="en-us">Right-click <b>Add-ins</b> and click <b>New
Add-in</b>.<b><br>&nbsp;</b></span></li>
<li>B<span lang="en-us">rowse to </span>
<span lang=EN-US style='mso-ansi-language:EN-US'>
<i style='mso-bidi-font-style:
normal'>project_path</i><span style='mso-bidi-font-style:
normal; '><i>\</i></span></span><span style='mso-bidi-font-style:
normal; mso-ansi-language:EN-US' lang="EN-US"><i>project_name\project_name</i><b>\bin\Debug</b>,
click <i>project_name</i><b>.dll</b> and <b>EPDM.Interop.epdm.dll</b>.<br>&nbsp;</span></li>
<li><span lang="en-us">Click <b>Open</b>.<br>&nbsp;</span></li>
<li>Click <b>OK</b>.<br>&nbsp;</li>
<li>Click <b>OK</b>.</li>
</ol></li>
<li class="kadov-P">
<p class=MsoNormal style='background:white'>
<span style="background-position: 0 0"><font face="Verdana">T</font></span><span lang=EN-US><font face="Verdana">ry adding, checking out, and checking in
vault files.</font><o:p></o:p></span></p></li>
</ol>
<p class=MsoNormal style='background:white'><strong>
<span lang=EN-US
style='font-family:Verdana'>NOTE: </span></strong>
<span
lang=EN-US style='font-family:Verdana'>OnCmd is not called during check-in if the
file is not modified before it is checked in. During check-in of unmodified
files, SOLIDWORKS PDM Professional triggers an &quot;undo check-out&quot; event. To handle
this &quot;undo check-out&quot; event, add hooks for <a href="EPDM.Interop.epdm~EPDM.Interop.epdm.EdmCmdType.html"> EdmCmdType.EdmCmd_PreUndoLock</a> and
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.EdmCmdType.html">EdmCmdType.EdmCmd_PostUndoLock</a>
to your add-in's GetAddInInfo.</span></p>
</div>
</body>
</html>