sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Little help?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 2 Posters 294 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      mut
      last edited by

      Hi guys,

      I modified a stair.rb script ages ago, to better suit how i work, but i just wondered if any of you guys could help me out in this one area:

      basically i use: entities.add_face(point1, point2, point3, point4) etc, but i would like to add an 8mm radius between some of the points. i am an absolute beginner in this (I have done some basic jscript/java/php etc, but nothing with ruby/sketchup), and i am having trouble finding an answer to this question.

      thanks,

      Tom.

      http://www.StairBox.com We make stairs... easy

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Imagine you are drawing it with a pencil...
        You have 4 points as 'dots' on the paper (p1,p2,p3,p4), that would form a rectangle.
        For ease lets assume that points p1 and p2 are to have 8mm radius corners.
        You need to make some extra points 8mm away from these - lets called p1's p1a and p1b, and p2's p2a and p2b. You need to think along which edge's 'line' these points will be located...
        If you were to draw the edges p1a,p2a and p1b,p4 and p2b,p3 and p3,p4, you'd have a rectangle with two parts of its corners missing - where you'd add the arcs. Once the arcs are put in it's a complete loop that would face.

        Instead of using the "entities.add_face(p1,p2,...)" method you have to use "my_edge=entities.add_line(p1a,p2a)", then "entities.add_line(p1b,p4)" and so on to add the four edges (note there's no face just yet).

        Then use "entities.add_arc(center,xaxis,normal,radius,start_angle,end_angle,numsegs)" to add in the arc(s) to complete a loop of edges and arcs that could take a face.

        Arc making looks complex but once you work out what the various bits do it's not too bad...
        Let's assume this is 'flat' in the Z...
        center - e.g. it's p1ax = p1a offset in (say) the X by 8mm - it'll vary depending where the arc lies in the loop...
        xaxis = Geom::Vector3d.new(1,0,0) i.e.it's flat.
        normal = (Geom::Vector3d.new(0,0,1)).normalize to match 'flat' arc
        radius = 8.mm
        start_angle = 0.degrees
        end_angle = 90.degrees

        angles are in radians but you can enter them in degrees like this for sanity's sake !

        for these angle bits you'll need to experiment to see what suits your arcs' orientations etc

        'optional' numsegs = 8 [or however many segments you want in the arc] - more segments give smoother curves BUT multiply up the edges/faces exponentially when pushpulled, with little visual benefit...

        Finally use "my_face=my_edge.find_faces" to make the face that can exist within 'entities' that use these edges and arcs...

        I assume you'll then 'pushpull' the my_face to make a tread or something ? To avoid lines forming where an arc meets a straight edge you could add the arc and its two abutting edges to a curve entity first - then its extrusion would be 'smooth'... but let's get the basics first...

        .

        TIG

        1 Reply Last reply Reply Quote 0
        • M Offline
          mut
          last edited by

          thanks alot for the help TIG, really well explained (even i can understand it hehe)
          its working fine so far (in that it now creates the profile of the tread with rounded corners etc, )

          so now i have:

          tread_edge1 = entities.add_line([0, 0, radius], [0, 0, tt - radius]) #this is the short striaght edge at the front
          tread_edge2 = entities.add_line([radius, 0, tt], [tread + nosing, 0, tt], [tread + nosing, 0, 0], [nosing + rt, 0, 0], [nosing + rt, 0, rd], [nosing, 0, rd], [nosing, 0, 0], [radius, 0, 0]) # rest of the tread
          tread_bottrad = entities.add_arc(bottcenter,bottxaxis,bottnormal,radius,bottstart_angle,bottend_angle) #bott radius
          tread_toprad = entities.add_arc(topcenter,topxaxis,topnormal,radius,topstart_angle,topend_angle) #top radius

          then i did

          tread_base = tread_edge1.find_faces

          which creates the face just fine, but when i add the line:

          tread_base.pushpull treadwidth

          sketchup does nothing (not even draw the initial outline)

          any suggestions?

          thanks again,

          Tom.

          http://www.StairBox.com We make stairs... easy

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            My mistake... 'find_faces' returns the number of faces it makes not the face itself ! Was going from memory - which is clearly failing...

            Try this:

            tread_base=tread_edge1.faces[0]

            the 0 = the first face that the edge has (I assume it'll only have the one face)

            Then:

            tread_base.pushpull(treadwidth)

            It should now work...
            .

            TIG

            1 Reply Last reply Reply Quote 0
            • M Offline
              mut
              last edited by

              thats cracking!

              Thanks a lot, was having a bit of trouble with that part.

              it pretty much works now! gotta just figure a bit more maths out to do with width/depth of the stringers, and im good to go πŸ˜„

              thanks,

              Tom.

              http://www.StairBox.com We make stairs... easy

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                Good...

                Next make a spiral staircase !

                .

                TIG

                1 Reply Last reply Reply Quote 0
                • M Offline
                  mut
                  last edited by

                  gimme ten mins πŸ˜‰ 🀣

                  http://www.StairBox.com We make stairs... easy

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement