QCAD Python Visual scripring with Sverchok and Blender

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
ionut
Junior Member
Posts: 10
Joined: Mon Dec 09, 2024 10:58 am

QCAD Python Visual scripring with Sverchok and Blender

Post by ionut » Tue Jan 21, 2025 12:30 pm

What I am trying to do is basicaly this:

- create a live link between Sverchok and QCad.

This could be easy to do with a watchdog, that can be activated somehow with a checkbox.

Here is an example of reading a dxf file opened in QCad and creating 3D geometry in Blender.

Next - I will showcase the reverse.

https://www.youtube.com/watch?v=UBH8zfMW7o0

Question:

- on windows 11, it is possible to do with a javascript script to call somehow the revert function with a trigger outside qcad?

User avatar
andrew
Site Admin
Posts: 8779
Joined: Fri Mar 30, 2007 6:07 am

Re: QCAD Python Visual scripring with Sverchok and Blender

Post by andrew » Tue Jan 21, 2025 3:46 pm

If QCAD is running, you can load additional files or run a script by launching it again with the appropriate parameters:

For example, to trigger the revert menu, you can launch:

Code: Select all

qcad.exe -exec scripts/Pro/File/RevertFile/RevertFile.js
A more sophisticated solution would involve QFileSystemWatcher.

ionut
Junior Member
Posts: 10
Joined: Mon Dec 09, 2024 10:58 am

Re: QCAD Python Visual scripring with Sverchok and Blender

Post by ionut » Wed Jan 22, 2025 8:19 am

Thank you!

I will use the simple aproach!

I will come back with feedback if/how I've solved it.

ionut
Junior Member
Posts: 10
Joined: Mon Dec 09, 2024 10:58 am

Re: QCAD Python Visual scripring with Sverchok and Blender

Post by ionut » Tue Feb 11, 2025 9:22 am

Thank you for the tip! This code does the trick for me in python.
I've realised I don't need a live update.
But I can use a watchdog to do it if I would find it more conveninent.


import subprocess

# Set up the paths
qcad_path = "C:\\Users\.......\\Downloads\\qcad-3.31.2-pro-win64\\qcad-3.31.2-pro-win64\\qcad.exe" # Path to the exe
dxf_file = "model_export.dxf"

# The Revert comamnd
command = [qcad_path, "-exec", "scripts/Pro/File/RevertFile/RevertFile.js"]

# Run the comand
subprocess.run(command)

print("The DXF file has been reset in QCAD.")

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”