News:

Please note new Forum URL: forum.designcad.com

Main Menu
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

Started by DrollTroll, Today at 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