Repository navigation
Releases: emirmrkaljevic/mesh2cad
Releases · emirmrkaljevic/mesh2cad
Release list
v0.20.0
- A rectangular box with every edge filleted at one radius is rebuilt as one exact solid: 6 planes, 12 partial cylinders and 8 sphere octants. Each cylinder is tangent to the two walls it joins, each sphere is tangent to the three faces at that corner, and the fillet axis passes through the two corner centres. On a 40×30×20 mm box with r=3 mm this is exact on 3 of 3 seeds at 0, 0.05 and 0.2 mm noise. With no noise the radius error is 0.006 mm, the Hausdorff distance is 0.023 mm, and the volume error is 0.01%. At 0.05 mm the worst radius error is 0.007 mm and the Hausdorff is 0.035 mm (volume error 0.07%). At 0.2 mm the worst radius error is 0.112 mm and the Hausdorff is 0.116 mm (volume error 0.18%). A fillet that meets a sphere in any other layout is unchanged and still falls back to a valid solid. There is no new script parameter.
fillet_ris still only the four vertical corners of a rectangular base.
v0.19.0
- Parametric CadQuery, OpenSCAD, and FreeCAD export write a quarter-torus fillet on the box vocabulary as a named parameter.
boss_N_filletis the round at the base of a straight vertical boss.hole_N_rim_randhole_N_bot_rim_rare the rounds on the top and bottom rims of a vertical hole.hole_N_floor_ris the fillet where a blind hole's floor meets the wall.mesh2cad edit script.py --set boss_1_fillet=3(orhole_1_rim_r, orhole_1_floor_r) rebuilds the solid. A fillet whose axis is not Z is refused.fillet_ris still the four vertical corners of a rectangular base. An L-bracket fillet and a spherical corner stay on the STEP path. - With no noise the usual gate holds (max deviation at most max(4·tol, 0.1) = 0.1 mm, volume error at most 1%). The Ø16 boss with a 2 mm base fillet recovers
boss_1_fillet = 2.0. CadQuery deviates by 0.0099 mm (volume error 0.020%), OpenSCAD by 0.0099 mm (0.015%), FreeCAD by 0.0099 mm (0.025%). The Ø12 hole with a 1.5 mm top round recovershole_1_rim_r = 1.43. CadQuery 0.0274 mm (0.045%), OpenSCAD 0.0274 mm (0.043%), FreeCAD 0.0274 mm (0.047%). Both rims at 1.2 mm recover 1.14. CadQuery 0.0224 mm (0.027%), OpenSCAD 0.0224 mm (0.025%), FreeCAD 0.0224 mm (0.029%). The Ø10 blind hole with a 1.5 mm floor fillet recovershole_1_floor_r = 1.46and depth 12.0. CadQuery 0.0143 mm (0.006%), OpenSCAD 0.0138 mm (0.007%), FreeCAD 0.0141 mm (0.005%). - At 0.05 mm (limit 0.200 mm) the boss fillet is found on 3 of 3 seeds and the script is written on seed 0 only (
boss_1_fillet = 1.7, CadQuery 0.178 mm, OpenSCAD 0.178 mm, FreeCAD 0.179 mm). Seeds 1 and 2 are refused at 0.226 mm and 0.238 mm. The single hole rim is written on 2 of 3 seeds (hole_1_rim_r = 1.3; seed 0 is 0.157 mm CadQuery, 0.158 mm OpenSCAD and FreeCAD; seed 1 is 0.144 mm). Seed 2 is refused at 0.241 mm and 1.35% volume. Both rims on seed 0 are refused at 0.201 mm on all three backends. The blind floor on seed 0 is not a torus and is refused with "sphere faces are not supported yet". - At 0.2 mm (limit 0.800 mm) the torus is not recovered, so the fillet parameter is absent. The boss is the sharp cylinder: CadQuery refuses seed 0 at 0.807 mm and writes seeds 1 and 2 at 0.758 mm and 0.719 mm. OpenSCAD seed 0 is refused at 0.867 mm. FreeCAD seed 0 is written at 0.745 mm. That sharp solid is 0.793 mm from the true boss. The Ø12 hole and the hole with both rims are written as sharp holes (CadQuery worst 0.625 mm and 0.705 mm). The blind hole is refused on seed 0 with "hole profile is not a plain or countersunk hole".
v0.18.0
- A fillet between a plane and a coaxial cylinder is rebuilt as one torus face in the STEP solid, tangent to both neighbours. A boss base and a rounded hole rim use the inner equator (major radius = cylinder radius + minor radius). The floor of a blind hole uses the outer equator (major radius = cylinder radius minus the minor radius). The fidelity report counts torus faces and lists each major and minor radius.
- On a plate with an Ø16 boss and a 2 mm base fillet this is exact on 3 of 3 seeds at 0 and at 0.05 mm noise. With no noise the minor radius error is 0.008 mm (major 10.012 mm, Hausdorff 0.026 mm). At 0.05 mm the worst minor error is 0.279 mm and the Hausdorff is 0.150 mm. An Ø12 hole with a 1.5 mm top round is exact with no noise (minor error 0.068 mm, major 7.451 mm, Hausdorff 0.026 mm) and on 2 of 3 seeds at 0.05 mm (worst minor error 0.247 mm). The third seed is a valid faceted solid, Hausdorff 0.633 mm. Both rims at 1.2 mm are exact with no noise (minor error 0.061 mm). An Ø10 blind hole with a 1.5 mm floor fillet is exact with no noise (minor 1.463 mm, major 3.529 mm, Hausdorff 0.021 mm).
- At 0.2 mm the boss fillet and the single hole rim are not recovered. The STEP is the sharp cylinder and its planes, Hausdorff 0.864 mm on the boss and 0.681 mm on the hole, and it is still one valid solid. At 0.05 mm the blind floor falls back (Hausdorff up to 0.992 mm) and a hole with both rims rounded falls back (Hausdorff up to 1.835 mm). A torus that does not sew does the same. CadQuery, OpenSCAD, and FreeCAD export still refuse a torus;
fillet_rremains the four vertical corners of a rectangular base.
v0.17.0
mesh2cad params script.pylists the named parameters of a CadQuery, OpenSCAD, or FreeCAD script mesh2cad generated: name, value, kind, and unit when one is known (base_x,hole_1_d,hole_1_depth,fillet_r,extrude_len,outline, and the rest).mesh2cad edit script.py --set hole_1_d=8 --set base_x=+2rewrites those numbers and leaves every other byte unchanged. A leading+or-is a delta. It re-renders with CadQuery in-process, or withopenscad/freecadcmdwhen that program is onPATH, and prints volume and bounding box before and after, and whether the solid is valid.--in-placeor--output-scriptwrites the script.-owrites STEP or STL. OpenSCAD writes STL. If the program is missing, the script can still be rewritten and the command says it did not render.-oin that case writes nothing.- An unknown parameter is refused and the message lists the valid names. An edit that is not one valid solid, or a hole larger than the wall it sits in, is refused and no file is written. Outline point lists are listed and are not edited as a single number.
- MCP tools
list_params(script_path)andedit_params(script_path, changes, output_path?).edit_paramsupdates the script in place and returns the old and new values, the rendered path, validity, the volume and bounding-box delta, and warnings.
0.16.0
- Parametric FreeCAD export:
mesh2cad convert in.stl --freecad out.FCMacrowrites a macro for the same parts as--cadqueryand--openscad. Parameter names match (base_t,hole_1_d,hole_1_cbore_d,fillet_r,extrude_len,outline,cut_1,clip_1_d, and the rest). The macro uses FreeCAD's Part API:makeBox,makeCylinder,makeCone, a polygon extruded along X, Y, or Z,fuse/cut/common, andmakeFilleton the four vertical corners of a rectangular base. freecadcmdruns the macro and the solid is compared with the mesh before the file is written. The gate is unchanged: max deviation at most max(4·tol, 0.1), volume error at most 1%. Iffreecadcmdis not onPATHthe file is still written and the command reports it unverified. FreeCAD is not a Python dependency. Parts outside the vocabulary exit with code 2 and a reason. STEP output is unchanged.- The macro is a Part script. Changing a dimension means editing the named number and running the macro again. It does not build a PartDesign body or a constrained sketch.
- MCP tool
to_freecad(input_path, output_path?, tol?). - All six Prusa parts export the macro. plug-aligner deviates by 0.0000 mm. endstop-block by 0.0421 mm (limit 0.1 mm). y-belt-idler by 0.1693 mm (limit 0.192 mm). y-belt-holder by 0.0896 mm (limit 0.154 mm). y-motor-holder by 0.1843 mm (limit 0.266 mm). y-rod-holder by 0.1300 mm (limit 0.138 mm). Volume error stays under 1% on each, which is the same gate as CadQuery and OpenSCAD. CadQuery and OpenSCAD deviations are unchanged. Exact STEP is unchanged on all six parts.
v0.15.0
- Parametric export can cut a solid back to the real cross-section along X, Y, or Z when the silhouette intersection, the partial-depth union, and the wall-snapped rebuild have all missed the mesh. One bounding extrusion is trimmed by a cut on each span where the outer profile stays within 0.05 mm (
cut_N, with the section kept ascut_N_cutout_J). A gap between two parallel faces from 0.12 mm to 0.55 mm is a polygonal cut of the section between them. An inner loop that holds its place along the axis, such as a hex pocket or a bore, is a polygonal cut over that span. The gate is unchanged. - y-belt-holder exports both scripts. CadQuery deviates by 0.0943 mm (volume error 0.700%) and OpenSCAD by 0.0965 mm (volume error 0.700%), under the limit of 0.154 mm. On 0.14.0 the same part was refused at 2.517 mm and 1.97% volume. The base is full height for only part of the length, a hexagonal pocket and a bore occupy part of that length, and five slits are 0.2 mm thick. plug-aligner (0.0000 mm), endstop-block (0.0421 mm), y-belt-idler (CadQuery 0.1534 mm, OpenSCAD 0.1639 mm), y-motor-holder (0.1843 mm), and y-rod-holder (0.1300 mm) are unchanged. Exact STEP is unchanged on all six parts.
- Tests: a bar that steps down along X, with a hexagonal tunnel and a 0.3 mm pentagonal slit, for both exporters. The sweep's cuts include the polygon and the section kept inside the bounding cut.
v0.14.1
- Fix: the CLI failed to import on Python 3.10 and 3.11 with a SyntaxError (an f-string reused double quotes inside the braces, which only Python 3.12+ allows).
pip install mesh2cadgave a broken command on those versions. CI now byte-compiles the sources on Python 3.10 too.
v0.14.0
- Parametric export rebuilds a combined extrusion after the silhouette intersection and the partial-depth union have both missed the mesh. Each outline is a raster snapped to vertical wall planes. A hole that has broken out through a slot is closed at the two mouths, and a flare outside that cylinder is left on the loop. A planar bevel with axis-aligned walls is a triangular cut (
cut_N) along the wide part of the face. A 45 degree cone that is not alreadyhole_N_chamferiscone_N_r0,cone_N_r1,cone_N_h. Shallow floors are scored again on that solid. The rebuild does not run when an earlier solid already passed the gate. The gate is unchanged. - y-rod-holder exports both scripts. CadQuery and OpenSCAD deviate by 0.1300 mm (volume error 0.096% and 0.089%), under the limit of 0.138 mm. On 0.13.0 the same part was refused at 0.745 mm and 0.61% volume: the Z outline followed the bore through the slot and chorded the slanted -Y wall. The Ø3.3 hole along Y at x=-11.65, z=-5 keeps the Ø6.3 counterbore. plug-aligner (0.0000 mm), endstop-block (0.0421 mm), y-belt-idler (CadQuery 0.1534 mm, OpenSCAD 0.1639 mm), and y-motor-holder (0.1843 mm) are unchanged. Exact STEP is unchanged on all six parts.
- y-belt-holder stays refused: "combined extrusion deviates by 2.517 mm (limit 0.154), volume error 1.97%". The belt profile is not a wall-snapped extrusion.
- Tests: a 2 mm 45 degree chamfer on the middle of one edge of a block, for both exporters. The square ends keep the silhouettes rectangular, and the chamfer is
cut_1. A plate with a slanted wall and a slot into a hole rebuilds an outline that keeps the slanted corner and meets the hole at two mouths. - Parametric export recovers a counterbore whose wall is only part of a turn. A ring of planar facets becomes one cylinder when the facets sit on a principal axis, the arc is a single span from 100 to 340 degrees, the bore inside the arc is empty, and the cylinder is not a fillet tangent to two planes. A flat polygon whose corners lie on a circle stays planes, because the face centres do not. The cylinder is used only when it is coaxial with a through hole and larger than that hole, and only when the stack is then a counterbored through hole. Otherwise the hole stays the one the full cylinders already described. Segmentation does not call this fit, so STEP faces are unchanged.
- When that counterbore stops short of the bounding end because a tab elsewhere sets the end, and the gap from the end to the mouth is already empty, the depth is measured from the part end out to the shoulder. A gap that still contains material is left alone.
- Tests: a block with a through hole and a counterbore that breaks out through a side face, for both exporters, including a tab that sets the part end past the mouth. Editing the counterbore diameter changes the volume by the part of the annulus that lies inside the block. A 90 degree fillet and a flat ring of chords are not returned as cylinders.
v0.13.0
- Parametric export can now write a union of partial-depth extrusions when the intersection of full-length silhouettes misses the mesh. Each extrusion has its own outline and length. A second outline on the same axis is
extrude_z2_len/outline_z2(the first of that axis isextrude_z1_len; one extrusion per axis keeps the old names). A clip on one extrusion isextrude_z2_clip1_x(and y, z, d) and cuts only that extrusion. A 45 degree chamfer on the start face of a Z extrusion isextrude_z1_chamferandextrude_z1_chamfer_at. A hole that opens on an intermediate face carrieshole_N_z0andhole_N_z1, and the counterbore is measured from that span. The gate is unchanged: max deviation at most max(4·tol, 0.1), volume error at most 1%. - y-motor-holder exports both scripts. CadQuery deviates by 0.1843 mm (volume error 0.306%) and OpenSCAD by 0.1843 mm (volume error 0.298%), under the limit of 0.266 mm. On 0.12.0 the same part was refused at 7.924 mm and 30.07% volume: that was the visual hull of the full-length silhouettes. The solid is a base from z=0 to z=8, a taller block and a sloped roof on part of that base, three edge bevels, the 0.5 mm slots, two hexagonal pockets, two shallow bottom pockets, and the screw holes. The Ø3.2 holes along Z run from z=0 to z=8, with an Ø5.6 counterbore 3 mm deep from z=8 and a 0.4 mm 45 degree chamfer at z=0. The base carries a 0.4 mm 45 degree chamfer on the edges that are actually chamfered. STEP is unchanged.
- y-belt-holder stays refused: "combined extrusion deviates by 2.517 mm (limit 0.154), volume error 1.97%". The cross-section changes along X and the belt pocket is a B-spline profile. A stack of planar extrusions does not close that.
- y-rod-holder stays refused: "combined extrusion deviates by 1.503 mm (limit 0.138), volume error 0.31%". The Ø6.3 opening is a partial ring of planes, about 140 degrees, and is not recovered as one cylinder. The body is also not a uniform extrusion: the +Y side reaches y=5.5 only in some bands of z. plug-aligner (0.0000 mm), endstop-block (0.0421 mm), and y-belt-idler (CadQuery 0.1534 mm, OpenSCAD 0.1639 mm) are unchanged.
- Tests: an L-shaped base with a taller block on one arm, and a counterbored hole whose mouth is the step rather than the top of the block, clean and at 0.05 mm noise, for both exporters. Editing the block length and the hole diameter changes the volume by the analytic amount in both scripts.
v0.12.0
- A cylinder or cone band that meets several planes and coaxial circles in one loop is sewn as a trimmed analytic face. A hole end that is a full chamfer circle can meet a cap split across coplanar pads. A short chamfer glued onto a plane is split back off when its vertices have left that plane. A fillet that only meets planes, including one that runs into a spherical corner, is unchanged and still falls back.
- y-rod-holder is exact: 158 planes, 8 cylinders, 11 cones, Hausdorff 0.2178 mm, volume error 0.391%, 12.4 s. The R=4.00 mm bore and the 45 degree chamfers on it are analytic faces. On 0.11.0 the bore did not sew and the output was the raw mesh (3043 faces, Hausdorff 0, 34.2 s). The 0.22 mm that remains is three shallow patches kept as single planes: vertices 0.16 to 0.24 mm off the plane, and no internal edge sharper than about 10 degrees. Cylinders and cones fit to under 0.005 mm.
- Parametric export of a combined extrusion now accepts a 45 degree axis-aligned chamfer on a hole (
hole_N_chamfer, the axial length), a blind hole (hole_N_depth), a blind pocket, and a shallow floor such as a hex pocket or a logo. When the fused silhouette is more than 3% smaller than a raster of the mesh, the raster outline is used. The gate is unchanged: max deviation at most max(4·tol, 0.1), volume error at most 1%. - y-belt-idler exports both scripts. CadQuery deviates by 0.1534 mm (volume error 0.144%) and OpenSCAD by 0.1639 mm (volume error 0.145%), under the limit of 0.192 mm. The solid is the X and Y silhouettes, the belt grooves, hex pockets, logo floors, an Ø3.2 hole along X with an Ø5.6 counterbore, a 0.5 mm blind hole along Y with a 45 degree taper, and two Ø3.3 holes along Z with a 0.4 mm 45 degree mouth chamfer. STEP is unchanged: 197 planes, 6 cylinders, 3 cones, Hausdorff 0.0082 mm.
- y-motor-holder stays exact (396 planes, 6 cylinders, 2 cones, Hausdorff 0.1001 mm). Parametric export is refused with "combined extrusion deviates by 7.924 mm (limit 0.266), volume error 30.07%". The Ø5.6 / Ø3.2 screw holes run from z=0.4 to z=8 on a part that spans z=0 to z=19. At a tighter tolerance the same part is refused earlier with "stepped hole is not a counterbored through-hole". The command reports the default-tolerance measurement.
- y-belt-holder stays exact and is still refused, now with "combined extrusion deviates by 2.517 mm (limit 0.154), volume error 1.97%". On 0.11.0 that refusal was 24.461 mm and 90.96% volume. y-rod-holder parametric is refused with "combined extrusion deviates by 1.503 mm (limit 0.138), volume error 0.31%": the Ø3.3 hole along Y is not one radius for the whole length, and a single cylinder sits about 1.5 mm off the mesh where the opening is wider. plug-aligner and endstop-block are unchanged (0.0000 mm and 0.0421 mm).
- Tests: a horizontal bore with a 0.5 mm 45 degree mouth chamfer sews as one cylinder and one cone. A 45 degree chamfer on an X hole through a slanted extrusion is
hole_1_chamferin both scripts, and editing it from 0.8 mm to 1.2 mm changes the volume by the analytic ring.