GithubHelp home page GithubHelp logo

justinsdk / dotscad Goto Github PK

View Code? Open in Web Editor NEW
755.0 52.0 103.0 17.45 MB

Reduce the burden of mathematics when playing OpenSCAD

Home Page: https://openhome.cc/zh-tw/openscad/

License: GNU Lesser General Public License v3.0

OpenSCAD 100.00%
openscad 3d-graphics cad 3d 3d-models geometry maze voronoi perlin-noise worley-noise

dotscad's Introduction

dotSCAD 3.3

Reduce the burden of mathematics/algorithm when playing OpenSCAD.

dotSCAD

Introduction

Some of my 3D models require complex mathematics/algorithm. I extract them into dotSCAD. Hope it helps when you're playing OpenSCAD.

The idea of the name dotSCAD comes from the filename extension ".scad" of OpenSCAD.

Getting started

OpenSCAD uses three library locations, the installation library, built-in library, and user defined libraries. Check Setting OPENSCADPATH in OpenSCAD User Manual/Libraries for details.

I set OPENSCADPATH to the src folder of dotSCAD so all examples here start searching modules/functions from src.

Every public module/function has the same name as the .scad file. Here's an example using the line2d module:

use <line2d.scad>

line2d(p1 = [0, 0], p2 = [5, 0], width = 1);

The library uses directories to categorize some modules/functions. For example, vx_circle.scad exists in voxel directory. Prefix the directory name when using vx_circle.

use <voxel/vx_circle.scad>

points = vx_circle(radius = 10);
for(pt = points) {
    translate(pt) square(1);
}

Examples

These examples incubate dotSCAD and dotSCAD refactors these examples. See examples.

examples

API Reference

2D Module

