DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

DrollTroll Wrestles the Python (or: Using Python to automate DesignCAD)

Started by DrollTroll, December 03, 2026, 08:00:57 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

DrollTroll

I've been playing with the python programming language for a while now, and needed some motivation to broaden my knowledge of it. A few days ago I ran across Zarathustra's older posts on his own efforts to make DesignCAD and python work together so I thought I'd give it a whirl.

One of my ever-present dissatisfactions with DesignCAD has been the lack of a proper native function to generate random numbers. Since python has one built-in, I thought this was the perfect marriage of python and DesignCAD.

The attached python file was tested with DesignCAD 2018 (it's what I had  handy at the time). It draws a line from 1 to 10 along X, with random variations along Y. It's not much of a project, but the useful part is the boilerplate that gets python and DesignCAD talking in the first place. The code is reasonably well commented. I hope you find it useful!

Forum limitations forced me to change the extension to .txt instead of .py -- change it back to use it with python.

I will note that I am using PyCharm as my python programming IDE -- I've found it quite helpful. However, you can use any decent programming text editor (PsPad, Notepad++, VS Code, etc.).

25 years with DesignCAD

DrollTroll

More progress!
The new sample can successfully instantiate DesignCAD if it's not running, and also demonstrates how to use the SetCommandPoints method to push out a whole set of points at once instead of doing it one at a time (and slowly) using SetCommandPoint.

As always, read the comments for more detailed info. And don't forget to change the extension to .py instead of .txt!
25 years with DesignCAD