Scripting - is there a python interface to QCad or in QCad?

Please use this forum to post feedback and suggestions related to QCAD.

Moderator: andrew

Post Reply
User avatar
Krischu
Premier Member
Posts: 150
Joined: Thu Jul 04, 2019 8:11 am

Scripting - is there a python interface to QCad or in QCad?

Post by Krischu » Thu Sep 26, 2019 1:19 pm

I understand that there is scripting in QCad in various manners from what I read. Is it correct that the scripting language is JS (javascript)?

Is there a plugin or bridge to python/jupyter notebooks to Qcad?

I would like to enumerate e.g. all entitites there are in a drawing and list their properties in a text mode output.

Reason behind: I have a very simple drawing and cannot figure out why it says it has an open contour.
So I thought I'd list them all and compare start- and endpoints.
--
Christoph

CVH
Premier Member
Posts: 3471
Joined: Wed Sep 27, 2017 4:17 pm

Re: Scripting - is there a python interface to QCad or in QCad?

Post by CVH » Thu Sep 26, 2019 2:58 pm

Krischu wrote:
Thu Sep 26, 2019 1:19 pm
I understand that there is scripting in QCad in various manners from what I read. Is it correct that the scripting language is JS (javascript)?
Yes.
Krischu wrote:
Thu Sep 26, 2019 1:19 pm
Is there a plugin or bridge to python/jupyter notebooks to Qcad?
There is a NO! somewhere on the forum.
Krischu wrote:
Thu Sep 26, 2019 1:19 pm
I would like to enumerate e.g. all entitites there are in a drawing and list their properties in a text mode output.
Done that dirty, script needs al lot of cleanup but runs.
Krischu wrote:
Thu Sep 26, 2019 1:19 pm
Reason behind: I have a very simple drawing and cannot figure out why it says it has an open contour.
So I thought I'd list them all and compare start- and endpoints.
Feel free to post the dxf.

Regards,
CVH

User avatar
Krischu
Premier Member
Posts: 150
Joined: Thu Jul 04, 2019 8:11 am

Re: Scripting - is there a python interface to QCad or in QCad?

Post by Krischu » Sun Sep 29, 2019 2:42 pm

I still have trouble with the drawing (DXF). I thought I had it checked already thoroughly but be it I reloaded the wrong one gain, forgot to save or whatsoever, some discontinuities creeped in.

I noticed that when I added another layer in which I wanted to add bending lines from the quarter arc points to the next quarter arc. Most of the time the lines (two point ~) snapped to "intersection". But some snapped to "endpoint" which made me to zoom in further finding that the ends were open or had an extra line piece dangling around



Now some scripting could be suitable to detect differing endpoint pairs
Attachments
Bildschirmfoto 2019-09-29 um 15.37.49.png
Bildschirmfoto 2019-09-29 um 15.37.49.png (8.89 KiB) Viewed 7466 times
M_Seite_1.dxf
(117.08 KiB) Downloaded 456 times
--
Christoph

CVH
Premier Member
Posts: 3471
Joined: Wed Sep 27, 2017 4:17 pm

Re: Scripting - is there a python interface to QCad or in QCad?

Post by CVH » Sun Sep 29, 2019 5:23 pm

For one:
My revision off that file is still on the forum.
It should be very easy to merge my result layer and your new additions.

That seems not to be the way you did it. :o
In the copy of the file included in this topic:
The lower leftmost 180 degree arc is off by too much.
In fact, it exit as two arcs and the placement of the centers if off.
But a lot of the placements are off.
Still.
Again.

I did a fast look for spooks: e_geek
As there were no chains, Find zeros below 0.01 units and 0.01 degrees reveiled none.
OG Poly from segments /0.00001 /No Simplify at the leftmost vertical.
The chain almost closes excluding the mentioned two arcs.
OG Poly from segments for the new and larger stretched hole.
The chain almost closes.
Select All sums 2Poly 18 circles and 2 arc.
So, no spooks.

And no under-trimmed entities. :!:
In investigating this copy I did not encounter the issue in the screengrab

Do you think scripting can solve this?
A extremely good A.I. might.

Question: Up to what point do you want a code to alter your drawing? :?:
eg.
What will it use for the lower horizontals Y: -8.2 or -8.193087 ??! e_confused
0.007 may look a little, even quite hard to make exactly, but it is still about 0.1% absolute.
What will it use for center Y of the lower arcs:
-1.2, -1.20011, -1.20022, -1.19849, -1.205972 ??! :?
Select all the 7 lower circles and look op X and Y.
X can't be equal .... Y should be as I am not mistaken.

In my revision I decided you probably needed -8.2, -1.2 and -4.7.
And most of the coordinates have only 1 digit I think.
A human thought that.
A human decided on that.

You can always try to code that. e_ugeek
First start with a problem description and isolate all the variants.
All the stupid things a user could ever do... :roll:

Regards,
CVH

User avatar
Krischu
Premier Member
Posts: 150
Joined: Thu Jul 04, 2019 8:11 am

Re: Scripting - is there a python interface to QCad or in QCad?

Post by Krischu » Sun Sep 29, 2019 5:34 pm

With all these findings you detected, do you think that I ever constructed these deviations by myself? Or isn't it Qcad destructing my drawing through moving entities around (e.g. copy/paste from another DXF)?

I'd better start constructing the part again from ground up and watch when it starts to get rotten.
--
Christoph

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 4939
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: Scripting - is there a python interface to QCad or in QCad?

Post by Husky » Sun Sep 29, 2019 7:27 pm

Krischu wrote:
Sun Sep 29, 2019 5:34 pm
With all these findings you detected, do you think that I ever constructed these deviations by myself? Or isn't it Qcad destructing my drawing through moving entities around (e.g. copy/paste from another DXF)?
@Krischu
Nobody is saying that you constructed the deviations on purpose but obviously QCAD has a lot of problems with this inaccuracies in your drawings. Nobody else of us has the same problems like you what means QCAD is doing a satisfying job.

We need to figure out why your drawing is inaccurate. Maybe it is just a lack of practice or maybe a kind of misunderstanding how to do things but thinking you could do a better job in scripting is something what I highly doubt.
Krischu wrote:
Sun Sep 29, 2019 5:34 pm
I'd better start constructing the part again from ground up and watch when it starts to get rotten.
I think that is a good start! Tell us when you run in trouble and we'll take it then from there. Ok?

Question: Do you use the grid to design your drawing?
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

CVH
Premier Member
Posts: 3471
Joined: Wed Sep 27, 2017 4:17 pm

Re: Scripting - is there a python interface to QCad or in QCad?

Post by CVH » Sun Sep 29, 2019 11:16 pm

Krischu wrote:
Sun Sep 29, 2019 5:34 pm
With all these findings you detected, do you think that I ever constructed these deviations by myself?
I still can't rule out the human factor.
Somethimes while I select and move:
It might be that I am not accurate in selecting a reference
or in the placement.
Not all references that should occur nearly at the same point are equal.
Somethimes a mouse click is not firm and doubles up.
Selecting is somethimes done too near and is handled as dragging.

When you see this happening it is easily undone.
But what happens as you can not make out the difference ....

There can be the coding factor too.
Values are mostly type float. Not that this is infinitly accurate.
Qcad has something as fuzzycompare with a tolerance of 1e-9.
In some funtions I come by truncation or rounding to 6 digits.
As default, user enrties are 6 digits too.
And recently I came across a function that exclude all endpoints of line segments in a poly.

The only strange thing is that a while ago the errors went up factor 100 and now start at digit 4-5.
If its a flaw, it is there allready a certain dozen updates.
The effect is traceable in the CXF definitions issued every update.

Maybe it is cumulative.

The best thing is to document it when discovered and within a reasonable undo range.

Regards,
CVH

User avatar
Krischu
Premier Member
Posts: 150
Joined: Thu Jul 04, 2019 8:11 am

Re: Scripting - is there a python interface to QCad or in QCad?

Post by Krischu » Mon Sep 30, 2019 8:30 am

Husky wrote:
Sun Sep 29, 2019 7:27 pm
...
Question: Do you use the grid to design your drawing?
No longer. When I was making my first steps in QCad I did but I abandoned and took grid snap out of my autosnap list.
--
Christoph

Post Reply

Return to “QCAD Suggestions and Feedback”