Close



Page 4 of 8 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 71
  1. #31
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    Quote Originally Posted by dacb View Post
    Not to hijack, but I just want to put in a quick plug for openjscad instead of openscad. It performs way better (render time), doesn't have the wonky syntax and variable scoping oddities. I have switched over completely.
    It is obvious from your work with the Marlin upgrades that you are either a professional programmer, or very competent in programming in various languages. For you, to switch between, say, C and Java might be as easy as changing shirts. However, some of us who are taking up 3D design haven't done any programming since they coded Pong on a Commodore 64 using GW-Basic.

    That's why OpenScad appears to be a good choice as the coding appears uncomplicated in its text form. I admit that I could probably create a 3D object in Rhino easier that I could in OpenScad at the moment, but I'm a late started of OpenSad. As I 've been working on my posts in this thread, I have started to pick up on how things happen. I like the interface. I did have a squiz at openjscad, and it did not jump out and grab me.

    For some of us, render time is not something we need to reduce down to jiffies as out minds still aren't much faster than split seconds.

    However, thanks for your comment, and perhaps the young Turks will follow your lead.

    Old Man Emu

  2. #32
    Super Moderator curious aardvark's Avatar
    Join Date
    Jul 2014
    Posts
    8,801
    download link ?

    I'm all for anything that's quicker. I have no problem with the syntax. Like I said after a fairly short while you just type the brackets automatically.

    Let's each download the OpenScad Cheat Sheet and, starting with Syntax , go through it explaining what each of the underlined words means, and the correct way to write it into some code.
    That could get complicated really quickly. A lot of the commands on there are stupidly complicated and rely on others to do anything at all - half of them. (or more) I haven't managed to get my head around at all.

    Take for example the Minkowski hull.
    On the surface it blends two shapes so you can get round cornered boxes, oval trays etc. I've used it for some oval screw trays.
    I looked at how it works the other day and it's all about how a robot drives around a space - wtf ??????
    It's also really tricky to work out how big the final shape is going to be.

    Likewise the rotate extrude command. I've used it to make a chapati press using donut shapes. Looks pretty cool. But I have no clue how the numbers you put into the equation relate to the size of the final donut. In the end I made a flat cube of known size and just kept changing numbers till the donut was the same size as the cube.

    I definitely think it's easier to start with an actual task you're likely to want to do and then explain how it's done.

    But we can try both methods :-)

    ps. Ah right openjscad is the online webpage version.
    Nah I like programs that run on my actual computer. Plus some of the designs I want to keep to myself. :-)
    Last edited by curious aardvark; 12-03-2014 at 05:44 AM.

  3. #33
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    Here's the link: http://www.openscad.org/cheatsheet/index.html

    Yes! Yes! Hasten slowly.

    I did a bit of that tonight, and here's the little bit of code I ended up with. The object is a toddler's Duplo building block. It took about half an hour to do, and that involved going back and forth to the cheat sheet.

    Here's my notes for the object, except that I was going to make a four peg block when I pinched the Duplo from my grandson. The first design decision I made was to make a block with a single peg, then multiply and join the single one.

    Duplo Sketch.jpg

    After some reading; some cut and paste, and some delete and replace work, I came up with this:

    Single Duplo Block.scad

    Critique appreciated.

    How do you get a grid displayed for measurement purposes? Working out where the centres of the spheres and cylinder was what took most of the time with this exercise.

    Old Man Emu
    Last edited by old man emu; 12-05-2014 at 02:15 AM.

  4. #34
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,183
    Quote Originally Posted by old man emu View Post
    How do you get a grid displayed for measurement purposes? Working out where the centres of the spheres and cylinder was what took most of the time with this exercise.
    A sphere and cylinder are always generated at (0,0). So when you translate them... what ever amount you translated them... Is where the center's are. I warmed over your code so you can see how to make your code easier to understand:
    Code:
    singleduploblock();
    
    module singleduploblock () {
    $fn=100;
    cube (32,32,20); color("gray", 0.5) translate([16,16,20]) cylinder(36, d=30); difference() {
    color("red" ) translate([16,16,55]) sphere(d=30); color ("lime") translate ([ 8,8,68 ]) cube([16,16,8]);
    }
    }
    First, in OpenScad you should have a 'Top Level' geometry. That is what that first singleduploblock(); is. It references other stuff, but it is at the top level.

    singleduploblock() does not have any paremeters, and certainly does not need its name passed in as a parameter.

    It is typical, and usually better to put modifiers like color() in the front of the line. And it is usually best to combine things that go together like color(), translate() and cube() so it is easy to pick out what everything is doing.

    And of course, indenting really helps too. For example, having things indented makes it easier to see what the difference() is operating on. The code directive isn't working perfectly on this post... But you can see what I mean even though I'm restricted on how to indent 'properly'. You only have one module in this file so this won't be as clear. But a lot of people indent everything within a module so it is clear where a module starts and ends. The module declarations are part of the 'top level' so they are pushed as far to the left as possible. As you get nested deeper and deeper, you indent more and more to show that.

    Even though what I posted is almost exactly what you had... most people would prefer to work with my version.
    Last edited by Roxy; 12-03-2014 at 09:47 AM.

  5. #35
    Super Moderator curious aardvark's Avatar
    Join Date
    Jul 2014
    Posts
    8,801
    I like the indenting idea.
    cylinder(36, d=30)
    What's the '36' refer to ?
    I know there are a lot of compact ways to write the parameters for a command - but can we stick to longhand for the time being ?

  6. #36
    Staff Engineer printbus's Avatar
    Join Date
    May 2014
    Location
    Highlands Ranch, Colorado USA
    Posts
    1,436
    Add printbus on Thingiverse
    Quote Originally Posted by Roxy View Post
    ...And of course, indenting really helps too...
    Another good habit for anywhere brackets are used is to comment the closing bracket to explain what it closes, exactly like CA did in his fully annotated script.

  7. #37
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,183
    Quote Originally Posted by curious aardvark View Post
    I like the indenting idea.

    What's the '36' refer to ?
    I know there are a lot of compact ways to write the parameters for a command - but can we stick to longhand for the time being ?
    cylinder(h=36, d=30);

    The way OpenScad works is default numbers can be specified for a module. And if the caller over rides that number, then something else can be used. H (Height) is the first parameter to cylinder, so you can be lazy and just give it a number and it will use that for height. But that is frowned up greatly.

  8. #38
    Super Moderator curious aardvark's Avatar
    Join Date
    Jul 2014
    Posts
    8,801
    Well I frowned at it :-)

    We're pretty much beginners here - so be gentle with us :-)

    Okay i copied and pasted the script - weird how the formatting just doesn't survive a copy and paste.

    Hate the colours - why ?????
    And are the plugs in duplo blocks really as long as that ?

    Looks really weird.

    Now that's better :-)
    duploblock-mono.JPG
    But the really weird thing is that you used a cube command with no square brackets. And it worked.

    cube (32,32,20);

    That should save some time.

    Also curious about this odd habit of putting modules before the module script.

    I tend to put modules at the start of the script to get the bulk out of the way and then use them in the script as a normal command.

    I've noticed a couple of times this habit of putting them at the end of the script. Just seems back to front to me.

  9. #39
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,183
    Quote Originally Posted by curious aardvark View Post
    But the really weird thing is that you used a cube command with no square brackets. And it worked.

    cube (32,32,20);
    I suggest you put the [32,32,20] inside of brackets. If for no other reason than everybody else does and expects to see that. But now you are changing your tune. You said you wanted the h=36 instead of a simple 36 for the cylinder(). So... ????

    Quote Originally Posted by curious aardvark View Post
    Also curious about this odd habit of putting modules before the module script.

    I tend to put modules at the start of the script to get the bulk out of the way and then use them in the script as a normal command.

    I've noticed a couple of times this habit of putting them at the end of the script. Just seems back to front to me.
    OpenScad is very loosely typed and doesn't care about forward references. Mostly, you want the code to be manageable and easy for other people to understand. So, my preference is to put equates up at the top, and invoke the modules I want very early. Then, I tend to use the bottom part of the file as a library to define the stuff that I used up at the top of the file.

    But that is me.... As long as it is well organized, clean and easy to understand, nobody is going to complain.

  10. #40
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    Ugly colours: I just put some random colours on each component so I could see boundaries and intersections. That's why I've put the coding for colour adjacent to the object being created. When I was fiddling about, I included opacity numbers (decimal from 0 to 1) to see if that improved clarity. When I had the coding done to what I thought was OK, I just deleted those values.

    Odd Looking Duplo block? Yes. I took it from the Duplo that is made for 18-24 month-olds. Here's some pics:

    P1013730 (Medium).jpgP1013731 (Medium).jpgP1013732 (Medium).jpg

    The next bit of coding to play with will be the bit that makes the object hollow.

    This single block can also be the basis of multiple units that are square, or rectangular.

    P1013734 (Medium).jpg

    Old Man Emu
    Last edited by old man emu; 12-04-2014 at 04:03 AM.

Page 4 of 8 FirstFirst ... 23456 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •