3D part design with Inkscape and OpenSCAD # 141: repeating SVG pattern on a cylinder.

2 min read
By Bob
3D part design with Inkscape and OpenSCAD # 141: repeating SVG pattern on a cylinder.

Here is an example of how to create a cylinder with a repeating SVG pattern on the outside that can be rotated, scaled, etc.

The code:

//

/*[SVG parameters]*/
Show_svg=true;
Path_to_SVG_File="drawing.svg";
Scale_svg_X=.3;//[.1:.01:10]
Scale_svg_Y=.3;//[.1:.01:10]
Scale_svg_Z=1;//[.1:.01:10]
Adjust_Z=10;//[0:.01:30]
Adjust_oversize=20;//[1:.01:100]

/*[Tube paramaters]*/
Tube_height=50;//[10:.01:200]
Tube_diameter=45;//[10:.01:100]
Wall_thickness=4;//[1:.01:10]

/*[Pattern parameters]*/
Vertical_spacing=6;//[2:1:20]
Horizontal_spacing=72;//[10:.1:400]
Rotation=8;//[0:1:14]

/*[Hidden]*/
$fa=$preview? 2:1;;
$fs=$preview?.5:.1;;

module Tube(){
difference(){
  cylinder(Tube_height,d=Tube_diameter);
  cylinder(Tube_height*2.5,d=Tube_diameter-Wall_thickness,center=true);
}}

module Svg_pattern(){
for(z=[0:Vertical_spacing:Tube_height-Adjust_oversize])
  translate([0,0,z])
for(rotation=[0:Horizontal_spacing:359])
  rotate(rotation+(z*(Rotation)))
  translate([Tube_diameter/2,0,Adjust_Z])
  rotate([0,90])
  scale([Scale_svg_X,Scale_svg_Y,1])
  linear_extrude(Scale_svg_Z)
  import(Path_to_SVG_File,center=true);
  
}

Tube();
if(Show_svg)
color("red")
Svg_pattern();

Now I can use any design I can make with Inkscape and make a roller for clay or just a neat looking design:

Here's an example using spheres or cylinders to make spikes, etc:

//

/*[Tube paramaters]*/
Tube_height=50;//[10:.01:200]
Tube_diameter=45;//[10:.01:100]
Wall_thickness=4;//[1:.01:10]

/*[Pattern parameters]*/
Vertical_spacing=6;//[2:1:20]
Horizontal_spacing=72;//[1:1:400]
Rotation=8;//[0:1:14]

/*[Sphere parameters]*/
Use_sphere=true;

/*[Spike parameters]*/
Use_cylinder=false;
Spike_widthX=2;//[1:.01:10]
Spike_widthY=2;//[1:.01:10]
Spike_length=1;//[.1:.01:10]


/*[Hidden]*/
$fa=$preview? 2:1;;
$fs=$preview?.5:.1;;

module Tube(){
difference(){
  cylinder(Tube_height,d=Tube_diameter);
  cylinder(Tube_height*2.5,d=Tube_diameter-Wall_thickness,center=true);
}}

module Spikes(){
for(z=[0:Vertical_spacing:(Tube_height-Spike_widthX)-6])
translate([0,0,z])
for(rotation=[0:Horizontal_spacing:359])
rotate(rotation+(z*(Rotation)))
translate([Tube_diameter/2-.5,0,5])
rotate([0,90])
scale([Spike_widthX,Spike_widthY,Spike_length])
cylinder(h=2,r1=4,r2=1);
}

module Spheres(){
for(z=[0:Vertical_spacing:Tube_height-8])
translate([0,0,z])
for(rotation=[0:Horizontal_spacing:359])
rotate(rotation+(z*(Rotation)))
translate([Tube_diameter/2,0,5])
rotate([0,90])
scale([1,1,1])
sphere(2);
}

Tube();
if(Use_cylinder)
Spikes();
if(Use_sphere)
Spheres();