Close



Page 7 of 7 FirstFirst ... 567
Results 61 to 69 of 69
  1. #61
    Super Moderator curious aardvark's Avatar
    Join Date
    Jul 2014
    Posts
    4,532
    Umm, yes ?

    There is no such thing as 'best practice'. Only what you are happiest using.
    If that's all it takes to save your own modules and use them in scripts. Then that's going to be extremely useful.
    The only thing I've used like that so far is the write.scad module. I actually made a different one for each font and renamed them for the font names. so i can just use: use <knewave.scad>
    To use the knewave font. Makes things a bit easier.

    Using a library of your own modules would make for simpler looking scripts, that's for sure.

    Also you're rotate extrude module just makes a bog standard straight sided ring. Shouldn't it make a round sided 'donut/torus' ?

    Here's some homework for you OME - find a decent module I can make different sized screw threads with. I've so far not managed to find one that actually works.

  2. #62
    Super Moderator old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    914
    Quote Originally Posted by curious aardvark View Post

    Also you're rotate extrude module just makes a bog standard straight sided ring. Shouldn't it make a round sided 'donut/torus' ?
    Pay attention!!. This is the OpenScad Help Centre, not the Geometry Help Centre. The code pasted here is just an example copied from the blog page to illustrate the topic "Modules"

    Quote Originally Posted by curious aardvark View Post
    Here's some homework for you OME - find a decent module I can make different sized screw threads with. I've so far not managed to find one that actually works.
    Hey! I'm not some pheasant phucker's pimp! Get your own screw (but ask if she has a friend.)

    Maybe this one love you long time:

    uploads-74-10-9c-ff-15-screwthread_v2.scad

    OME
    Last edited by old man emu; 12-09-2014 at 07:34 AM.
    You may go past me,
    But you won't outlast me!

  3. #63
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,664
    I think that using the "module" function is the only way to make openscad files easy to understand by the people that did not write them.

    If you stick all the separate things it does in modules then just call them from the bottom of the file it really is a lot easier to remember what is what.

  4. #64
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,664
    Quote Originally Posted by old man emu View Post
    QUESTIONS:

    1. Say I've just created a module to make a whatsit, and I'm going to be making whatsits of various sizes in the future. If I click on <Save As> in Openscad do I save my .scad file here
    C:\Program Files\OpenSCAD\Libraries?
    2. If I've saved my module as whatsit.scad, can i create a whatsit using this bit of code:

    use <whatsit.scad>
    whatsit (parameters);

    3. Which is better practice, putting this in the code:
    module ring(height, radius, radial_width)
    {
    difference()
    {
    cylinder(h = height, r = radius + radial_width / 2);
    translate([0, 0, -1])
    cylinder(h = height + 2, r = radius - radial_width / 2);
    }}

    or this:
    use <ring.scad>
    ring(h,rw,r);

    OME

    If you have some modules that are in another file and you want to call those modules then you can either "include" the file or "use" the file.

    "Include" will perform calculations that are within the file whereas "use" will not do any internal calculations, it will just use the functions.

    For example:

    With the toroid file from the other thread I can simply
    use <./new_toroid.scad>




    //CentretoShape,CornerRadius
    toroid (25,5);


    to make the toroid

  5. #65
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,051
    Quote Originally Posted by old man emu View Post
    I was reading this, http://blog.cubehero.com/2013/12/18/...d-code-part-i/ and came across this example of a module,

    module ring(height, radius, radial_width) {
    difference() {
    cylinder(h = height, r = radius + radial_width / 2);
    translate([0, 0, -1])
    cylinder(h = height + 2, r = radius - radial_width / 2);
    }}

    After studying it for a while, it dawned on me that the module was like an icon on the object creation toolbar of a GUI based progam like Rhino.
    Here is a piece of OpenScad code I wrote to make ridged beams. I was making a Pump Jack for my brother that just graduated from University of Texas as a Petroleum Engineer. I wanted things as big as they could be because this was going to sit on his desk. But I ran into problems with the beams warping when they were long.

    This is a good example of how to use modules to insulate yourself from a problem. I already had a module that made a ridged_beam() and let me set numbers to build it. But then I defined a module to make a stress_relieved_ridged_beam() that took some input numbers and generated an 'appropriate' beam from them.

    And at a higher level, it only takes a few lines of code to make the base() with all these fancy holes. If I need to do further work to reduce stress on the model, I just have to do it in the one routine stress_relieved_ridged_beam() and it will automatically get replicated everywhere that function is used. If the topic is of interest to you, you can zoom in and see the miniature cuts between each big hole to eliminate stress build up on the early layers.

    PumpJack_Base.jpg

    Proper and judicious use of 'module' can help make your code more maintainable and easier to reuse. (Not to mention... Easier for other people to understand!!!!)
    Attached Files Attached Files

  6. #66
    Super Moderator curious aardvark's Avatar
    Join Date
    Jul 2014
    Posts
    4,532
    Pay attention!!. This is the OpenScad Help Centre, not the Geometry Help Centre. The code pasted here is just an example copied from the blog page to illustrate the topic "Modules"
    Listen, I didn't even understand the question in the geometry thread. So have not looked at it since :-)

    And using examples from thje openscad manual is just going to confuse everybody :-)
    Not sure who wrote that manual, but I'm leaning towards someone with aspergers.
    They defintiely don't share any frame of reference with me :-)

  7. #67
    Super Moderator old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    914
    I agree that I didn't put the question about the square doughnut very well, but it did generate some lively discussion, have minds whirring over, and introduced us to an expert in the field.

    I'm with you in saying that the OpenScad manual is not instructive. It clearly was not written with the intention of enlightening people like you and me who just wanted to use OpenScad to make objects. The manual was obviously written by programmers for programmers and that is why it is full of jargon such as, (You can instantiate the module by passing values (or formulas) for the parameters just like a C function call)

    Instantiate??????

    Techopedia explains Instantiate
    Instantiation is the creation of an instance of an abstraction, object class (also known as a template) or other computer process whereby objects are used. Each instance created by instantiation is unique depending on the variation of the elements within the object. Until an object becomes instantiated, none of the code within the relevant class declarations is used.

    Prior to modern OOP methods, instantiate had a similar meaning in relation to the creation of data within an empty template. For example, the entry of a record into a database was considered to be instantiation.


    Remember this. It will be in the End of Year examination of the core topic Obfuscation 101.

    The manual presumes too much prior knowledge of programming, which is why I started this thread with a request for a description of the syntax, and then realised that I needed to know the meanings of it symbols and punctuation before I could move on to writing some code. I'm also wondering if OpenScad is an efficient way to end up with an *.stl file that is needed for slicing. I haven't tried converting any code to an stl file.

    I find that it is very easy to make typographical errors in writing this code. I had to edit the code in the example I posted in Post #60 because the original author had mixed up the order of parameters here
    ring(h,r,rw);

    OME
    Last edited by old man emu; 12-10-2014 at 07:29 AM.
    You may go past me,
    But you won't outlast me!

  8. #68
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,051
    OpenScad has been stagnant for a whole year. No bug fixes or improvements. It almost looked like the development effort was dead. Well, it turns out they were very busy!!! There is a new release 2015.03 that adds a lot of important features and simplifies the code to do a number of things. It seems very stable and so far, it appears to be fully backward compatible.

    Two of the best things in the new version are the ability to generate text directly to put on your models and the offset() command.

    Check it out: http://www.openscad.org/downloads.html

    Actually... There is one more thing that is super important. The ability to set and reset a variable within any scope. This dramatically simplifies a number of things.
    Last edited by Roxy; 04-16-2015 at 03:28 PM.

  9. #69
    Super Moderator curious aardvark's Avatar
    Join Date
    Jul 2014
    Posts
    4,532
    latest scad release is NOT the latest release.
    go here : http://www.openscad.org/downloads.html

    on the right click on: Development Snapshots
    Takes you down to the part of the page with the ACTUAL latest releases.

    Some cool new features that, as far as I can find out - just aren't listed. You have to meander through the manual untill you see: 'new in release 2016.*.*'
    How I found out you could do a partial rotate extrude.

    Must be some other stuff in there as well. I just haven't gone through the whole manual yet.

Page 7 of 7 FirstFirst ... 567

Posting Permissions

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