Z depth

Discussions around the CAM Add-On of QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Indicate the post processor used.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
KHE
Active Member
Posts: 37
Joined: Sat Oct 09, 2021 9:54 pm

Z depth

Post by KHE » Sat Sep 07, 2024 8:29 pm

WIndows 11
Qcad
Version: 3.30.1.0 (3.30.1)
Internet: QCAD.org
Build Date: Jun 18 2024
Revision: 5067327
Qt Version: 5.13.2
Architecture: x86_64
Compiler: MSVC++ 14.0 (2015)

Is it possible to associate a z value to a vector in qcad. I have found a few posts describing a z value in the property editor but z does not show up in the property editor when I click an entity.
I'm exporting a .dxf file to v-carve pro and it can use a z value if I can provide it.

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

Re: Z depth

Post by CVH » Sun Sep 08, 2024 12:11 am

Hi,

First, QCAD is mainly 2D, several to many drawing tools may not return proper results or fail altogether.
Files with 3D content are loaded or saved just the same as 2D data where Z is typically zero.

A line segment in 3D is correctly measured in 3D and that may be longer than the projected shape displayed in 2D.
Besides that, the Z property has an important meaning in QCAD/CAM.
CAM-entities have a Z property different from zero depending their height above the substrate or their cutting depth.
Most of them live on a flat plane, plunging and retracting is straight up/down.
These CAM-entities are the content what is exported as for example G-Code.

See menu Edit .. Application Preferences .. Widgets .. Property Editor and enable displaying Z coordinates.
It might be required to restart QCAD.

You can manually adapt Z coordinates of selected entities by editing the Z property(-ies) in direct and then best done in a final stage.
For modifying the drawing afterwards with QCAD tools it can be required to flatten it back to 2D again.
See menu Misc .. Modify .. Flatten Drawing to 2D

Line segments endings may have different Z values but remind that a Circle or an Arc can only exist in a flat plane.
Some things may render faulty like an Ellipse or a bulging segment of a polyline.

Regards,
CVH

KHE
Active Member
Posts: 37
Joined: Sat Oct 09, 2021 9:54 pm

Re: Z depth

Post by KHE » Mon Sep 09, 2024 4:38 pm

Thank you, I tried but had strange results. Many of the vectors are arcs so it look like this will not work for me. Thanks again.

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

Re: Z depth

Post by CVH » Mon Sep 09, 2024 7:38 pm

As said, Arc entities can only exist in a flat plane governed by the Z coordinate of the center.
For the record: An arc or a circle on a slanted plane would be displayed as an ellipse(-arc) when projected to 2D.

And then arcs have no endpoints, they have end-angles.
If we would query the start point (x,y,z) of an arc then QCAD returns (center.x + cos(angle) * radius, center.y + sin(angle) * radius, center.z)
Meaning that the endpoints and the center have the same Z coordinate.

It is more problematic with bulging polyline segments.
A polyline segment is defined by its endpoints (vertices) and the bulging nature of the segment what is zero for a straight segment.
Converting that to a standalone arc (Explosion or to render on screen) gives us no center, radius or end-angles in direct.
That is all pure math.
The chord of the arc segment is the straight line between the two vertices and that can be in 3D.
The center is located on an orthogonal at the middle of the chord ... mid = (VN+VN+1)/2 => Zm = (ZN + ZN+1)/2 = Zcenter.
The central angle is by the bulging factor identity: bulge = tan(sweep/4) => sweep = 4*atan(bulge)
And that is enough to work it out for the center position.

One thing we are missing is the radius and that is the chord length divided by sin(sweep/2) ...
... And here QCAD fails because the chord length is measured in 3D (RVector.getDistanceTo(RVector) instead of RVector.getDistanceTo2D(RVector))

It would be right in 3D but then you need to project it to 2D to visualize.
Or one way, or the other way ... Or an arc in 2D or one in 3D.

That can look like this, the selection is one polyline what should be continuously connected:
The shape is rendered incorrect, and other properties can be faulty, like for example the polyline length.
OddLookingPolyline.png
OddLookingPolyline.png (29.13 KiB) Viewed 59592 times

You may also notice that QCAD won't save this shape as is (Command History)
Why :?: :!: Other 3D data is loaded and saved unchanged. e_geek


In the perspective of G-Code, a CW arc plunging to Z-10:

Code: Select all

Start = (4,2,0)
G2 X10 Y10 Z-10 I3 J4
Is perfectly OK and from above it would look like this online example
Don't assume that this is an arc (nor an ellipse) ... It is part of a spiral in 3D.
For the record: It is the best approach to plunge down cutting into the material.

Back to QCAD: The exact length of a spiral is not an easy task but there are good approximations.
From above it perfectly matches with an arc and there you have your third option:
- 2D arc what is already flat
- 3D arc projected to an ellipse in 2D
- 3D spiral projected to an arc in 2D
Perhaps the last approach is more suited for a 2D CAM associated with a 2D CAD like QCAD.


For what I know of V-carving it can be done in 2.5D and/or 3D.
The contour to carve with V-Carve is usually defined as flat given that your substrate is flat.
How cutter paths in 2D and 3D are generated is by V-Carve ...
... The central path offset at Z=0 to the contour is related to the depth of cut.
Projecting a design on a 3D substrate is manageable with V-Carve.

I generate my 2.5D contours myself with QCAD, these days in microns later converted to mm.
In microns because QCAD exploits fixed tolerances and may fail for 'ridicule' small numbers.
And I modify the 3D finishing path in the corners semi-manually, adapting Z directly in G-code.
I don't use V-Carve for that because A: Price, B: Inaccurate or fails for my engravings ... Again for small values ...
... My 4mm stylus has a 20-30° top angle and typically a top cutting edge of less than 0.1mm :wink:

When I upgrade my CNC with new motion controllers it will handle 1unit as a mm while it is a motion of 1 micron.
That way I can export my dxf in microns processing it with G21.

Regards,
CVH

Post Reply

Return to “QCAD/CAM”