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,297 @@
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<title>Creating Add-ins (C++)</title>
<meta name=MS-HKWD content="C++">
<meta name=MS-HKWD content="C++,add-ins">
<meta name=MS-HKWD content="Add-ins, C++">
<meta name=MS-HKWD content="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">
</head>
<h1><span style="font-weight: normal; font-size: 7.5pt;">SOLIDWORKS PDM Professional API Help</span>
</h1>
<h1>Creating Add-ins (C++)</h1>
<body bgcolor=white lang=SV link=blue vlink=purple style='tab-interval:65.2pt'>
<div class=Section1>
<p><span lang=EN-US style='font-family:Verdana'>This topic shows how to create
an add-in using Visual C++ in Microsoft Visual Studio
that adds a menu item to the context-sensitive and Tools menus of vaults in File Explorer. You must be familiar
with the process of creating a C++ COM DLL in the development environment that
you use.</span></p>
<ol>
<li class="kadov-P"><font face="Verdana" style="font-size: 8pt">
<span lang=EN-US style='mso-ansi-language:EN-US'>Create the C++ project.<br>
&nbsp;</span></font><ol>
<li><font face="Verdana" style="font-size: 8pt">
<span lang=EN-US style='mso-ansi-language:EN-US'>Start Microsoft Visual
Studio.<br>&nbsp;</span></font></li>
<li><span lang="en-us"><font face="Verdana">Select <b>File &gt;
New &gt; Project &gt; Visual C++ &gt; <span lang="sv">MFC/</span>ATL &gt; ATL Project</b>.<br>&nbsp;</font></span></li>
<li><font face="Verdana" style="font-size: 8pt">
<span lang=EN-US style='mso-ansi-language:EN-US'>Type the name of your
project in <b>Name</b>.<br>&nbsp;</span></font></li>
<li><span lang="en-us"><font face="Verdana">Click <b>Browse</b> and navigate to the folder where to create your project.<br>&nbsp;</font></span></li>
<li><span lang="en-us"><font face="Verdana">Click <b>OK</b>.<br>&nbsp;</font></span></li>
<li>
<p class=MsoNormal>If you intend on using MFC, select <b>Application
Settings</b> &gt; <b>Support MFC</b> in the ATL Project Wizard dialogMyAdd.<br>&nbsp;</p>
</li>
<li>
<p class=MsoNormal>Click
<strong>Finish</strong> to generate the
project.&nbsp;<br>&nbsp;</p></li>
</ol>
</li>
<li class=kadov-p>
<p class=MsoNormal>Modify the project's settings.</p>
<ol>
<li>
<p class=MsoNormal>Right-click the project in Solution Explorer, and select
<b>Add &gt; Class</b>.<br>&nbsp;</p></li>
<li>
<p class=MsoNormal>In the Add Class dialog, select <strong>ATL &gt; ATL Simple
Object</strong>.<br>&nbsp;</p></li>
<li>
<p class=MsoNormal>Click <b>Add</b>.<br>&nbsp;</p></li>
<li>
<p class=MsoNormal>Type <b>MyAddIn</b> in <b>Short name</b>.<br>&nbsp;</p>
</li>
<li>
<p class=MsoNormal>Click <b>Next </b>and<b> Next</b>.<br>&nbsp;</p></li>
<li>
<p class=MsoNormal>Select
<b>Custom</b> in the Interface and <strong>Both</strong> in the Threading
Model.<br>&nbsp;</p></li>
<li>
<p class=MsoNormal>Click <b>Finish</b>.&nbsp;<br>&nbsp;</p></li>
<li>
<p class="MsoNormal">Select <b>View &gt; Class View</b> and expand your project in the Class View window.<br>&nbsp;</p>
</li>
<li>
<p class="MsoNormal">Right-click <b>CMyAddIn</b> and select<b> Add &gt;
Implement Interface</b>.&nbsp;
<br>&nbsp;</p></li>
<li>
<p class=MsoNormal>Select <b>Project</b> and select the most recent SOLIDWORKS PDM Professional type library,
<b>Edm.tlb</b>, from
the <b>Available type libraries</b> list.&nbsp;
<br><br /><b>NOTE:</b> If the type library is not in the list, you must
copy <b>Edm.tlb</b> from the API folder on the CD to&nbsp; <i>project_path\project_name\project_name</i>.
Then select <b>File</b>, browse to <i>project_path\project_name\project_name, </i>
and select <b>Edm.tlb</b>.<br>&nbsp;</p></li>
<li>
<p class=MsoNormal>Select
<a href="EPDM.Interop.epdm~EPDM.Interop.epdm.IEdmAddIn5.html">IEdmAddIn5</a>
in <b>Interfaces</b> .<br>&nbsp;</p></li>
<li>
<p class=MsoNormal>Click the single right-arrow button to move IEdmAddIn5 to
<b>Implement Interfaces</b>, and click <b>Finish</b>.&nbsp;
<br>
<br>
Two
new methods,
<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>,
are added to your class.</p></li>
<li>
<p class=MsoNormal>Select <strong>File &gt; Save All</strong>.<br>&nbsp;</p>
</li>
</ol>
</li>
<li class=kadov-p>
<p class=MsoNormal>Implement
IEdmAddIn5::GetAddInInfo by replacing <font size="2" face="Courier New">
STDMETHOD(GetAddInInfo)</font>in <b>MyAddin.h</b> with the following code.<br><br>
<span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New"'>STDMETHOD(GetAddInInfo)(EdmAddInInfo
* poInfo, IEdmVault5 * poVault, IEdmCmdMgr5 * poCmdMgr)<br>{<br>
<span style='color:green'>//The AFX_MANAGE_STATE macro is needed
for MFC applications but should not <br>//be used for applications that are MFC-free</span><br>&nbsp;&nbsp; AFX_MANAGE_STATE(AfxGetStaticModuleState());<br>
<br>&nbsp;&nbsp; if (poInfo == NULL || poCmdMgr == NULL )<br>&nbsp;&nbsp;&nbsp;&nbsp; return E_POINTER;<br>
<br>&nbsp;&nbsp; <span style='color:green'>//Return some information
to the Properties dialog box</span><br>&nbsp;&nbsp; poInfo-&gt;mbsAddInName= SysAllocString( L&quot;My first
add-in&quot; );<br>&nbsp;&nbsp; poInfo-&gt;mbsCompany = SysAllocString( L&quot;The name of my
company&quot; );<br>&nbsp;&nbsp; poInfo-&gt;mbsDescription= SysAllocString( L&quot;This is a very
nice add-in.&quot; );<br>&nbsp;&nbsp; poInfo-&gt;mlAddInVersion = 1;<br><br>&nbsp;&nbsp;
<span style='color:green'>//SOLIDWORKS PDM Professional 5.2 is
required by this add-in</span><br>&nbsp;&nbsp; poInfo-&gt;mlRequiredVersionMajor = 5;<br>&nbsp;&nbsp; poInfo-&gt;mlRequiredVersionMinor= 2;<br>
<br>&nbsp;&nbsp; <span style='color:green'>//Add hooks and menu commands to
SOLIDWORKS PDM Professional<br>&nbsp;&nbsp; //Below is a menu command that
appears in the Tools<br>&nbsp;&nbsp; //and context-sensitive menus of a
vault in File Explorer </span><br>&nbsp;&nbsp; poCmdMgr-&gt;AddCmd( 1, bstr_t(&quot;My first menu
command&quot;), EdmMenu_Nothing, bstr_t(&quot;&quot;), bstr_t(&quot;&quot;),
0, 0 );<br><br>&nbsp;&nbsp; return S_OK;<br>}</span></p></li>
<li class=kadov-p>
<p>Implement IEdmAddIn5::OnCmd by replacing
<font size="2" face="Courier New">STDMETHOD(OnCmd)</font>in <b>MyAddin.h</b>
with the following code.</span><br><br>
<span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New"'>STDMETHOD(OnCmd)(EdmCmd *
poCmd, SAFEARRAY * * ppoData)<br>{<br><span style='color:green'>//The AFX_MANAGE_STATE macro is needed
for MFC applications, but should not <br>//be used for applications that are MFC-free</span><br>&nbsp;&nbsp; AFX_MANAGE_STATE(AfxGetStaticModuleState());<br>
<br>&nbsp;&nbsp; if (poCmd == NULL ||ppoData == NULL)<br>&nbsp;&nbsp;&nbsp;&nbsp; return E_POINTER;<br>
<br>&nbsp;&nbsp; MessageBox((HWND)poCmd-&gt;mlParentWnd, L&quot;Hello
World!&quot;, L&quot;SOLIDWORKS PDM Professional&quot;, MB_OK );<br><br>&nbsp;&nbsp; return S_OK;<br>}<br>
<br>
</span><span style="font-weight: 700" lang="en-us"><font face="Verdana">NOTE</font></span><font face="Verdana"><span lang=EN-US><b>:</b>
If you copy the code from this topic and paste it into the IDE, delete any characters or spaces that offend the
compiler. On a 64-bit computer, you must replace <b>L</b>
with <b>bstr_t()</b> for the strings in the MessageBox.<br>&nbsp;</span></font></p></li>
<li class=kadov-p>
<p class=MsoNormal>Specify the project configuration properties:</p>
<ol>
<li>
<p class=MsoNormal>Right-click the project name in Solution Explorer and
select <b>Properties</b>.</p></li>
<li>
<p class=MsoNormal>Select <b>Configuration Properties &gt; General</b>.<br>
<br>
Ensure that the properties are configured as:</p>
<ul>
<li>
<p class=MsoNormal>Output Directory:
<b>$(SolutionDir)$(Platform)\$(Configuration)\</b></p></li>
<li>
<p class=MsoNormal>Configuration Type: <b>Dynamic Library (.dll)</b></p></li>
<li>
<p class=MsoNormal>Use of MFC: <b>Use MFC in a Shared DLL</b></p></li>
<li>
<p class=MsoNormal>Use of ATL:<b> Dynamic Link to ATL</b></p></li>
<li>
<p class=MsoNormal>Character Set: <b>Use Unicode Character Set</b></p></li>
</ul>
</li>
<li>
<p class=MsoNormal>Select <b>Linker &gt; General</b>.<br>
<br>
Ensure Output File is:</p>
<ul>
<li>
<p class=MsoNormal>&nbsp;<b>$(SolutionDir)$(Platform)\$(Configuration)\$(TargetName)$(TargetExt)</b></p>
</li>
</ul>
</li>
<li>
<p class=MsoNormal>Select <b>Linker &gt; Input</b>.<br><br>Ensure that Module Definition File is
<b>.\</b><i>project_name</i><b>.def</b>.</p></li>
<li>
<p class=MsoNormal>Select <b>Linker &gt; Embedded IDL</b>.<br><br>Ensure the properties are configured as follows:</p>
<ul>
<li>
<p class=MsoNormal>Type Library:
<b>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName).tlb</b></p>
</li>
<li>
<p class=MsoNormal>TypeLib Resource ID should be empty. Delete any
characters appearing in this row.</p></li>
</ul></li>
<li>
<p class=MsoNormal>Select <b>MIDL &gt; General</b>.<br><br>Select the environment in the Target Environment<i>
</i>dropdown that
most closely matches your environment.</p></li>
<li>
<p class=MsoNormal>Select <b>MIDL &gt; Output</b>.<br><br>Ensure the properties are configured as follows:</p>
<ul>
<li>
<p class=MsoNormal>Output Directory:
<b>$(SolutionDir)$(Platform)\$(Configuration)\</b></p></li>
<li>
<p class=MsoNormal>Type Library: <b>$(IntDir</b><i>)project_name.</i><b>tlb</b></p></li>
</ul></li>
</ol></li>
<li class=kadov-p>
<p class=MsoNormal>Click <b>OK</b>.</p></li>
<li class=kadov-p>
<p class=MsoNormal>To change the project's type of configuration to <b>
Release</b>:</p>
<ol>
<li>
<p class=MsoNormal>In the Solution Explorer, right-click <b>Solution </b>'<i>project_name</i>'<b> </b>
and select <b>Configuration Manager.</b></p></li>
<li>
<p class=MsoNormal>Click the down-arrow key in the project's Configuration
column and select <b>Release. </b></p></li>
<li>
<p class=MsoNormal>Click<b> Close</b>.</p></li>
</ol></li>
<li class=kadov-p>
<p class=MsoNormal>Save and compile
the project for either x32 or x64 to create an add-in DLL that is compatible
with your system. <br><br><span style="font-family: Verdana" lang="en-us">
<b>NOTE</b>: See <a href="Using_NET_Framework_in_Addins.htm">Using .NET Framework in Add-in Applications</a>
if a problem occurs at runtime.</span><br>&nbsp;</p></li>
<li class=kadov-p>
<p class=MsoNormal>Add the new add-in, <i>project_name</i><b>.dll</b>, to
the file vault:<span lang=EN-US style='mso-ansi-language:EN-US'><br>&nbsp;</span></p>
<ol style="font-family: Verdana; font-size: 8pt">
<li><span lang=EN-US style='mso-ansi-language:EN-US'>Start up the SOLIDWORKS
PDM Professional <a href="AdminDlg.htm">Administration tool</a>.<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. Log in, if prompted.<br>&nbsp;</span></li>
<li><span lang="en-us">Right-click <b>Add-ins</b> and select <b>New
Add-in</b>.<br>&nbsp;</span></li>
<li><span lang="en-us">Select:<br>
&nbsp;</span><ul style="font-family: Verdana; font-size: 8pt">
<li><span lang="en-us">x32: </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\</i><b>Release</b><i>\project_name</i><b>.dll</b>, and click
<b>Open</b>.<br>
&nbsp;</span></li>
<li><span lang="en-us">x64: </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\</i><b>x64</b><i>\</i><b>Release</b><i>\project_name</i><b>.dll</b>, and click
<b>Open</b>.<br><br>The add-in <b>Properties</b> dialog displays the add-in's name,
company, add-in version, required version of SOLIDWORKS PDM Professional,
package, and description.<br>&nbsp;</span></li>
</ul>
</li>
<li><span lang="en-us">Click <b>OK</b>.</span></li>
</ol>
<p class=MsoNormal>&nbsp;</p></li>
<li class=kadov-p>
<p class=MsoNormal>Right-click the list of vaults in File Explorer to
show the context menu:<br><br>
<img
border=0 width=166 height=298 id="_x0000_i1034" src=contextmenu.gif><br>The new menu item appears in the context menu.<br>&nbsp;</p></li>
<li class=kadov-p>
<p class=MsoNormal>Select <b>My first menu command</b> on the context-sensitive
menu.<br>
&nbsp;</p></li>
<li class=kadov-p>
<p class=MsoNormal>A message box is displayed.<br></span></p></li>
</ol>
<p>Use
your new add-in to
create <a href="cppmenuitem.htm">more advanced menu commands</a> or
<a href="cppreactor.htm">add-in hooks</a> that allow you to check files in and out of the vault.</p>
<p class=MsoNormal style='background:white'><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p>&nbsp;</o:p></span></p>
</div>
</body>
</html>