206 lines
13 KiB
HTML
206 lines
13 KiB
HTML
<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>Stand-alone Applications (VB.NET)</title>
|
|
<meta name=MS-HKWD content="Stand-alone applications">
|
|
<meta name=MS-HKWD content="Stand-alone applications, VB.NET">
|
|
<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>Stand-alone Applications (VB.NET)</h1>
|
|
|
|
<body bgcolor=white lang=SV link=blue vlink=purple style='tab-interval:65.2pt'>
|
|
|
|
<div class=Section1>
|
|
|
|
<p style='margin-bottom:12.0pt'>
|
|
This topic describes how to create a VB.NET stand-alone application that logs into
|
|
a SOLIDWORKS PDM Professional file vault and lists the files in the root folder. </p>
|
|
<ol style="font-family: Verdana; font-size: 8pt">
|
|
<li class=kadov-p>
|
|
<p style='margin-bottom:12.0pt'>
|
|
Start up Microsoft Visual Studio.</p></li>
|
|
<li class=kadov-p>
|
|
<p style='margin-bottom:12.0pt'>
|
|
Click <b>File > New Project</b> <b>></b> <b>Visual Basic > Windows Forms
|
|
App (.NET Framework)</b>.</p>
|
|
<ol type="a">
|
|
<li>
|
|
<p style='margin-bottom:12.0pt'>Type <font face="Verdana" style="font-size: 8pt"><b>
|
|
StandaloneApplicationVBNET</b></font> in <b>Name</b>.</p>
|
|
</li>
|
|
<li>
|
|
<p style='margin-bottom:12.0pt'>Click <b>Browse</b> and navigate to the folder where to create the
|
|
project.</p></li>
|
|
<li>
|
|
<p style='margin-bottom:12.0pt'>Click <b>OK</b>.</p></li>
|
|
<li>
|
|
<p style='margin-bottom:12.0pt'>Right-click the name of your project in the Solution Explorer and select
|
|
<b>Add Reference</b>
|
|
to add the SOLIDWORKS PDM Professional primary assembly interop to your project. </p>
|
|
<div class="Section1">
|
|
<ol>
|
|
<li><font style="FONT-SIZE: 8pt" face="Verdana">Browse to the top
|
|
folder of your SOLIDWORKS PDM Professional installation.</font> <br>
|
|
</li>
|
|
<li><font style="FONT-SIZE: 8pt" face="Verdana">Locate and click <b>
|
|
EPDM.Interop.epdm.dll</b>.<br>
|
|
</font> </li>
|
|
<li><font style="FONT-SIZE: 8pt" face="Verdana">Click <b>Open.</b></font>
|
|
<br>
|
|
</li>
|
|
<li><font style="FONT-SIZE: 8pt" face="Verdana">Click <b>Add.</b></font>
|
|
<br>
|
|
</li>
|
|
<li><font style="FONT-SIZE: 8pt" face="Verdana">Click <b>Close</b>.<br></font></li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>
|
|
<p style="MARGIN-BOTTOM: 12pt">
|
|
<span style="FONT-FAMILY: Verdana">C</span><span style="FONT-FAMILY: Verdana" lang="en-us">hange the
|
|
version of the .NET Framework and the </span>
|
|
<span style="FONT-FAMILY: Verdana">platform </span>
|
|
<span style="FONT-FAMILY: Verdana" lang="en-us">target.</span></p>
|
|
<div class="Section1">
|
|
<ol style="font-family: Verdana; font-size: 8pt" type="a">
|
|
<li><font style="FONT-SIZE: 8pt" face="Verdana">Click <b>Project ></b>
|
|
</font><font face="Verdana" style="font-size: 8pt"><b>
|
|
StandaloneApplicationVBNET</b></font><font style="FONT-SIZE: 8pt" face="Verdana">
|
|
<b>Properties > Compile</b> <b>> Advanced Compile Options</b>.<b><br>
|
|
</b></font></li>
|
|
<li>Set <b>Target CPU</b> to <b>AnyCPU</b>.<font style="FONT-SIZE: 8pt" face="Verdana">
|
|
<br>
|
|
</font></li>
|
|
<li>Keep suggested<font style="FONT-SIZE: 8pt" face="Verdana"> <b>Target
|
|
framework (all configurations) </b>or change it<b> </b>to<b> .NET Framework 4.5 </b>
|
|
(or later).<br></font></li>
|
|
<li>De-select <strong>Prefer 32-bit</strong>.<font style="FONT-SIZE: 8pt" face="Verdana"><b><br>
|
|
</b></font></li>
|
|
<li><font face="Verdana">Click<b> OK.<br>
|
|
</b></font></li>
|
|
<li>Click<b> Yes.</b></li>
|
|
</ol>
|
|
<p> </div></li>
|
|
<li class=kadov-p>
|
|
<p style='margin-bottom:12.0pt'>
|
|
<span style="font-family: Verdana" lang="en-us">Right-click <b>Form1.vb</b>
|
|
in the Solution Explorer and click <b>View Designer</b>.</span></p>
|
|
</li>
|
|
<li class=kadov-p>
|
|
<p style='margin-bottom:12.0pt'>
|
|
<span style="font-family: Verdana" lang="en-us">Click <b>View > Toolbox</b>.</span></p>
|
|
</li>
|
|
<li class=kadov-p>
|
|
<p style='margin-bottom:12.0pt'>
|
|
<span style="font-family: Verdana" lang="en-us">Drag </span>
|
|
<span lang=EN-US
|
|
style='font-family:Verdana'>a button from the Toolbox onto the form.</span></p>
|
|
</li>
|
|
<li class=kadov-p>
|
|
<p style='margin-bottom:12.0pt'><span lang="en-us">Double-click the button
|
|
to open <b>Form1.vb </b>and replace all of the code in the code window with</span><span lang=EN-US> the following
|
|
code. </span></p></li>
|
|
</ol>
|
|
<blockquote>
|
|
<pre style="font-family: Courier New; font-size: 13; color: black; background: white"><span style="color:blue;">Imports</span> EPDM.Interop.epdm
|
|
|
|
<span style="color:blue;">Public</span> <span style="color:blue;">Class</span> <span style="color:#2b91af;">Form1</span>
|
|
|
|
<span style="color:blue;">Private</span> <span style="color:blue;">Sub</span> Button1_Click(<span style="color:blue;">ByVal</span> sender <span style="color:blue;">As</span> System.<span style="color:#2b91af;">Object</span>, <span style="color:blue;">ByVal</span> e <span style="color:blue;">As</span> System.<span style="color:#2b91af;">EventArgs</span>) <span style="color:blue;">Handles</span> Button1.Click
|
|
<span style="color:blue;">On</span> <span style="color:blue;">Error</span> <span style="color:blue;">GoTo</span> ErrHandler
|
|
|
|
<span style="color:green;">'Create a file vault interface and log in to a vault</span>
|
|
<span style="color:blue;">Dim</span> vault <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmVault5</span> = <span style="color:blue;">New</span> <span style="color:#2b91af;">EdmVault5</span>
|
|
vault.LoginAuto(<span style="color:#a31515;">"<i>MyVaultName</i>"</span>, <span style="color:blue;">Me</span>.Handle.ToInt32)
|
|
|
|
<span style="color:green;">'Get the vault's root folder interface </span>
|
|
<span style="color:blue;">Dim</span> message <span style="color:blue;">As</span> <span style="color:blue;">String</span>
|
|
<span style="color:blue;">Dim</span> file <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmFile5</span>
|
|
<span style="color:blue;">Dim</span> folder <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmFolder5</span>
|
|
folder = vault.RootFolder
|
|
|
|
<span style="color:green;">'Get position of first file in the root folder </span>
|
|
<span style="color:blue;">Dim</span> pos <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmPos5</span>
|
|
pos = folder.GetFirstFilePosition
|
|
<span style="color:blue;">If</span> pos.IsNull <span style="color:blue;">Then</span>
|
|
message = <span style="color:#a31515;">"The root folder of your vault does not contain any files."</span>
|
|
<span style="color:blue;">Else</span>
|
|
message = <span style="color:#a31515;">"The root folder of your vault contains these files:"</span> + vbLf
|
|
<span style="color:blue;">End</span> <span style="color:blue;">If</span>
|
|
|
|
<span style="color:green;">'For all files in the root folder, append the name to the message</span>
|
|
<span style="color:blue;">While</span> <span style="color:blue;">Not</span> pos.IsNull
|
|
file = folder.GetNextFile(pos)
|
|
message = message + file.Name + vbLf
|
|
<span style="color:blue;">End</span> <span style="color:blue;">While</span>
|
|
|
|
<span style="color:green;">'Show the names of all files in the root folder </span>
|
|
MsgBox(message)
|
|
|
|
<span style="color:blue;">Exit Sub</span>
|
|
|
|
ErrHandler:
|
|
<span style="color:blue;">If</span> vault <span style="color:blue;">Is</span> <span style="color:blue;">Nothing</span> <span style="color:blue;">Then</span>
|
|
MsgBox(<span style="color:#a31515;">"Could not create vault interface."</span>)
|
|
<span style="color:blue;">Else</span>
|
|
<span style="color:blue;">Dim</span> ErrName <span style="color:blue;">As</span> <span style="color:blue;">String</span>
|
|
<span style="color:blue;">Dim</span> ErrDesc <span style="color:blue;">As</span> <span style="color:blue;">String</span>
|
|
vault.GetErrorString(Err.Number, ErrName, ErrDesc)
|
|
MsgBox(<span style="color:#a31515;">"Something went wrong."</span> + vbLf + ErrName + vbLf + ErrDesc)
|
|
<span style="color:blue;">End</span> <span style="color:blue;">If</span>
|
|
|
|
<span style="color:blue;">End</span> <span style="color:blue;">Sub</span>
|
|
|
|
<span style="color:blue;">End</span> <span style="color:blue;">Class</span><span lang="EN-US" style="font-size: 10pt; font-family: Courier New"> </span></pre>
|
|
</blockquote>
|
|
<ol style="font-family: Verdana; font-size: 8pt" start="8">
|
|
<li>
|
|
<p class="APICODE" style="line-height: 11.3pt"><span lang="en-us">
|
|
<font face="Verdana" style="font-size: 8pt">Replace </font></span>
|
|
<span style="color: #a31515"><i><font face="Courier New">MyVaultName</font></i><font face="Verdana" style="font-size: 8pt">
|
|
</font></span><span lang="en-us">
|
|
<font face="Verdana" style="font-size: 8pt">in
|
|
the code with the name of a SOLIDWORKS PDM Professional vault on your
|
|
computer.</font></span></li>
|
|
<li>
|
|
<p class="APICODE" style="line-height: 11.3pt"><span lang="en-us">
|
|
<font face="Verdana" style="font-size: 8pt">Click <b>Debug >
|
|
Start Debugging</b> or press <b>F5</b>.</font></span><ol style="font-family: Verdana; font-size: 8pt" type="a">
|
|
<li>
|
|
<p class="APICODE" style="line-height: 11.3pt"><span lang="en-us">
|
|
<font face="Verdana" style="font-size: 8pt">Click <b>Button1</b> on the
|
|
form.<br><br>A message box is displayed that either contains the names of
|
|
the files in the root folder of the specified vault or informs you that the
|
|
root folder of the specified vault does not contain any files.</font></span></li>
|
|
<li>
|
|
<p class="APICODE" style="line-height: 11.3pt"><span lang="en-us">
|
|
<font face="Verdana" style="font-size: 8pt">Close the form.</font></span></li>
|
|
</ol></li>
|
|
</ol>
|
|
<ol style="font-family: Verdana; font-size: 8pt" start="7">
|
|
<li value="10">
|
|
<p class="APICODE" style="line-height: 11.3pt"><span lang="en-us">
|
|
<font face="Verdana" style="font-size: 8pt">Click <b>File > Save All</b>.</font></span></li>
|
|
</ol>
|
|
<h2 style='background:white'>
|
|
<span lang=EN-GB style='font-family:Verdana;mso-ansi-language:EN-GB'><o:p> See
|
|
Also</o:p></span></h2>
|
|
<p style='background:white'><a href="StandAloneAppCSharp.htm">Stand-alone
|
|
Applications (C#)</a></p>
|
|
<p style='background:white'><a href="StandAloneAppCpp.htm">Stand-alone Applications (C++)</a></p>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|