Book Review: SolidWorks 2008 API

SolidWorks 2008 API Programming & Automation is recent self-published book by Luke Malpass, founder of AngelSix.  (You will not find his book on Amazon.)  Mr. Malpass wrote this book to fill an apparent gap in guide books about SolidWorks API.  The last book that I know of written specifically on this topic was Automating SolidWorks 2006 using Macros by Mike Spens, published way back in 2005.  Like that book, Mr. Malpass’ new book is spiral bound.

Mr. Malpass states in his introduction that he wrote his book to share his “ways of thinking and programming and hopefully to enlighten at least one other person’s day.”  Much of the book is written in this same friendly manner.  At times, the book is not written in a way that some would consider professional.  Yet, he gets his points across clearly.  The book is accessibly readable by experienced and novice programmers alike. 

The first chapter is correctly labelled “The Basics”.  The first section gets right into the task at hand. The lesson teaches how to make and use recorded macros.  The book next jumps right into writing macros from scratch.  It takes a step by step approach that reveals what code is necessary.  It explains each line in Mr. Malpass’ ever present friendly style. 

As one reads through the book, they will find code examples being built and explained piece by piece in both C# and VBA.  These macros are real world examples that the reader may find immediately useful.  Instructions are so clear that many will be able to apply the demonstrated code in their own macros.

One good example of this is found in the first chapter.  Right near the beginning of the book, Mr. Malpass provides instructions on how to make a macro that save each drawing sheet as an individual DXF File automatically.  This example is great because this question actually comes up a lot in the online message forums.

Many more important topics are extensively covered.  These include working with selected objects, implementation of Property Manager Pages, traversing through each type of document, Custom Property Manager, working with drawings, use of forms, and how to create and use Add-ins (something of special interest to many).  Additionally, all macro examples within the book are included in completed form on a CD. 

Of course, the book covers both C# and VBA code examples.  However, it also often talks extensively about VB.NET.  I found the instructions regarding VB.NET to be distracting, especially since few VB.NET examples appear in the book except for one section written specifically for it.  Granted, VB.NET and VBA are very similar.  However, in my opinion, differences are enough to warrant specific examples for each language.  It should be noted that some VB.NET examples are provided on the CD.  It seems to me that this book may have been better served if it focused on VB.NET and VBA instead of C# and VBA.  C# may have been better handled within its own book.  This would’ve allowed for more room in the book for more specific examples on even more topics, such as more information on how to read and utilize data from external files or methods specifically addressing the handling of BOM’s. 

One minor point of concern I found is within statement of ownership by the author.  It’s a boiler plate “all rights reserved” statement that limits reproduction or distribution without written permission of the publisher.   As this applies to the book itself, I stand by such statements.  However, in my view, it is not practical to place such limitations on code examples.  Doing so kind of defeats the purpose of the book.  That is not to say an author should not hold control over their works, but that if an author chooses to provide examples on how to do something, limitations should not be placed on the examples themselves.   (SolidWorks Corp makes a statement in their API Help that grants permission for the unlimited use of their examples.)

That aside, my opinion is that this book is great for anyone with programming exposure and who wishes to learn how to apply that experience directly to SolidWorks.  It is not meant for the person that has never attempted to program, unless that person is a brave soul willing to dive right in to the process.  I believe this book will be useful for people from novices to those of advanced programming skill.  It may also be a good reference guide to professionally trained expert programmers for SolidWorks specific programming possibilities and requirements.  I recommend this book.

Disclaimer:  This review is unsolicited by the book’s author.  It is based on use of product that I purchased at full price.  I receive no compensation for referrals.

If you are interested in SolidWorks 2008 API Programming & Automation, it may be purchased here: AngelSix.com.

Setting up and using SolidWorks Revision Tables faster

I am sometimes surprized by the limited the adoption of the SolidWorks Revision Table.  This is a powerful tool for drawings within SolidWorks.  The Revision Table allows the user to create a drawing template with an easily updateable revision block already included.  The user doesn’t have to use a potentially unstable Excel inserted OLE.  They also do not need a drawn revision block that requires significant labor in order to update and maintain.

