SOLIDWORKS-Minecraft-Blog-SolidSolutions

What is SOLIDWORKS API?

SOLIDWORKS API is a gateway to automating your design process and data management. Using .NET compatible languages (VB, C#, C++) one can write small macros or build full-blown add-ins for modelling, routine edits and feeding data from one software package to another.

We at Solid Solutions offer bespoke coding on a consultancy basis. Be it a one-page input form, a PDM Pro custom task or a multiplatform app that talks to SOLIDWORKS – we have a team of automation specialists able to tackle a wide range of challenges.

But what can be done with API outside of office hours, just for fun? Well, it’s not very hard to implement some basic MINECRAFT functionality with a couple of macros. Let’s have a look at the process and some results!

Creating a Macro

  1. We start with a small 10x10x10mm cube model (could be any other size).
  2. Start recording a macro (Tools->Macro->Record).
  3. Perform the following steps by hand:
    • Select any face on the cube surface and start a new Sketch.
    • Use the Sketch -> Convert Entities command.
    • Boss extrude 10mm Blind without merging the result. Actual extrusion depth depends on the size of your initial cube.
    • Stop recording the macro, save it into a separate folder.

SOLIDWORKS-Minecraft-Blog-SolidSolutions

You will need to edit the code behind your macro to remove the selection part. This is done through Tools -> Macro -> Edit. Your macro code will look similar to one below:

SOLIDWORKS-Minecraft-Blog-SolidSolutions

This macro allows you to ‘draw’ cubes on top/below/next to other cubes. If bound to a keyboard shortcut or a spare mouse button this can be done very quickly.

But all of these cubes are grey, where are the Minecraft textures?!

Okay, this is where things get tricky. You will need some SOLIDWORKS API and VBA programming knowledge from here onward. I created some textured appearances and saved them as .p2m files in a sub folder next to my macro file. Then we add some bits of intelligence to the already existing macro:

SOLIDWORKS-Minecraft-Blog-SolidSolutions

I created two macros for ‘bark’ and ‘leaves. Now we can ‘draw’ some vegetation:

With some time and effort we can grow trees even:

SOLIDWORKS-Minecraft-Blog-SolidSolutions

 

SOLIDWORKS-Minecraft-Blog-SolidSolutions

In Conclusion

Here we have barely scratched the surface of what SOLIDWORKS API is capable of… Minecraft within SOLIDWORKS!

Now show this to the young people you know, maybe they will become SOLIDCRAFT Engineers one day.

Rodion Radchenko
Elite Applications Engineer

Solid Solutions Technical Team
Solid Solutions commenced business as a SolidWorks Training and SolidWorks Support provider in 1998 and has consistently achieved strong growth year-on-year to become the UK’s leading SolidWorks 3D CAD reseller. Growth has been completely organic and has been consistently driven by a focus on recruiting the best from academia and industry and by delivering high quality services to more than 4,000 customers. Our customers range widely in size and are drawn from a broad spectrum of industry sectors. SolidWorks software is used by over 2 million engineers and designers across the world. As a company we are dedicated and focused at providing first class training and support to help you realise the best return on your investment.


Categories: SOLIDWORKS 2017, Tips & Tricks, Usability

Comments
Last comment By: Ethan Kinney   Wed, 28 Jun 2017 12:57:00 +0000
By: Peter Brinkhuis
Nice one! Now I want to build my own game :D Pong or tetris maybe?
By: Peter Brinkhuis  Tue, 13 Jun 2017 10:09:00 +0000
By: Ethan Kinney
Haha, very cool. I made snake in solidworks and it's pretty fun to play. Might have to try creating a version of this!
By: Ethan Kinney  Wed, 28 Jun 2017 12:57:00 +0000
You are not authorized to view this page No results found! Suggestions: Check spelling, try a different search, or browse topics below.