Update: Since I originally announced the contest, I made a small change to the model to make the solution easier. Please re-download the file set if your Base1 component does not have a fillet as shown above.
I am pleased to announce the second CADSharp.com SolidWorks API programming contest! (See results of first contest here.) In this edition, we’re going to test your skills involving assemblies. Here’s how to win one of three Amazon.com gift cards or a 3-month premium membership to CADSharp.com.
How To Enter and Win
- Download the example file set here and open both assemblies.
- Write a VBA macro in as few lines as possible that meets the conditions stated below.
- Submit the macro to email@example.com July 1, 12:00AM EST.
- The winners will be announced on our blog in July, along with everyone else who submitted a working macro, ranked from fewest lines to most lines.
Conditions for Success
- The only required precondition for running the macro is that “contest2_start.SLDASM” is active.
- After the macro runs, the resulting assembly has the same center of mass as “contest2_complete.SLDASM”.
- After the macro runs, the resulting assembly has the same degrees of freedom as “contest2_complete.SLDASM”. (The green cylinders can spin in place and no other components can move in any way.)
- The macro contains no hard coded physical property values: face areas, face normals, edge lengths, vertex coordinates, etc.
- The macro does not use IModelDocExtension::SelectByID2 to select entities for mating.
- The macro uses the Option Explicit statement.
- This problem is not intended to reflect any real life problem. It is simply a puzzle. As long as you achieve the result described above, you can use any tricks or shortcuts you can think of, regardless of whether they entail good programming practices.
- The models were created in SolidWorks 2012 but any version of the SolidWorks API may be used.
- Comments, blank lines, and lines resulting from a line continuation character (underscore) will not be counted in the final line count.
- Multiple variable declarations on one line (and similar syntax tricks) will be counted as separate lines.
- Any person may submit multiple solutions and I will only consider the submission with the fewest lines of code.
Three winners will be chosen based on the number of lines of code in their macro.
First prize: $100 gift card at Amazon.com.
Second prize: $50 gift card at Amazon.com.
Third prize: $50 gift card at Amazon.com.
Note: The Amazon gift cards can only be awarded to entrants who may purchase Amazon.com or one of its affiliates in Australia, Canada, United Kingdom, Germany, Italy, France, Spain, Netherlands, China, Brazil, India, Mexico, and Japan. Otherwise, a 2-month Power User membership (valued at $199) will be awarded instead. Optionally, a winner that is entitled to a gift card may choose to receive the 2-month CADSharp.com Power User membership instead.
The winners will be announced in July. May the best programmer win!
Want to learn about future CADSharp.com contests and new content? Sign up for our newsletter.
CADSharp is offering a 4-day live API training class titled “SolidWorks API Fundamentals” on August 4-7, 2015 in Los Angeles, CA, USA. Here’s what others have said about this class:
” Great intro to SolidWorks API. Extremely helpful to have the object hierarchies explained versus having to try to reverse-engineer the steps from a zillion API Help entries. Also really enjoyed the personal flair that Keith brings to his craft. Keith has helped me achieve my 15-year-old goal of learning the SolidWorks API. I now feel like, given sufficient time, I could write any macro anybody would need! “
” I used my new API skills in combination with DriveWorks a couple of weeks ago. I am amazed at how much easier it is now that I understand the API Help and API object model. Loved the interaction between peers and instructor. “
Why You Should Attend
<> Beginner-friendly. No previous programming experience required.
<> Small class size allows for excellent teacher-student interaction.
<> Complimentary one-year Premium membership to CADSharp.com is included.
<> Content is designed by the industry’s leading SolidWorks API trainer, Keith Rice, to make you proficient in SolidWorks API fundamentals quickly and without frustration.
Course Contents and Objective
Download an outline of the course here.
This course emphasizes the three fundamentals skills of SolidWorks API programming: 1) Programming using Visual Basic Applications, 2) Using the API Help, 3) Understanding the SolidWorks API Object Model. After the course, students should feel comfortable researching API calls and using those calls to create macros from scratch.
Major topics include: VBA programming essentials, macro recorder, API Help, SolidWorks API object model, opening and saving documents, configurations, custom properties, selection handling, system and document options, sketch creation, feature creation, feature traversal, feature editing, geometry and topology traversal, and more (if time allows).
The speed and contents of the course will be adjusted on the fly according to the attendees current skill level and automation needs. Most of the content in the last day is chosen by attendees.
1,199 USD per person
Invoices may be paid by check, wire transfer, or credit card. If by credit card, an additional 30 USD fee is included. Invoices will be sent out a week before the class starts.
Important: You are responsible for bringing your own computer.
Dates and Times
August 4 – August 7, 2015
Training is from 8:00 AM to 5:00 PM with an hour break for lunch.
Comfort Inn & Suites LAX Airport Inglewood, 4922 W Century Blvd, Inglewood CA 90304
Comfort Inn & Suites LAX is conveniently located near Los Angeles International Airport (LAX). Continental breakfast and airport shuttle are available to guests free of charge.
Registration is limited. Email me to register. Deadline is July 17!
I hope you can join me in Los Angeles for a great time of learning! Let me know if you have ANY questions.
Want to keep up with future content and training events? Sign up for our newsletter.
The SolidWorks 2015 API contains quite a few enhancements that I am excited to share with you. Here are some of the most significant:
- Access scenes.
- Insert a table-driven pattern feature.
- Get or set the components and transforms for interferences.
- Specify more document printing options.
- Create and access local curve- and sketch-driven patterns.
- Get type of body folder cut list.
- Specify more options when mirroring components in an assembly.
- Add a width mate to an assembly.
- Specify whether to print a specified layer when printing a drawing document.
- Get a feature’s folder.
- Move a feature to another location in the FeatureManager design tree of a part or assembly.
- Get all of the bodies that result from splitting a part.
- Modify a split-body feature by changing its split bodies.
- Specify more options when editing a mate in an assembly.
- Support for intersect features.
- Support for extracting Scanto3D information.
- Specify whether to keep or delete bodies in a multibody part.
- Divide a sketch segment into equally spaced sketch segments or points.
- Get the display dimension object for a specified pattern property or a sketch relation.
- Get the sketch segments that define the path of a structural member body.
- Specify more properties when creating a weldment gusset.
- Specify more properties when creating a structural member end cap.
- Specify more properties when creating cosmetic threads.
- Modify variable-pitch helix features.
Want to see the API interfaces and calls related to each of these topics? You need only open up the local API Help, go to the Index tab, and search for the “Release Notes” category. This will show all enhancements in SolidWorks 2015 SP0 in great detail.
As always, if you discover an area where the API is lacking, don’t be afraid to submit it to the SolidWorks API support team.
Want to keep up with future CADSharp.com content, webinars, and special offers? Sign up for our newsletter.