The SolidWorks Revision Table is easy to insert in SolidWorks 2008.  With a drawing open, just go to Insert pulldown>Tables>Revision Table.  Within the Revision Table Pane, pick the appropriate revision template.  Choose any desired options for the table. Choose OK.  The Revision Table will automatically appear in upper right corner.  Save the drawing template for future use.  (See Help for instructions to place the Revision Table at other locations on the drawing.  Also, more steps are required in 2007 and prior; but, they are intuitive to follow and provide more on-screen control over the table’s location.)

Custom Revision Tables can be created to suit the companies specific needs.  Right click on the table to use the RMB menu to access functions that provide methods to modify the table.  When modifications are complete, use the RMB menu Save As option to save the new table as a table template for future use.

To add a revision, simply right click on the Revision Table.  Choose Revisions>Add Revision.  A new revision row will appear with the next revision inserted.  Simply double click any field to add or modify its value.  LMB click outside of the table to set the edits.

Of course, there is a simpler way to add revisions to the Revision Table!  I’ve created a macro that provides a form which allows the quick addition of revisions to the Revision Table.  It’s called RevBlockControl.  It is much faster than directly creating and entering all the rows and values.  It has been recently updated, so if you already use this macro, please consider using the latest version.

RevBlockControl Form

Sample image of the macro form

To use the macro, place it in the macros folder under the SolidWorks folder.  If it doesn’t exist, create it.  Within SolidWorks, assign a custom key stroke to the macro and/or create a toolbar icon location for it.

It can be used for a variety of revision table set-ups, including standard recommended ASME types.  It is limited to 5 columns, though it is customizable without editing the code or a complex .ini file.  If editing the code is desired, everything is spelled out with descriptions for easy of use.  In fact, the code can be quickly edited to allow the macro to drive the drawing’s “Revision” custom property.  Additionally, there is a small .ini included in this current version.  It is simply a list of initials used by the Rev By field.  Edit it with NOTEPAD to add and delete names that will automatically appear within the Rev By field.

Even without the RevBlockControl macro, the easy of use of the SolidWorks Revision Table is well worth the few minutes of effort to set it up on a template.  With the RevBlockControl macro, adding revisions to a Revision Table is so fast that it is almost effortless when compared to other type of revision blocks.

Users, Choosers, and PDM-less Losers

It’s a fairly common topic on most of the SW fora: “How do I move/manage/protect my files?”.  I suppose someone needs to say it, just as a formality; it doesn’t take very long before someone replies, “You should get a PDM system!”

 Can I get a “Well, Duh!” from the congregation? [Amen, Hallelujah].

The fact is, the vast majority of the SW community are users, not choosers.  They work away in the arena provided by their employer: slow network, weak workstation, outdated software, leaky ceiling and bad coffee.  Users may have loud voices, but usually very little say in what they get to use.  They almost certainly don’t get to decide whether to install and use a PDM system, making the first salvo of well-meaning advice hollow. For whatever reason, management will not allow PDM implementation.

File Management Survival Skills

As CAD skills go, file management tends to get short shrift.  New users-in-training are preoccupied with more pressing issues like changing colors and constraining sketches.  They are in a hurry to get useful so that Sir Boss doesn’t second-guess his hiring decisions.  Especially true for small-to-medium sized businesses, where cost of CAD comes out of Sir Boss’ pocket.

At work, it gets worse.  Projects and priorities appear and change daily.  Many projects get idled or abandoned, and the SW files get scattered across a half-dozen network drives and “My Documents” folders.  Multiple files exist of some parts, leaving no one certain what truly belongs.  Parts get accidentally changed by ham-fisted noobs or over-eager bosses.  In many places, there is no formal ECN process or designated storage area for released files.

Get the picture?  I’ve seen it four times over in the last two years while doing contract work.

Case Study: A Client Awakens

There is hope for some.  My current assignment is at a metal fabrication place with three SW users, plus myself.  The engineering manager saw the mounting file management crisis and tasked me to address it.  PDM was out of the question, as there was no money or support from parent company.  We had to find another way.

