Image to Textured Anulus (Ring) Python Tool 3D model preview
View source Save
1,976 downloads 168 likes 15,078 views Free price

About this 3D model

originally this was a script to convert images to height maps as polyhedrons suitable for use in openscad...now it has become a tool for making height map textured ring shapes ToDo add control for fading edges of image v0-13 modifications based on prototype from i.materialise Ring .stl internal diameter seemed to be 6 or 16.5mm, but size is entered correctly as 6.5 or 16.9mm which is correct GENERATING A NON-TEXTURED RING GIVES CORRECT DIMENSIONS however adding an embossed texture to the inside adds material Fixed!!! in... if texture: if texture_inside_not_outside: #print "texture inside not outside" if texture_engraved_not_raised: #changes made here to fix texture size issue NOW vertex_list.append([row*height_scaling,column,texture_depth - (pix[row,column]*depth_scaling) ]) WAS vertex_list.append([row*height_scaling,column, - (pix[row,column] *depth_scaling) ]) sizes/etc changed for 2nd prototype/production version texture_depth=0.2 #to match prototype which turned out well, default was 0.5 ring_width=4.4 #to match engagement ring, default was 4 inputImage = 'slightlycleanedbetter_text.png' to include engraving text texture_height_ring_circum_ratio=1#changed from 0.6 to take account of longer texture image featuring text doming looks good now with adjusted shape v0-12 add control for how much of ring is covered in pattern added texture_scale ability possibly this introduces shadows at the edges... perhaps have option to trim 1 pixel from each edge before using for texture to prevent this? identified possible bug with texture direction when only using partial coverage identified possible bug where back vertical edges have gaps...possibly due to ctrl+h replacing of width and height previously...blergh! reduced the number of holes and bad edges but still not perfect... this requires further attention as at the moment it generates bad .STLs!!! fixed!!! v0-11 Now can directly make the entire ring! ability to invert/flip/rotate image add control over emboss/engrave fix jumbled up width and height removed openscad output options to functions removed make_square section to function add control for placing image on inner/outer surface control the shapes of inner/outer surface so can directly create final ring curvature direction and amount on inner and outer surface add 2 separate ellispe radii for each surface implementing simple control over curving in second direction fixed some bugs where curved surfaces shape and change in height was miscalculated Only tested on combinations of flat and convex...possibly bugs in concave surfaces??? v0-10 implement curving in second direction cleanup code v0-9 Moved items to __main__ fixed calculation of ring width added ability to connect ends together so you can get a complete ring add option for direct output in ascii .stl format (from https://en.wikipedia.org/wiki/STL_ %28file_format%29 ) An STL file describes a raw unstructured triangulated surface by the unit normal and vertices (ordered by the right-hand rule) of the triangles using a three-dimensional Cartesian coordinate system. STL coordinates must be positive numbers, there is no scale information, and the units are arbitrary. An ASCII STL file begins with the line: Line 1 solid name where name is an optional string (though if name is omitted there must still be a space after solid). The file continues with any number of triangles, each represented as follows: Line 2 to n-1 facet normal ni nj nk In both ASCII and binary versions of STL, the facet normal should be a unit vector pointing outwards from the solid object. In most software this may be set to (0,0,0) and the software will automatically calculate a normal based on the order of the triangle vertices using the 'right-hand rule' outer loop vertex v1x v1y v1z vertex v2x v2y v2z vertex v3x v3y v3z endloop endfacet where each n or v is a floating point number in sign-mantissa 'e'-sign-exponent format, e.g., "-2.648000e-002". The file concludes with: Line n endsolid name v0-8 3d graph of vertex points with ID numbers v0-7 simple hack around failure with non-square images by adding blank pixels to edges to make it square! This works but leaves flat parts at the edges uses the maxima from im.extrema() to scale the texture heights uses user input to select width of output polygon via x position of vertex points began attempt to join ends together v0-6 vertex array is now curved in 1 dimension v0-5 all data is saved to arrays rather than written immediately to file this will allow for easier editing v0-4 moved all polygon and triangle surface generation (textured top, flat bottom & sides) into single block swapped order of side 4 in attempt to fix winding order This can now generate a valid 3d polyhedron... but openscad has trouble with non-square input textures (not sure why) v0-3 2013-01-09 Now able to generate all surfaces...still need to integrate this all into one method (removing special values) so they can form one object! Cleaned up section that generates upper