Signature Description
arc(radius, angle[, width, width_mode"]) create an arc.
hexagons(radius, spacing, levels) create hexagons in a hexagon.
line2d(p1, p2[, width, p1Style, p2Style]) create a line from two points.
multi_line_text(lines[, line_spacing, size, font, ...]) create multi-line text from a list of strings.
pie(radius, angle) create polyline2de a pie (circular sector).
polyline2d(points[, width, startingStyle, endingStyle, ...]) create a polyline from a list of [x, y] coordinates.
polygon_hull(points) create a convex polygon by hulling a list of points. It avoids using hull and small 2D primitives to create the polygon.
rounded_square(size, corner_r[, center]) create a rounded square in the first quadrant.

3D Module

Signature Description
crystal_ball(radius[, theta, phi, thickness]) create a crystal ball based on spherical coordinates (r, θ, φ) used in mathematics.
line3d(p1, p2[, diameter, p1Style, p2Style]) create a 3D line from two points.
loft(sections[, slices]) develop a smooth skin between crosssections with different geometries.
polyhedron_hull(points) create a convex polyhedron by hulling a list of points. It avoids using hull and small 3D primitives to create the polyhedron.
polyline3d(points, diameter[, startingStyle, endingStyle]) create a polyline from a list of [x, y, z].
rounded_cube(size, corner_r[, center]) create a cube in the first octant.
rounded_cylinder(radius, h, round_r[, convexity, center]) create a rounded cylinder.
sweep(sections[, triangles]) develop a smooth skin from crosssections with the same number of sides.

Transformation

Signature Description
along_with(points, angles[, twist, scale, method]) put children along the given path. If there's only one child, put the child for each point.
bend(size, angle[, frags]) bend a 3D object.
hollow_out(shell_thickness) hollow out a 2D object.
shear([sx, sy, sz]) shear all child elements along the X-axis, Y-axis, or Z-axis.
select(i) select module objects.
polyline_join(points) place a join on each point. Hull each pair of joins and union all convex hulls.

2D Function

Signature Description
bijection_offset(pts, d[, epsilon]) move 2D outlines outward or inward by a given amount. Each point of the offsetted shape is paired with exactly one point of the original shape.
contours(points, threshold) compute contour polygons by applying marching squares to a rectangular list of numeric values.
in_shape(shapt_pts, pt[, include_edge, epsilon]) check whether a point is inside a shape.
trim_shape(shape_pts, from, to[, epsilon]) trim a tangled-edge shape to a non-tangled shape.

2D/3D Function

Signature Description
angle_between(vt1, vt2) return the angle between two vectors.
bezier_smooth(path_pts, round_d[, t_step, closed, angle_threshold]) use bezier curves to smooth a path.
cross_sections(shape_pts, path_pts, angles[, twist, scale]) given a 2D shape, points and angles along the path, this function returns all cross-sections.
in_polyline(line_pts, pt[, epsilon]) check whether a point is on a line.
lines_intersection(line1, line2[, ext, epsilon]) find the intersection of two line segments. Return [] if lines don't intersect.
path_scaling_sections(shape_pts, edge_path) given an edge path with the first point at the outline of a shape, this function uses the path to calculate scaling factors and returns all scaled sections in the reversed order of the edge path.
midpt_smooth(points, n[, closed]) given a 2D path, this function constructs a mid-point smoothed version by joining the mid-points of the lines of the path.

Path

Signature Description
arc_path(radius, angle) create an arc path.
archimedean_spiral(arm_distance, init_angle, point_distance, num_of_points[, rt_dir]) get all points and angles on the path of an archimedean spiral.
bauer_spiral(n, radius = 1[, rt_dir]) create visually even spacing of n points on the surface of the sphere. Successive points will all be approximately the same distance apart.
bezier_curve(t_step, points) given a set of control points, this function returns points of the Bézier path.
bspline_curve(t_step, degree, points, knots, weights) B-spline interpolation using de Boor's algorithm.
curve(t_step, points[, tightness]) create a curved path. An implementation of Centripetal Catmull-Rom spline.
fibonacci_lattice(n, radius = 1[, dir]) create visually even spacing of n points on the surface of the sphere. Nearest-neighbor points will all be approximately the same distance apart.
golden_spiral(from, to, point_distance[, rt_dir)] get all points and angles on the path of a golden spiral based on Fibonacci numbers. The distance between two points is almost constant.
helix(radius, levels, level_dist[, vt_dir, rt_dir]) get all points on the path of a spiral around a cylinder.
sphere_spiral(radius, za_step[, z_circles, begin_angle, end_angle, ...]) create all points and angles on the path of a spiral around a sphere. It returns a vector of [[x, y, z], [ax, ay, az]].
torus_knot(p, q, phi_step) generate a path of The (p,q)-torus knot.

Extrusion

Signature Description
bend_extrude(size, thickness, angle[, frags]) extrude and bend a 2D shape.
box_extrude(height, shell_thickness, bottom_thickness[, offset_mode, chamfer, ...]) create a box (container) from a 2D object.
ellipse_extrude(semi_minor_axis, height[, center, convexity, twist, slices]) extrude a 2D object along the path of an ellipse from 0 to 180 degrees.
rounded_extrude(size, round_r[, angle, twist, convexity]) extrude a 2D object roundly from 0 to 180 degrees.
stereographic_extrude(shadow_side_leng) take a 2D polygon as input and extend it onto a sphere.

2D Shape

Signature Description
shape_arc(radius, angle, width[, width_mode]) return points on the path of an arc shape.
shape_circle(radius, n) return points on the path of a circle.
shape_cyclicpolygon(sides, circle_r, corner_r) return points on the path of a regular cyclic polygon.
shape_ellipse(axes) return points on the path of an ellipse.
shape_liquid_splitting(radius, centre_dist[, tangent_angle, t_step]) return shape points of two splitting liquid shapes, kind of how cells divide.
shape_path_extend(stroke_pts, path_pts[, scale, closed]) extend a 2D stroke along a path to create a 2D shape.
shape_pentagram(r) return shape points of a pentagram.
shape_pie(radius, angle) return shape points of a pie (circular sector) shape.
shape_square(size[, corner_r]) return shape points of a rounded square or rectangle.
shape_star([outer_radius, inner_radius, n]) create a 2D star.
shape_superformula(phi_step, m1, m2, n1, [n2, n3, a, b]) return shape points of Superformula.
shape_taiwan(h[, distance]) return shape points of Taiwan.
shape_trapezium(length, h[, corner_r]) return shape points of an isosceles trapezoid.

2D Shape Extrusion

Signature Description
archimedean_spiral_extrude(shape_pts, arm_distance, init_angle, point_distance, num_of_points, ...) extrude a 2D shape along the path of an archimedean spiral.
golden_spiral_extrude(shape_pts, from, to, point_distance, ...) extrude a 2D shape along the path of a golden spiral.
helix_extrude(shape_pts, radius, levels, level_dist, ...) extrude a 2D shape along a helix path.
path_extrude(shape_pts, path_pts, ...) extrude a 2D shape along a path.
ring_extrude(shape_pts, radius[, angle = 360]) rotational extrusion spins a 2D shape around the Z-axis.
sphere_spiral_extrude(shape_pts, radius, za_step, ...) extrude a 2D shape along the path of a sphere spiral.

Util

util/list

Signature Description
util/binary_search(sorted, target[, lo, hi]) search a value in a sorted list.
util/contains(lt, elem) return true if lt contains elem.
util/find_index(lt, test) return the index of the first element that satisfies the testing function.
util/dedup(lt, ...) eliminate duplicate vectors.
util/flat(lt[, depth]) return a new list with all sub-list elements concatenated into it recursively up to the specified depth.
util/reverse(lt) reverse a list.
util/slice(lt, begin, end) return a list selected from begin to end, or to the end of the list (end not included).
util/sorted(lt[, cmp, key, reverse]) sort a list.
util/sum(lt) use + to sum up all elements in a list.
util/swap(lt, i, j) swap two elements in a list.
util/zip(lts, combine) make a list that aggregates elements from each of the lists.
util/every(lt, test) test whether all elements in the list pass the test implemented by the provided function.
util/some(lt, test) test whether at least one element in the list passes the test implemented by the provided function.
util/count(lt, test) return the number of times test return true in the list.

util/random

Signature Description
util/choose(choices, seed) choose an element from the given list.
util/rand([min_value, max_value, seed_value]) generate a pseudo random number.
util/shuffle(lt[, seed]) randomizes the order of the elements.

util/string

Signature Description
util/parse_number(t) parse the string argument as an number.
util/split_str(t, delimiter) split the given string around matches of the given delimiting character.
util/sub_str(t, begin, end) return the part of the string from begin to end, or to the end of the string (end not included).

util/math

Signature Description
util/degrees(radians) convert a radian measurement to the corresponding value in degrees.
util/radians(degrees) convert a degree measurement to the corresponding value in radians.
util/polar_coordinate(point) convert from Cartesian to Polar coordinates.
util/spherical_coordinate(point) convert from Cartesian to Spherical coordinates (used in mathematics).
util/lerp(v1, v2, amt) linear interpolate the vector v1 to v2.
util/fibseq(from, to) generate a Fibonacci sequence.

util/set

Signature Description
util/set/hashset(lt, ...) model the mathematical set, backed by a hash table.
util/set/hashset_add(set, elem, ...) add an element to a hashset.
util/set/hashset_has(set, elem, ...) return true if a hashset contains the specified element.
util/set/hashset_del(set, elem, ...) del an element from a hashset.
util/set/hashset_len(set) return the length of the elements in a hashset.
util/set/hashset_elems(set) returns a list containing all elements in a hashset. No guarantees to the order.

util/map

Signature Description
util/map/hashmap(kv_lt, ...) map keys to values.
util/map/hashmap_put(map, key, value, ...) put a key/value pair to a hashmap.
util/map/hashmap_get(map, key, ...) get the value of the specified key from a hashmap.
util/map/hashmap_del(map, key, ...) delete the mapping for the specified key from a hashmap if present.
util/map/hashmap_len(map) return the length of a hashmap.
util/map/hashmap_keys(map) return a list containing all keys in a hashmap.
util/map/hashmap_values(map) return a list containing all values in a hashmap.
util/map/hashmap_entries(map) return a list containing all [key, value]s in a hashmap.

Matrix

Signature Description
matrix/m_determinant(m) calculate a determinant of a square matrix.
matrix/m_mirror(v) generate a transformation matrix which can pass into multmatrix to mirror the child element on a plane through the origin.
matrix/m_rotation(a, v) Generate a transformation matrix which can pass into multmatrix to rotate the child element about the axis of the coordinate system or around an arbitrary axis.
matrix/m_scaling(s) generate a transformation matrix which can pass into multmatrix to scale its child elements using the specified vector.
matrix/m_shearing([sx, sy, sz]) generate a transformation matrix which can pass into multmatrix to shear all child elements along the X-axis, Y-axis, or Z-axis in 3D.
matrix/m_translation(v) generate a transformation matrix which can pass into multmatrix to translates (moves) its child elements along the specified vector.
maxtrix/m_transpose(m) transpose a matrix.
matrix/m_replace(m, i, j, value) replace the aᵢⱼ element of a matrix.

Point Transformation

Signature Description
ptf/ptf_bend(size, point, radius, angle) transform a point inside a rectangle to a point of an arc.
ptf/ptf_circle(size, point) transform a point inside a rectangle to a point inside a circle.
ptf/ptf_ring(size, point, radius[, angle, twist]) transform a point inside a rectangle to a point of a ring.
ptf/ptf_rotate(point, a, v) rotate a point a degrees around the axis of the coordinate system or an arbitrary axis.
ptf/ptf_sphere(size, point, radius[, angle]) transform a point inside a rectangle to a point of a sphere.
ptf/ptf_torus(size, point, radius[, angle, twist]) transform a point inside a rectangle to a point of a torus.
ptf/ptf_x_twist(size, point, angle) twist a point along the x-axis.
ptf/ptf_y_twist(size, point, angle) twist a point along the y-axis.

Triangle

Signature Description
triangle/tri_circumcenter(shape_pts) return the circumcenter of a triangle.
triangle/tri_incenter(shape_pts) return the incenter of a triangle.
triangle/tri_ear_clipping(shape_pts[, ret, ...]) triangulation by ear clipping.
triangle/tri_delaunay(points[, ret]) Join a set of points to make a Delaunay triangulation.
triangle/tri_delaunay_indices(d) return triangle indices from a delaunay object.
triangle/tri_delaunay_shapes(d) return triangle shapes from a delaunay object.
triangle/tri_delaunay_voronoi(d) return Voronoi cells from a delaunay object.
triangle/tri_subdivide(shape_pts[, n]) subdivide a triangle n times.

Turtle

Signature Description
turtle/footprints2(cmds[, start]) drive a turtle with ["forward", length] or ["turn", angle]. This function is intended to use a turtle to imitate freehand drawing.
turtle/footprints3(cmds[, start]) a 3D verion of footprint2.
turtle/lsystem2(axiom, rules, n, angle[, leng, heading, ...]) 2D implementation of L-system.
turtle/lsystem3(axiom, rules, n, angle[, leng, heading, ...]) 3D implementation of L-system.
turtle/t2d(t, cmd, point, angle, leng) an implementation of Turtle Graphics.
turtle/t3d(t, cmd, point, unit_vectors, leng, angle) a 3D version of t2d.

Voxel

Signature Description
voxel/vx_ascii(char[, center, invert]) generate 8x8 voxel points of printable ASCII characters (codes 32dec to 126dec).
voxel/vx_bezier(p1, p2, p3, p4) return voxel-by-voxel points of Bézier Curve.
voxel/vx_circle(radius[, filled]) return points that can be used to draw a voxel-style circle.
voxel/vx_contour(points[, sorted]) return the contour which encircles the area.
voxel/vx_curve(points[, tightness]) the curve is drawn only from the 2nd control point to the second-last control point.
voxel/vx_cylinder(r, h[, filled, thickness]) return points that can be used to draw a voxel-style cylinder.
voxel/vx_difference(points1, points2) create a difference of two lists of points.
voxel/vx_from(binaries[, center, invert]) given a list of 0s and 1s that represent a black-and-white image. This function translates them into voxel points.
voxel/vx_gray(levels[, center, invert, normalize]) given a list of numbers (0 ~ 255) that represent a gray image. This function translates them into a list of [x, y, level]s.
voxel/vx_intersection(points1, points2) create an intersection of two lists of points.
voxel/vx_line(p1, p2) given two points. it returns points that can be used to draw a voxel-style line.
voxel/vx_polygon(points[, filled]) return points that can be used to draw a voxel-style polygon.
voxel/vx_polyline(points) return points that can be used to draw a voxel-style polyline.
voxel/vx_sphere(radius[, filled, thickness]) return points that can be used to draw a voxel-style sphere.
voxel/vx_union(points1, points2) create a union of two lists of points.

Part

Signature Description
part/cone(radius[, length, spacing, angle, void, ends]) create a cone for rotatable models.
part/connector_peg(radius, height[, spacing, void, ends]) create a connector peg.
part/joint_T(shaft_r, shaft_h, t_leng, thickness,[ spacing, center]) create a joint_T for rotatable models.

Surface

Signature Description
surface/sf_bend(levels, radius, thickness, depth[, angle, invert]) bend a photo.
surface/sf_ring(levels, radius, thickness, depth[, angle, twist, invert]) turn a photo into a ring.
surface/sf_solidify(surface1, surface2[, slicing]) solidify two square surfaces.
surface/sf_sphere(levels, radius, thickness, depth[, angle, invert)] map a photo onto a sphere.
surface/sf_square(levels, thickness, depth[, x_twist, y_twist, invert]) turn a photo into a twistable square.
surface/sf_torus(levels, radius, thickness, depth[, angle, twist, invert]) turn a photo to a torus.
surface/sf_curve(levels, curve_path, ...) curve a photo.
surface/sf_splines(ctrl_pts, row_spline, column_spline) generalized-spline surface.
surface/sf_thicken(points, thickness, ...) thicken a surface.
surface/sf_solidifyT(points1, points2, triangles) solidify two surfaces with triangular mesh.
surface/sf_thickenT(points, thickness, ...) thicken a surface with triangular mesh.

Noise

Signature Description
noise/nz_cell(points, p[, dist]) an implementation of Worley noise.
noise/nz_perlin1(x[, seed]) return the 1D Perlin noise value at the x coordinate.
noise/nz_perlin1s(xs[, seed]) return 1D Perlin noise values at x coordinates.
noise/nz_perlin2(x, y[, seed]) return the 2D Perlin noise value at the (x, y) coordinate.
noise/nz_perlin2s(points[, seed]) return 2D Perlin noise values at (x, y) coordinates.
noise/nz_perlin3(x, y, z[, seed]) return the 3D Perlin noise value at the (x, y, z) coordinate.
noise/nz_perlin3s(points[, seed]) return 3D Perlin noise values at (x, y, z) coordinates.
noise/nz_worley2(x, y[, seed, grid_w, dist]) return the 2D Worley noise value at the (x, y) coordinate.
noise/nz_worley2s(points[, seed, grid_w, dist]) return 2D Worley noise values at (x, y) coordinates.
noise/nz_worley3(x, y, z[, seed, grid_w, dist]) return the 3D Worley noise value at the (x, y, z) coordinate.
noise/nz_worley3s(points[, seed, grid_w, dist]) return 3D Worley noise values at (x, y, z) coordinates.

Voronoi

Signature Description
voronoi/vrn2_cells_from(points) create cell shapes of Voronoi from a list of points.
voronoi/vrn2_cells_space(size, grid_w[, seed]) create cell shapes of Voronoi in the first quadrant.
voronoi/vrn2_from(points[, spacing, ...]) create a Voronoi from a list of points.
voronoi/vrn2_space(size, grid_w[, seed, spacing, ...]) create a Voronoi in the first quadrant.
voronoi/vrn3_from(points[, spacing]) create a 3D version of Voronoi.
voronoi/vrn3_space(size, grid_w[, seed, spacing]) create a Voronoi in the first octant.

Maze

Signature Description
maze/mz_square([rows, columns, start, init_cells, x_wrapping, y_wrapping, seed]) return cell data of a square maze.
maze/mz_square_get(cell, query) a helper for getting data from a square-maze cell.
maze/mz_squarewalls(cells, cell_width[, left_border, bottom_border]) a helper for creating square wall data from maze cells.
maze/mz_hexwalls(cells, cell_radius[, left_border, bottom_border]) a helper for creating hex wall data from maze cells.
maze/mz_square_initialize(rows, columns, mask) a helper for initializing cell data of a maze.
maze/mz_hamiltonian(rows, columns[, start, seed]) create a hamiltonian path from a maze.
maze/mz_theta_cells(rows, beginning_number[, start, seed]) return cell data of a theta maze.
maze/mz_theta(rings, beginning_number[, start, seed]) return cell data of a theta maze.
maze/mz_tiles(cells[, left_border, bottom_border]) turn maze cells into tiles.

Polyhedra

Signature Description
polyhedra/star([outerRadius, innerRadius, height, n]) create a 3D star.
polyhedra/polar_zonohedra(n[, theta]) create a polar zonohedra.
polyhedra/tetrahedron(radius[, detail]) create a tetrahedron.
polyhedra/hexahedron(radius[, detail]) create a hexahedron.
polyhedra/octahedron(radius[, detail]) create a octahedron.
polyhedra/dodecahedron(radius[, detail]) create a dodecahedron.
polyhedra/icosahedron(radius[, detail]) create a icosahedron.
polyhedra/superellipsoid(radius[, detail]) create a superellipsoid.

Point Picking

Signature Description
pp/pp_disk(radius, value_count[, seed]) generate random points over a disk.
pp/pp_sphere(radius, value_count[, seed]) pick random points on the surface of a sphere.
pp/pp_poisson2(size, r[, start, k, seed]) perform poisson sampling over a rectangle area.
pp/pp_poisson3(size, r[, start, k, seed]) perform poisson sampling over a cube space.

dotscad's People

Contributors

chill1n avatar frandias avatar justinsdk avatar kniight avatar lorf avatar vaaski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotscad's Issues

Error message in rounded_cube

i got an Error-message when using rounded_cube with an array:

rounded_cube(size=[20,20,20],corner_r=.5,center=false);

There seem to be 2 unnecessary lines in rounded_cube.scad:

half_l = half_x - edge_d;
half_w = half_y - edge_d;
half_h = half_z - edge_d;

// half_cube_leng = size / 2; // produced the error
// half_leng = half_cube_leng - edge_d;

pair = [1, -1];
corners = [
    for(z = pair) 

Archimedean spiral with non-approximated spacing

Hi there,

I'm currently working on a project that involves your excellent Archimedean spiral code. It's sort of a locking gear mechanism, and requires that things line up perfectly:

image

As you can see, the holes are spaced just a bit too close together, which I think is due to the approximation you mention in the document above.

I'll continue trying to work out the math on my own, but I haven't had much success so far.

Thanks!

arc_path request

Hello,
Thanks for sharing this awesome library.

I'm on a project and actually missing the arc_path, like there is a circle_path.
This seems somehow already implemented in the 2D-arc, generating a shape...
Is't possible for creating only an arc_path?

Thanks.

path_extrude closed option generates geometry that fails subsequent CGAL boolean operations

Hey I first off just wanted to say thanks for providing such a great set of libraries for openscad, they truely open up possibilities that I had always longed for in openscad. I've run into some issues using the library. I'm not confident saying they are issues with the library per say, I suspect I am just trying to do something which perhaps it isn't quite designed for. I've managed to do a workaround but I thought I'de mention it anyways just incase there is some tip you have that I've missed.

Unfortunately I don't have a minimal example currently, but I can try and put one together if you are interested. What I'm finding is that when I use the path_extrude functionality with the closed option as shown in the torus knot example at the end of https://openhome.cc/eGossip/OpenSCAD/lib3x-path_extrude.html (except with my own custom path), and perform subsequent operations I get a CGAL error. I always try and use "AXIS_ANGLE" as it provides the smoothest line segment. I then introduce a twist to ensure that whatever geometry I have is as precisely aligned as possible to match at the start and the end. (this helps eliminate the problem in some cases however not in others)

If I then attempt to perform a difference operation to subtract portions from the path extruded mesh, it will preview fine, but rendering often fails with a message like this "ERROR: Rendering cancelled by exception Unauthorized intersections of constraints". I've also seen it spit out more specific CGAL errors but I don't have any present right now. When I searched for them online it seemed like perhaps the generated geometry might not have been entirely valid (something about polyhedron invalid or something). The work around for me is to basically never use closed, but instead to render the path as two chunks which overlap on both sides then perform a union. It doesn't generate as perfect a geometry but it works ok for my purposes.

I was curious if you were aware of any potential issue with the geometry not being valid being generated between the last segment and the first segment when the closed parameter is supplied. I'm happy to try and put together a minimal example if it would help.

Cannot do a difference between two path_extrude() objects

I'm trying to make custom-made knife angle guide (e.g. https://www.amazon.com/JSSHI-Knife-Sharpening-Sharpener-Kitchen/dp/B07DVYB367). I was planning to use a few solids created with path_extrude(), but I've hit a snag. When I try to subtract two of them, I get nothing.

This is the source:
test.scad.txt and this is what it looks like:
image

If I draw the two objects with a(); #b();, they are drawn as in the picture. If I comment the two lines, and call difference() nothing is shown. Perhaps I'm missing something basic, but I expected to be able to subtract the solids.

"donut ring" using ellipse_extrude?

Looking for a way to do a rotate_extrude in openscad but with different x and y distances, meaning the resulting ring would be elliptical rather than a circle. ellipse_extrude seemed at first like what I'm looking for but seems to be something else when I actually try it out. Any suggestions? Thanks!

Can't make a seamless surface (cylinder) with sf_bend

Hello,

I am trying to use a picture to emboss a cylinder. So I have tried with sf_bend and a 360° angle. However I can't get a seamless junction at the edges even if the pixels on each border of the picture do have the same value. I have also tried with angles slightly bigger or smaller than 360° but it doesn't function.

convexity as optional parameter to sf_solidify

When previewing more complex shapes created via sf_solidify, it is often necessary to increase the complexity parameter passed to polyhedron (inside sf_solidify). It is currently necessary to modify the source code of sf_solidify itself to achieve this. It would be nice if you could make "convexity" an optional parameter to sf_solidify, sf_thicken, etc. which would simply be passed on to the internal polyhedron call.

Docs needs a table of contents page

I've found myself digging through the docs folder for the markdown file relevant to the module I'm trying to use, and opening the preview manually. It would be great if dotSCAD had a cheat sheet or table of contents with links to each file, a quick syntax example, and a short description like the OpenSCAD cheat sheet. It could even be updated dynamically in pretty much any language.

Currently it looks like every line has the function name on line 1 and the description on line 3.

Syntax would be a bit more difficult, but I think it's a necessary addition. Examples are great but any man page or powershell help also has syntax laid out.

A super rough example would be something like this:

Module Description Syntax
arc Creates an arc. You can pass a 2 element vector to define the central angle. Its $fa, $fs and $fn parameters are consistent with the circle module. arc(radius, angle[x,y], width);
archimedean_spiral Gets all points and angles on the path of an archimedean spiral. The distance between two points is almost constant. archimedean_spiral(arm_distance, init_angle, point_of_distance, num_of_points);
bend Bends a 3D object into an arc shape. bend(size = [x, y, z], angle) object();

Also, markdown supports triple-backtick code fencing which allows you to specify a language. With a proper language file, you can turn this
image

into this
image

by replacing the four-space with these: ```openscad

path_extrude.scad : scale parameter ignored for first sweep

Just discovered dotSCAD, and I'm loving it. But on to a little issue I tripped upon....

Looking at the docs, I would expect the following code would produce a sweep of three rectangles that get progressively larger from top to bottom. But the first 2 sections are identical. In fact, if one of member of points[] is removed, the shape is a cube.

use <path_extrude.scad>;

w=8;
h=3;


rect = [
    [   -w/2,   -h/2,   0],
    [   +w/2,   -h/2,   0],
    [   +w/2,   +h/2,   0],
    [   -w/2,   +h/2,   0],
];

points = [
    [0,0, 10],
    [0,0, 5],
    [0,0,0]
];

path_extrude(   shape_pts = rect,
                path_pts = points,
                scale = 1.5);

Code sample for a fully fluent turtle

Hi, please consider the code below.
It allows for constructing a polyline directly from a sequence of turtle commands. When constructing the list of 3D points, I automatically drop the turn commands which would produce duplicates.

It would also be interesting to add some commands to produce arcs in a straightforward way, but that is for another time.

use <turtle/t3d.scad>;
use <hull_polyline3d.scad>;

leng = 10;
angle = 120;
thickness = 1;

function drop_front(lst) =
  [ for (i=[1 : 1 : len(lst)-1]) lst[i] ];

function in(sub, s, i=0, j=0) = ( i==len(sub) ) 
  ? true
  : ( j==len(s) )
    ? false
    : in(sub, s, ( sub[i]==s[j] ) ? i+1 : 0, j+1);

function t3dc(pt, cmds, pts=[]) = (len(cmds) == 0) 
  ? concat(pts, [t3d(pt, "point")])
  : t3dc( t3d(pt, [cmds[0]]),
          drop_front(cmds), 
          concat( pts, in("turn", cmds[0][0]) ? [] : [t3d(pt, "point")] )
        );

pol = t3dc( t3d(point = [0, 0, 0]),
  [
    ["xforward", leng],
    ["zturn", angle],
    ["xforward", leng],
    ["zturn", angle],
    ["xforward", leng]
  ]
);   

hull_polyline3d(pol, thickness);

Readme is incomprehensible to newbie

The top of the readme for this project does not explain what it is, what it does or what it enhances in openscad. Ok, fair enough, it does say: "Reduce the burden of mathematics when playing OpenSCAD."

The beginning of the first sentence goes on about library install locations for OpenSCAD. But why do I need this information?

Is this a new standard library for openscad, or a new core for openscad? I still do not know.

Adding a section "What this is" to the top of the readme with a sentence or two would help a lot.

along_with has an element out of place

I'm doing along_with on a circular path (obtained from shape_circle) and it looks like some of the elements are out of place. It looks like some sort of off-by-one error, but I don't quite see it yet. Two views, one oblique and one from directly above:
Screenshot from 2022-04-13 18-13-51
Screenshot from 2022-04-13 18-14-29

Note the two adjacent slabs that are exactly parallel and aligned with each other on the right. Surely that shouldn't happen with a symmetrical path.

Also, all the other slabs aren't facing toward the center symmetrically, as I would have expected (am I wrong to expect that?)

If I get a chance I'll see if I can write a patch for this, but I thought I'd get the ticket made in the meantime.

bijection_offset.scad problem

The order of the ofsetted points is incorrect.
You will not notice it with polygon of the ofsetted shape, but it appears if you use polyline2d.

Tested with version 1.3.3

Example:
include <polyline2d.scad>;
include <line2d.scad>;
include <bijection_offset.scad>;

shape = [
[15, 0],
[15, 30],
[0, 20],
[-15, 40],
[-15, 0]
];

shape_o = bijection_offset(shape, 1);
color("green") polyline2d(points=shape,thickness=1,$fn=3);
color("red") polyline2d(points=shape_o,thickness=1,$fn=3);
echo(shape);
echo(shape_o);

path_extrude() artifacts when path touches Z axis

When path_extrude() given a path that touches axis parallel to Z, it produces some artifacts in the touch area. Code to reproduce:

include <../src/rotate_p.scad>;
include <../src/bezier_curve.scad>;
include <../src/polysections.scad>;
include <../src/path_extrude.scad>;

shape_pts = [[5, -5], [5, 5], [-5, 5], [-5, -5]]; // 10mm square

// Path produced with bezier_curve():
//curve_pts = [[20,20,0],[10,10,10],[20,20,20]];
//path_pts = bezier_curve(0.1,curve_pts);
path_pts = [[20, 20, 0], [18.2, 18.2, 2], [16.8, 16.8, 4], [15.8, 15.8, 6], [15.2, 15.2, 8], [15, 15, 10], [15.2, 15.2, 12], [15.8, 15.8, 14], [16.8, 16.8, 16], [18.2, 18.2, 18], [20, 20, 20]];

path_extrude(shape_pts,path_pts,triangles="SOLID");

Result:
image

The workaround is to rotate the path so that it doesn't touch Z:

include <../src/rotate_p.scad>;
include <../src/bezier_curve.scad>;
include <../src/polysections.scad>;
include <../src/path_extrude.scad>;

shape_pts = [[5, -5], [5, 5], [-5, 5], [-5, -5]]; // 10mm square

// Path produced with bezier_curve():
//curve_pts = [[20,20,0],[10,10,10],[20,20,20]];
//path_pts = bezier_curve(0.1,curve_pts);
path_pts = [[20, 20, 0], [18.2, 18.2, 2], [16.8, 16.8, 4], [15.8, 15.8, 6], [15.2, 15.2, 8], [15, 15, 10], [15.2, 15.2, 12], [15.8, 15.8, 14], [16.8, 16.8, 16], [18.2, 18.2, 18], [20, 20, 20]];

path_pts_tmp = [ for(p=path_pts) rotate_p(rotate_p(p, [0,0,45]),[0,90,0]) ];
rotate([0,-90,-45])
    path_extrude(shape_pts,path_pts_tmp,triangles="SOLID");

image

path_extrude() behavior incorrect in latest release(s) but correct in v1.0.0

Instead of a regular thread, I see a gradually rotated thread for increasing z.
With release v1.0.0 the behavior was correct, but with release v1.2.0 (and possibly older releases) the behavior is incorrect.
The code that shows this behavior is:

include <dotSCAD/rotate_p.scad>;
include <dotSCAD/polysections.scad>;
include <dotSCAD/path_extrude.scad>;

r = 10;
fa = 2;

shape_pts = [
// outer
[0,0],
[3, 1],
[0, 2]
];

path_pts = [
for(a = [0:fa:360 * 5])
[-r * cos(a), r * sin(a), a/100]
];

path_extrude(
shape_pts,
path_pts
);

The correct output result is shown below.

Screenshot at 2019-05-30 02-53-54

The incorrect output result is shown below.
Screenshot at 2019-05-30 02-57-31

Slicer says "empty layers" with output from sf_thicken/sf_splines?

Hi,
I am trying to model an old telescope pier, using measurements that were taken at various vertical intervals on its surface. It looks like this when rendered in openSCAD
image

This was modeled using dotSCAD because I needed the smooth curves and it renders without error.

When I pull it into a slicer (e.g. Prusa) though, I get an error saying there are empty layers in the area between the two "cube" calls in openSCAD, ie in the area created by the dotSCAD output. In Meshmixer it renders fine and does not have any issues flagged, that I can see. And using the "repair STL" option of Prusa doesn't fix anything. So I can't figure out where something is going goofy.

I'm wondering if there is any trick I should be aware of in trying to mate surfaces created using sf_thicken/sf_splines? Is there a better way to do this? I thought that by using common edges that I would largely avoid holes/gaps/etc.

I've attached a cleaned up version of the openSCAD file (with a .txt extension). Apologies for it's length.

TIA,
mconsidine
old_pier_demo.txt

Defining shapes for path_extrude to use

Hi,

Is it possible to change the shape_pts part way along, as the module moves it's way along the path_pts that it is given.

I want to start off as a 'U' shape and then change to half a 'U' shape.

Thanks for anyone who has any ideas.

Richard.

dotSCAD 2.3 assumes library is used at top level

Since dotSCAD 2.3 it's not possible anymore to use dotSCAD from a sub-directory, so as to have separated library namespaces.
I use dotSCAD library as follows:

use <dotSCAD/some_dotscad_library_name.scad>;

Since dotSCAD 2.3 this results in errors because some files/functions cannot be found anymore, e.g. when using: use <dotSCAD/helix_extrude.scad>;

this gives:
WARNING: Can't open library '_impl/_ptf_rotate_impl.scad'.
WARNING: Can't open library 'comm/__to2d.scad'.
WARNING: Can't open library 'comm/__to3d.scad'.
WARNING: Can't open library 'comm/__to_ang_vect.scad'.

This can be fixed by not assuming that the dotSCAD library is stored at top level. I propose to encode the organization of the dotSCAD directories explicitly in the relative paths of the "use" lines. Making these dependencies explicit improves the readability and usability of the code.

For instance for file: ptf/ptf_rotate.scad
Change
use <_impl/_ptf_rotate_impl.scad>;
to
use <../_impl/_ptf_rotate_impl.scad>;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.