This year’s SolidWorks API programming contest, sponsored by CADSharp, brought in five fascinating submissions. This may seem like a low number, but I quite pleased considering the complexity of the contest. If you aren’t familiar with the contest rules, visit here.

My intention with the contest is that entrants would use geometry/topology traversal techniques to find the appropriate entities for mating. I did not, however, specify sufficient contest parameters to ensure this outcome, as I quickly discovered. Rather than penalizing the individuals who used alternative approaches that technically were within the boundaries of the contest, I have decided to awards prizes to all entrants.

Download submissions (.swp files)

Each .swp is named after the initials of the entrant. Let’s discuss each one, from shortest to longest:

1. rj.swp A very clever solution that utilizes the ability to put multiple statements on the same line as long as each statement can return a value. Even if you split up the conditional statements onto different lines, this macro still comes out to less than 30 lines. Rajat obtained the mating entities by hard-coding the feature names and considering the face order in the array returned by IFeature::GetFaces.

2. eq.swp Edgar’s 46 line solution locates and selects the exact edges necessary for mating by considering the order in which the edges were returned in certain arrays.

3. rb.swp Raghvendra’s macro, which comes out to 53 lines (discounting using a colon to place statements on the same line), traverses the feature tree while examining several criteria until the right faces for mating are found.

4. ik.swp At a mere 64 lines, Ivana’s macro represents a very efficient way to solve the problem without hard-coding feature names or the order in which desired entities appear in entity arrays.

5. cs.swp At 110 lines, Corey offers a straightforward use of geometry and topology traversal to solve the problem. This is similar to how I solved the problem, which you can see in kr.swp. Both of our solutions are largely unoptimized for minimal length but also have the advantage of being easier to read and understand.

Thanks again to everyone who took the time to enter our contest!

Did any of the techniques utilized stand out to you as particularly clever? Hopefully you can pick up some new programming tricks while looking over these submissions, just as I have.

Until next time,

Want to learn about future contests and new content? Sign up for our newsletter.