Skip to content

Debugging python script in cadwork
This section refers to calling the plugins from the Plugin Bar. If you want to debug a script in cadwork, then you can enable the console in User Test in the user settings. When cadwork is restarted, the console opens. In the console you will see the screen output, or errors.

User Test -> Userprofile -> Test Options... -> Console

GIF

Console

Bugs present in the script can be detected in the console.

Any print statements are also visible in the console.

1
print("hello world")

Print output in console:

Screenshot

Displayed Bug in console:

Screenshot

or use the debugger from Python IDLE.

Screenshot

Pycharm Professional

Remote debugging with the Python remote debug server configuration

Pycharm debug server configuration 💡

  • Install the pydevd-pycharm package on the remote machine by running the following command:

pip install pydevd-pycharm~=

for example, pip install pydevd-pycharm~=191.3490)

  • Modify the source code file as follows:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import math
# ==============this code added==================================================================:
import pydevd_pycharm

pydevd_pycharm.settrace('172.20.208.95', port=12345, stdoutToServer=True,
                        stderrToServer=True)


# ================================================================================================
class Solver:

    def demo(self, a, b, c):
        d = b ** 2 - 4 * a * c
        if d > 0:
            disc = math.sqrt(d)
            root1 = (-b + disc) / (2 * a)
            root2 = (-b - disc) / (2 * a)
            return root1, root2
        elif d == 0:
            return -b / (2 * a)
        else:
            return "This equation has no roots"


if __name__ == '__main__':
    solver = Solver()

while True:
    a = int(input("a: "))
    b = int(input("b: "))
    c = int(input("c: "))
    result = solver.demo(a, b, c)
    print(result)