Author Topic: How to use Python with DesignCAD  (Read 380 times)


  • Newbie
  • *
  • Posts: 5
How to use Python with DesignCAD
« on: October 14, 2016, 11:21:44 AM »
Dear Members,

how can I use Python with DesignCad? Has anybody experience writing python scripts to operate by remote control DesignCAD?

I'm trying it with comtypes but I only get rudimentary access to DC. Are there any small examples? I didn't find anything in Forum.

Many thanks for your Answers.




  • Kindly Curmudgeon
  • Administrator
  • *****
  • Posts: 4152
Re: How to use Python with DesignCAD
« Reply #1 on: October 14, 2016, 01:35:08 PM »
Hi Zarathustra. Have you come down from the mountain yet? :)

Sorry, I don't have any experience with Python. Everyone seems to have their own pet scripting language, but Python isn't one that (as far as I know) anyone has yet tried to use with DesignCAD.
25 years with DesignCAD


  • Newbie
  • *
  • Posts: 5
Re: How to use Python with DesignCAD
« Reply #2 on: October 09, 2017, 09:06:29 AM »
Hello Members I'm down from the Mountain  ;)

Here is my first attempt with COM and Python. It think it should work. I tested with DC23.

import sys
import wx
from comtypes.client import GetActiveObject as gao
from ctypes import c_double, byref

def Mitteilung(Titel, Nachricht):
    app = wx.App()
    frame = wx.Frame(None)
    wx.MessageDialog(None, Nachricht, Titel, wx.OK | wx.ICON_INFORMATION).ShowModal()

def main():
        DcApp = gao("DesignCAD.Application.23")
        Mitteilung("Makro Einspurmodell","Einspurmodell gestartet!")
        Mitteilung("Kein DesignCAD", "Bitte zuerst DesignCAD starten, Abbruch!")

    DcApp.Visible = True

    DcDoc = gao("DesignCAD.DCD-Document.23")

    DcPlane = DcDoc.Plane
    DcCurve = DcDoc.Curve
    DcPts = DcDoc.CmdPoints

    x = c_double()
    y = c_double()
    z = c_double()
    DcPts.GetUserPoint(byref(x), byref(y), byref(z))

    DcPts.SetCommandPoint(0. + x.value, 0. + y.value, 0. + z.value)
    DcPts.SetCommandPoint(10. + x.value, 0. + y.value, 0. + z.value)
    DcPts.SetCommandPoint(5. + x.value, 8.6667 + y.value, 0. + z.value)
    DcPlane.DrawType = 0

if __name__ == '__main__':

There is only a Messagebox from wxPython, therefore "import wx". But in future, i try to use wxPython for  GUI-Programming because of wxFormbuilder for design GUI-Layout.

It was hard for myself to find out how to get values from GetUserPoint. It doesent work for me with win32com.client etc.
You should use oleview.exe to get the Names of the registred Class-Names.

Next Tests are with numpy array and SetCommandPoints

I hope it's not to hard for me...

Greetings from Düsseldorf, Germany