Hi!
Before digging into the code here is the reason for my request:
I have to make a complex cut to a part: The cut has a section that can’t be calculated… Too complex.
The cut has an helical path, so this is not a problem to make an extrusion and a difference to get it.
But the only way I have to get the section to extrude is through another section of my part which is along the cut, but through a plane which is not perpendicular to the extrusion axis.
So to get the section to extrude I need to project the angled section on the XY plane, But I need to follow the helix angle to get the ‘flattened’ section that, once extruded with an helix angle, will pass through the angled one. This is easy to calculate, once you have access to the points of the inclined section… And I see no way to get that graphically from the angled section with OpenSCAD functions.
Obviously these points are used to draw the projected section, so it could be relatively easy to extract them from the code and create an XY array that can be processed to have the polygon data of the perpendicular section.
It might be simpler to do this within Openscad rather than exporting a DXF, process it, and reinject the processed DXF into Openscad.
Has anybody an idea to where I must look into the code to get this done?
Thanks
I'm not quite following what you're trying to do, but here are some hints...
There is not currently any way to extract coordinate data from the
model. OpenSCAD itself does not know the coordinates at the time that
the program is being executed. PR#4478 adds this feature, but there's
no estimate of when it might be available.
However, if all you need is a polygon, you may be able to use
projection(cut=true) to derive the polygon - if the polygon that you
want is a slice from some 3D figure, you need to rotate and translate
the 3D figure until the desired slice is on the Z=0 plane, and then
projection(cut=true) will give you that slice as a polygon. You could
then do normal polygon things with it - notably, extruding it, exporting
it as SVG, et cetera.
For instance, here's a 2D slice from a rotated cone:
projection(cut=true)
rotate([45,0,0])
cylinder(h=10,d1=10,d2=0);
Just to explain with pictures:
Here is the kind of surface that I have to create.
The surface profile is defined from a cut of the part along the plane labelled ‘Cutplane’ It is rotated about 12° from the top plane.
The section on the cut plane is obtained by the projection(cut=true) method.
The surface follows an helix with an axis perpendicular to the top plane. The only way to create an extrude object with a twist in OpenSCAD is to use the section in the top plane (XY plane). and extrude it, so I need to ‘project’ the cut plane section on the top plane to get the primitive for the extrusion, while staying on the twisted surface. Here is a top view to see the difference of the sections.
So the section on the XY plane has to be derived from the section on the cut plane following an helical path of known center and pitch. It’s easy to calculate as the plane’s intersection is going through the helix axis.
So if exporting the DXF is the only way to get the data of the cut plane section, I will go through this…
I think you're exceeding my ability to visualize 3D operations.
I think that what you're saying is that you have a polygon that is
tilted from the XY plane, and that what you want is to screw that
polygon down along a helical path and record the shape that it draws as
it passes through the XY plane.
Is that sort of right?
If so, yeah, sorry, no idea how to do it.
You're welcome to grab a copy of PR#4478 and play with it - please do -
and it will give you the polygon data.
For instance:
sq = {{ square(10); }};
sqpoly = render(sq);
echo(sqpoly);
yields (reformatted for readability):
ECHO: {
min : [0, 0, 0],
max : [10, 10, 0],
center : [5, 5, 0],
size : [10, 10, 0],
objects : [
{
points : [[0, 0], [10, 0], [10, 10], [0, 10]],
paths : [[0, 1, 2, 3]]
}
]
}