The result was a system of protected folders acting as a vault for CAD files and a library for other documents.  The folders are protected using windows security and are owned by a “phantom” user, so that no individual can inadvertently change files under his own login.  So far, it works.  Not as good as PDM, but OK.

What was encouraging was that the manager saw the value of his CAD data.  CAD data is valuable information.  Design data does not come cheap.  Software, hardware, users, training, etc. are all pricey.  Even more costly are the mistakes that can result from mishandled or lost data.  Design data needs careful guardianship.

File Management Survival Skills

File management is a skill set that is no less important than sketching.  There are things every user should know how to do (or at least know can be done).  If you can not do any of these things, you should not be satisfied with your file management skills:

  • Move files to a new folder
  • Create copies of files for work or backup
  • Copy entire assemblies
  • Replace components in an assembly
  • Reconnect “lost” components to an assembly
  • What is a file’s “internal ID” and why it is important
  • Understand how SW finds components and references
  • Use your operating system to protect files and folders

Not a complete list, but enough to get one thinking.

How to use a Model’s Material directly on the Drawing

I should start out by saying that I personally advise against using the model’s Material value directly on a drawing (edit: for SolidWorks version 2008 and older; SW 2009 appears to have addressed some of the issues).  However, below is the instructions to do just this.

First, let me bring up three problems when it comes to materials and the SolidWorks Material Database naming convention.  One, the material names used in SolidWorks library are not correct.  In fact, in many cases they are not even the common names for those materials.  Two, for those of us who need accurate specification, the standards that define the materials are not mentioned of the library at all, making references to material incomplete.  Three, the names of the materials are not capitalized, so they are not formatted correctly to be used directly on a drawing in the first place.

A solution to these issues is to change your library to add this info and correct formatting or create a new library to do the same.   Another more common solution is to enter the information manually in a custom property within the model, then have that value pulled into the drawing via normal custom property linking, such as an annotation note with the following text: $PRPSHEET:”Material” or similar.  Make sure to identify which view you wish the data to be pulled from, within the Sheet Property window.

If you still wish to use the actual model’s material value (despite all of the above reasoning), there’s a couple extra steps (also involving the use of custom properties):

1.  In the model, create a custom property called something like Material at File>Properties>Custom tab.

2.   For the value of Material property, just click on the down arrow of the entry field and select Material.

3.  On the associated drawing, create similar custom property with the same name.  (Again, make sure to identify which view you wish the data to be pulled from, within the Sheet Property window.)

4.  For the value of the drawing’s Material custom property, type $PRP:”Material”

5.  Create an annotation note that links to the drawing’s Material custom property.  This will display the value of the model’s material directly on the drawing.

Into the “real” world.

Hello my name is Joe.  I have been working in the Engineering industry for about 7 months and been at my current job for almost 3 months. After graduating from Northwest Technical Institute in February of this year I had a vast amount of jobs to choose from. There are so many different possibilities in this field that I found myself not sure what to do or even what type of job I wanted. For most it seems that the starting pay is what drives them to decide on a certain job. I wanted to find a job that paid well and used a program I enjoyed using. I am from Minnesota, right around the Minneapolis area where there is a technical jungle of drafting and design jobs for entry level candidates to choose from. I was lucky enough to be offered an internship while I was still attending school so I was able to explore many options. Only one out of the 6 job offers I had used SolidWorks so I was more than willing to give them a chance. I couldn’t be happier with my decision, I work with some really great people and I love what I do.

After being in the industry for a while I began to realize how much I never learned in school about SolidWorks. I did some online research and I couldn’t believe how many resources were available to me. I found out about using macros to automate SolidWorks and have actually been helping my company develop a standardized way to do drawings and fill in title block/bill of materials information using macros. With the help of Matt Lorono and other online resources I have been able to customize macros and actually am able to understand a lot of the code it takes to make one.

If you are fresh out of school be sure to explore every option available to you, take every job interview you can. This will serve you greatly in the future because you are not only seeing what else is available to you but you are building relationships and networks of people that may want to hire you down the road if things don’t work out where you end up.

I’ll continue to document my journeys and keep you updated!