Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: Bezier Curves, Follow Me and Weld, Pt1

  1. #1
    Join Date
    Feb 2003
    Location
    N/A
    Posts
    3,628

    Bezier Curves, Follow Me and Weld, Pt1

    Since I haven't got another installment of the SU project Demo, I thought I could at least post the following.

    The first part of this has to do with drawing Bezier curves. This requires that you have a file called bezier.rb in your Plugins directory. If you don't see a Plugins menu when you have SU open, you also need to copy sketchup.rb from the Examples folder into the Plugins folder.

    The tree view of your SketchUp directory should be something like this:

    SketchUp
    --Plugins
    ----Examples
    ------sketchup.rb

    You want it to look like this:
    SketchUp
    --Plugins
    ----Examples
    ----bezier.rb
    ----sketchup.rb
    ----any other scripts you may have.rb

    I hope that makes sense.

    Click here: bezier.rb to get the script.

    For the final part of this episode, you'll need weld.rb which is available via this link: weld.rb

    Here's how to draw a Bezier curve. First, select the script from the Draw menu.



    Next, choose the "Degree". (Note the VCB) I don't understand the reason for that term but it indicates the number of "spaces" between editable points on the curve. You can also think of it as the number of points not including the first one. The default setting for this is 3. If you want more points simply type the desired number and press Enter.

    I've set the Degree to 5, started the curve at the origin dragged off to make the opposite end which is the second point you'll locate. I haven't actually set that point yet.



    End points are set and I'm about to set point number three.


    More points set. The straight lines are shown between the points you've set. You'll note the points do not fall on the curve.



    After the last point is set the straight lines go away and you're left with the curve. Here I've turned on shadows. You can see that the curve is 3D and does not lie on a single plane. That's cool if it's what you want but if you are trying to draw the edge of a table top, this wouldn't be quite the thing.



    This time I start with a face to draw on. Make it large enough so that all the points will lie on it. You can always erase what you don't need later.



    Select the script from the menu. Set the Degree. Start clicking points.







    Push/Pull gives it some thickness.


  2. #2
    Join Date
    Feb 2003
    Location
    N/A
    Posts
    3,628

    Pt 2

    Next, I'm going to use Follw Me to add a profile to the curved edge. The first thing I do is use the Protractor tool to set a construction line that is 90° to the first segment in the curve. This is very important for Follow Me to work properly.



    Then I draw out a face and add the features for the profile. In this case a simple arc.



    Select the edge to be the path for Follow Me.



    Choose the Follow Me tool, click on the profile and...



    And from a different angle.



    Now, for fun I'm going to do an Offset on the bottom and pull down as if this was the top to a corner cabinet or something.



    Notice when I pull down the center area I have all these faces on the edge. This is because Follow Me breaks up curves into their individual line segments. The lines between them could be smoothed with Ctrl+Eraser tool but that could add a bunch of work.


  3. #3
    Join Date
    Feb 2003
    Location
    N/A
    Posts
    3,628

    Pt 3

    Instead we'll use the Weld script to join all those line segments. First we select the segments of the curve. I double clicked on the inside face which selected the face and its bounding edges. Then, while holding the Shift key I clicked on the face and the two straight line leaving only the curve selected.



    I select Weld from the Plugins menu.



    A message box comes up asking if I want the curve to be closed. In this case I say no. If I chose Yes it would draw a line from one end of the curve to the other.



    Another message box asks if you want it to find the face. I chose Yes. then I used Push/Pull again and you can see the result.



    And again from another angle.


  4. #4
    Join Date
    Feb 2004
    Location
    Wendell, NC
    Posts
    116
    Very nice Dave, that is a job well done.

  5. #5
    And for Mac users, your SketchUp related directory should be something like this:

    {your home folder}
    - Library
    -- Application Support
    --- Sketchup 5
    ----Plugins
    -----weld.rb
    Smile. It worries the other guy.

  6. #6
    Join Date
    Mar 2003
    Location
    SE PA - Central Bucks County
    Posts
    65,888
    Vally ingtalesting!!
    --

    The most expensive tool is the one you buy "cheaply" and often...

  7. #7
    Join Date
    Feb 2003
    Location
    N/A
    Posts
    3,628
    Glad a few are finding this interesting.

    I thought I'd share a few things I found about Bezier curves.

    The degree of the curve is one less than the number of control points, so it is a quadratic for 3 control points. It will always be symmetric for a symmetric control point arrangement.


    The curve always passes through the end points and is tangent to the line between the last two and first two control points. This permits ready piecing of multiple Bézier curves together with first order continuity.



    The curve always lies within the convex hull of the control points. Thus the curve is always "well behaved" and does not oscillate erratically


    Closed curves are generated by specifying the first point the same as the last point. If the tangents at the first and last points match then the curve will be closed with first order continuity. In addition, the curve may be pulled towards a control point by specifying it multiple times.



    Adding multiple control points at a single position in space will add more weight to that point "pulling" the Bézier curve towards it.


    The blending function is always a polynomial one degree less than the number of control points. Thus 3 control points results in a parabola, 4 control points a cubic curve etc.

  8. #8
    Quote Originally Posted by tim rowledge
    And for Mac users, your SketchUp related directory should be something like this:

    {your home folder}
    - Library
    -- Application Support
    --- Sketchup 5
    ----Plugins
    -----weld.rb
    Thanks Tim,

    Do all of the rb scripts in the plugins folder show up in the SK menu bar plugin drop down menu? Both the weld and bezier scripts are in the plugin folder, but only weld is on the menu bar. I'm using free SK.

    Thanks, Larry

  9. #9
    Join Date
    Feb 2003
    Location
    N/A
    Posts
    3,628
    Larry, the scripts don't always appear in the Plugins menu even though they're in the Plugins folder. Bezier.rb for exame will appear in the Draw menu and if you select thebezier curve after drawing it and right click, you'll get a context menu entry for Editing the curve.

    If you can't figure out where a script should appear, open it in a text editor and scroll down to the bottom of it. The last few lines will direct SU where to display the script.

    # Add a menu choice for creating bezier curves
    if( not file_loaded?("bezier.rb") )
    add_separator_to_menu("Draw")
    UI.menu("Draw").add_item("Bezier Curves") { Bezier.tool }

    # Add a context menu handler to let you edit a Bezier curve
    UI.add_context_menu_handler do |menu|
    if( Bezier.selected_curve )
    menu.add_separator
    menu.add_item("Edit Bezier Curve") { Bezier.edit_curve }
    end
    This is the tail end of Bezier.rb to give you an idea.

  10. #10
    Ah, so that's where it gets decided. I'm happy to see that it is a nice obvious bit of code since it means I can change it if I want; for example I'd rather see 'wled' in the tools menu for example. In fact I'd say it would be nice to squeeze it in between offset and tape measure since it is manipulator of objects.

    I suppose I'll have to try to make some sense of Ruby at some point. It looks very odd to someone used to Smalltalk for the last 20 years.
    Smile. It worries the other guy.

  11. #11
    Join Date
    Feb 2003
    Location
    N/A
    Posts
    3,628
    Quote Originally Posted by tim rowledge
    I'd rather see 'wled' in the tools menu for example. In fact I'd say it would be nice to squeeze it in between offset and tape measure since it is manipulator of objects.

    I'd have a hard time finding under "wled"

    I'm not certain that you could insert a Ruby script entry into a menu between SU native menu entries. Still, putting Weld under Tools makes sense.

  12. #12
    Ah, that's the Old Welsh spelling as still used by two people in a remote corner of inner near-coastal southwestern north-east Wales. A place called Llandfyl if I remember right.

    As for putting a menu item in the middle of an existing menu, well I guess we need to know if there is an api something like
    UI.menu("Tools").add_item("Weld").after_item("Offs et") { join_edges }
    but I have no idea what the api is like. Like I say, I do Smalltalk. This Ruby syntax looks very odd to me.
    Smile. It worries the other guy.

  13. #13
    Join Date
    Feb 2003
    Location
    N/A
    Posts
    3,628
    I thought it might be something like that.


    You might want to ask on the Ruby forum at sketchup.com

  14. #14
    Since I haven't got another installment of the SU project Demo, I thought I could at least post the following.

    The first part of this has to do with drawing Bezier curves. This requires that you have a file called bezier.rb in your Plugins directory. If you don't see a Plugins menu when you have SU open, you also need to copy sketchup.rb from the Examples folder into the Plugins folder.

    The tree view of your SketchUp directory should be something like this:

    SketchUp
    --Plugins
    ----Examples
    ------sketchup.rb

    You want it to look like this:
    SketchUp
    --Plugins
    ----Examples
    ----bezier.rb
    ----sketchup.rb
    ----any other scripts you may have.rb

    I hope that makes sense.

    This dosent make sence to me, I don't have the pluggins up in my menu. How do I get this feature. Stacey

  15. #15
    Join Date
    Feb 2003
    Location
    N/A
    Posts
    3,628
    Stacey, go back and read my first post in the thread. You need to have a script called sketch.rb in the Plugins folder.

    If you don't see a Plugins menu when you have SU open, you also need to copy sketchup.rb from the Examples folder into the Plugins folder.
    After you have added these scripts, open SketchUp and you'll see the Plugins menu heading.

Similar Threads

  1. Exactly how straight should a BS blade weld be?
    By Michael Adelong in forum General Woodworking and Power Tools
    Replies: 7
    Last Post: 03-10-2006, 1:15 PM
  2. Tool Related - JB Weld Strength
    By Scott Coffelt in forum General Woodworking and Power Tools
    Replies: 17
    Last Post: 03-09-2006, 11:57 PM

Posting Permissions

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