Welcome! Log In Create A New Profile

Advanced

Use stl, dxf file to mod part

Posted by rrowan327 
Use stl, dxf file to mod part
August 17, 2015 01:14PM
Hi folks,

I am working on a simple part to learn more about Openscad. I have the basic shape done but I wanted to change the slot cut that holds a tablet. Since I don't fully understand how to use polyhedron which I think is what I need or maybe some other command, I created a basic shape in Autocad to show the new slot cut I want to use. I can export the part as either stl or dxf and import into blank openscad file but I don't understand how to use the shape. I have attached the shape. I am hoping there is a easy way to create it inside openscad. The only real import parts of the shape is the bottom width and the side wall angle of 15 degrees and the rounded bottom corners.Any help will be greatly appreciated.
Thanks Rick

sample code - please excuse my horrible code
$fa = 0.5;
$fs = 1.5;

b_width = 124.7;
b_depth = 28.5;
b_height = 24;
b_circle = 30.5;
b_circle_length = 17;

slot_width = 10.5;
slot_height = b_height +1.2;
slot_angle = 0;


base();


module base() {

    difference() {
        cube([b_width, b_depth, b_height]);
    //circle cuts
        //left
        translate([b_width/2+40,b_height-10,slot_height+5]) circlecutout2(1.2); 
        //center
        translate([b_width/2,b_height+7,slot_height]) circlecutout();
        //right
        translate([b_width/2-40,b_height-10,slot_height+5]) circlecutout2(1.2);
        
    //slot cut
        translate([-3,b_height-13,6]) slotcutout();
    //Front cut
        translate([-1.5,b_depth/2,b_height/1.2]) fCut();
    
    
    }    
}

module circlecutout() {
        rotate([90,0,00]) 
        cylinder(h=b_circle_length, d=b_circle);
}

module circlecutout2(scx) {
        rotate([-70,0,0]) 
        cylinder(h=b_circle_length, d=b_circle*scx); 
}

module fCut() {
    cube([b_width+3, b_depth/1.5, b_height/2]);
}

module slotcutout() {
    rotate([15,0,0])
     minkowski() {
        cube([b_width + 8, slot_width-1, slot_height+5]);
        rotate([0,90,0]) cylinder(r=2,h=slot_height+5);
     }  
}
Attachments:
open | download - Shape-slotcut2.png (6.9 KB)
open | download - Shape-slotcut2a.stl (2.6 KB)
Re: Use stl, dxf file to mod part
August 17, 2015 03:39PM
Great that you start working with OpenScad! I am sure the more you use it, the more you will
like it.

But I would not recommend resorting to import of outside objects, just because you don't
know (yet!) how to construct them directly in OpenScad.
Why not try to work it out directly in OpenScad?

Your shape is simply a convex hull of a flat cube at the top and two cylinders at the bottom.
Here an example how to implement it. The parameter opening specifies how much larger
the top of the slot is compared to the bottom of the cutout. Just change the value of opening
to whatever you need. With i]opening=0[/i] you'll get exactly what you got with the minkowski().

module slotcutout(opening=10) {
    rotate([15,0,0]){
      hull() {
        translate([0,-opening/2-2,slot_height+5])cube([b_width+8,slot_width+3+opening,1]);
        rotate([0,90,0]) cylinder(r=2,h=b_width+8);
        translate([0,slot_width-1,0])rotate([0,90,0]) cylinder(r=2,h=b_width+8);
      }
    }
}
Re: Use stl, dxf file to mod part
August 17, 2015 10:07PM
Hi enif,

Many thanks for the help, the code works perfectly. I didn't mean to say I wanted to use the drawing from auto cad but it was just to show what i wanted to do. My goal is do all part design in opens cad.

Thanks again

Rick
Re: Use stl, dxf file to mod part
August 17, 2015 11:03PM
Hi me again,

Just going over the code to make sure I understand it.

module slotcutout(opening=10) {
** This rotate is no longer needed since the hull command makes the shape properly **
rotate([15,0,0]){

** hull forms the required shape using the top (cube) then two cylinders for the bottom corners. **
hull() {

**top section with cube command and the use of opening constant is cool here. **
translate([0,-opening/2-2,slot_height+5])cube([b_width+8,slot_width+3+opening,1]);

**two bottom cylinders to complete the shape along with rotation and move the cylinders to proper location **
rotate([0,90,0]) cylinder(r=2,h=b_width+8);
translate([0,slot_width-1,0])rotate([0,90,0]) cylinder(r=2,h=b_width+8);

Hopefully I got it all correct. If so I need to draw up more shapes on paper and see if I can duplicate them in openscad
Many thanks again for your assistance and pointing me into the correct direction.
Rick
Re: Use stl, dxf file to mod part
August 18, 2015 12:19AM
Perfect! smiling smiley
Re: Use stl, dxf file to mod part
August 18, 2015 10:20PM
Hey enif,

Just showing (off) with what I was trying to do in openscad. Now one part I did cheat and "borrow" some code from thingiverse. That person create an RC car wheels with the center spokes being a hazard symbol. I thought it was an interesting design and used the spokes part.I am not happy with the code yet (doubt it will ever be perfect smiling smiley )

Thanks for your help, I am still trying and hoping to get better.
Rick

P.S. how do I go from either openscad or STL file to png/jpeg? I couldn't figure out how to display the file in this forum. I have an imgur account but they what a raster file.
Attachments:
open | download - facy2.stl.zip (137.3 KB)
Re: Use stl, dxf file to mod part
August 19, 2015 01:07AM
Glad to see that you are making much progress smiling smiley

Quote
rrowan327
P.S. how do I go from either openscad or STL file to png/jpeg? I couldn't figure out how to display the file in this forum. I have an imgur account but they what a raster file.

In OpenScad I use "File / Export / Export as image" to generate a PNG from a Scad-File

For STLs, I use "gmsh" to display the STL and then do a screen shot with Gimp.

To post the image on the forum, I go to the control center (link on top right of each page) and upload it into the My Files section, then copy the link into the post.
Re: Use stl, dxf file to mod part
August 19, 2015 05:11AM
To post the image:

1. Click on "Attach a file ..."
2. Click on "Browse..." button
3. Select the image file and click on "Open"
4. Click the "Attach" button
5. Click on "Create link in message"




Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: Use stl, dxf file to mod part
August 19, 2015 10:30AM
Quote
rhmorrison
To post the image:

1. Click on "Attach a file ..."
2. Click on "Browse..." button
3. Select the image file and click on "Open"
4. Click the "Attach" button
5. Click on "Create link in message"

[attachment 60257 DoubleFacepalm.jpg]

Yeah I know that but the original picture was too large for the size over the size limit.

Also how do I go from openscad to a nice looking picture. Unless openscad exports to png, etc.

Thanks Rick

Edited 1 time(s). Last edit at 08/19/2015 10:31AM by rrowan327.
Re: Use stl, dxf file to mod part
August 19, 2015 10:47AM
Quote
enif
In OpenScad I use "File / Export / Export as image" to generate a PNG from a Scad-File

And if you really want a rendered picture you can use POV-Ray and import the STL file with appropriate scenery.
See the article "How to convert and render STL files to images".


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: Use stl, dxf file to mod part
August 19, 2015 12:01PM
I created a new part. Its for a Slik tripod quick release base. I plan to use it to attach other devices to my tripod like a smart phone or tablet once I design holders from them. This is still a learning process but I need the diversion from work and real life. Enif, the code for the y axis is base from your code example.



Rick
Sorry, only registered users may post in this forum.

Click here to login