Using the ATL Object Wizard (Visual C++ 6)
The SolidWorks
API SDK, which includes the Visual
Studio 6 ATL Object Wizard,
expects that Microsoft Visual Studio 6.0 has been installed at C:\Program
Files.
NOTE: Some parameters and properties
may change between SolidWorks service packs. This is a known Microsoft
software issue; see "Q220137 - "MIDL
Changes the Case of Identifier in Generated Type Library" for details.
Also, according to Microsoft Corporation, this behavior is by design.
Creating a new SolidWorks Visual C++ 6.0 DLL
In Visual C++ 6, create a new project using the
ATL COM AppWizard, choose a project
location and name, and click OK.
Select Dynamic
Link Library (DLL) for Server
Type and click Finish.
Click OK.
On the ClassView
tab, right-click the top-level classes icon and select New
ATL Object.
Select SolidWorks
in the Category list.
Select the SwAddIn
icon on Objects and click Next.
On the Names
tab, type the name for your ATL object class in Short
Name.
On the SolidWorks
AddIn tab, select the options that you want the wizard to provide
skeleton code for and click OK.
Click Build,
Set Active Configuration, then
select the project configuration and click OK.
Click Project,
Settings.
On the C/C++
tab, select Preprocessor in Category. Type the full path to the
<install_dir>\samples\appcomm folder for your SolidWorks installation
in Additional include directories.
Append a semi-colon at the end of the filename and add the full path to
the main SolidWorks installation folder (the folder where sldworks.exe
resides).
Select the C++
Language in Category, select
Enable exception handling, and click OK.
In Step 4d, if you selected any option other than
that for sample PropertyManagerPage2 code, you must open the project’s
CPP file and make some edits. Near the top of the file and between the BEGIN_OBJECT_MAP() and the END_OBJECT_MAP()
lines of code, there is commented code. For every line of code that has
commented code, delete all of the code except the code inside the braces.
For example, to edit this line of code:
OBJECT_ENTRY(CLSID_vvv, /* Replace this
line with the string in the braces {OBJECT_ENTRY_NON_CREATEABLE(CPart)}*/)
Delete all of the code except the code inside the braces:
OBJECT_ENTRY_NON_CREATEABLE(CPart)
Your project should now successfully build.
Building the DLL registers the DLL for use with the SolidWorks add-in
manager. You can unload the DLL from the SolidWorks session by deselecting
it in the SolidWorks add-in
manager.