sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Pushpull coding problem

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 3 Posters 1.4k Views 3 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.
    • T Offline
      tomot
      last edited by

      I have a 1/4 circle, and the face defined
      how do I code the pushpull?

      e = entities.add_arc([x+$dist, y+$dist, z], vecx, vecz, $d/2, 0, pi/2, $s)
      e = entities.add_line([x+$dist, y+$dist, z],[x+$dist, y+$dist+$d/2, z])
      e = entities.add_line([x+$dist, y+$dist, z],[x+$dist+$d/2, y+$dist, z])
      e.find_faces # the face is now defined
      e.pushpull $thick #thick is defined

      tia

      [my plugins](http://thingsvirtual.blogspot.ca/)
      tomot

      1 Reply Last reply Reply Quote 0
      • T Offline
        todd burch
        last edited by

        Before the .find_faces, do an inventory of all the faces in your current entities set.
        After the .find_faces, do a second inventory of all the faces in your current entites set.
        Subtract the first inventory from the second.
        With the remaining elements, find the face with the same normal as the one you pushpulled.

        Todd

        1 Reply Last reply Reply Quote 0
        • T Offline
          todd burch
          last edited by

          The code you have won't work.

          "e" is an edge. e.find_faces works for edges, so it's good.

          e.pushpull will never work, 'cuz .pushpull only works on faces.

          Remove the e.pushpull, do what I said in the first post to come up the new face, and then do the pushpull on that face.

          Todd

          1 Reply Last reply Reply Quote 0
          • T Offline
            tomot
            last edited by

            Sorry but I don't understand your coding lingo πŸ˜„

            But I did find an example piece of code from a previous Ruby that works

            model.entities.add_arc([x+@dist, y+@dist, z], vecx, vecz, @d/2, 0, pi/2, @s)
            model.entities.add_line([x+@dist, y+@dist, z],[x+@dist, y+@dist+@d/2, z])
            e=model.entities.add_line([x+@dist, y+@dist, z],[x+@dist+@d/2, y+@dist, z])
            e.find_faces
            e.faces.first.pushpull @thick

            do I understand the following correctly?

            "e",collects the 3 entities (arc, line & line)

            "e.find_faces" ,then makes the face out of the entities

            now what does "first" do because without it pushpull still wont work?

            tia

            [my plugins](http://thingsvirtual.blogspot.ca/)
            tomot

            1 Reply Last reply Reply Quote 0
            • T Offline
              todd burch
              last edited by

              That won't work. I don't have time now to respond, but will later tonight.

              I've posted the code to do this somewhere before. Perhaps in the old pro Ruby forum. Maybe you can search on "find_faces" and "pushpull" to locate it.

              Todd

              1 Reply Last reply Reply Quote 0
              • T Offline
                tomot
                last edited by

                Todd, I think you misread my last post.

                I found that code in a another Ruby, and applied it to my example. and viola it WORKS!

                what followed was my understanding of what I thought the code was doing.
                I would like you to comment if my understanding is correct.

                and I don't understand why adding ".first" make the pushpull work?

                [my plugins](http://thingsvirtual.blogspot.ca/)
                tomot

                1 Reply Last reply Reply Quote 0
                • T Offline
                  todd burch
                  last edited by

                  @tomot said:

                  model.entities.add_arc([x+@dist, y+@dist, z], vecx, vecz, @d/2, 0, pi/2, @s)
                  model.entities.add_line([x+@dist, y+@dist, z],[x+@dist, y+@dist+@d/2, z])
                  e=model.entities.add_line([x+@dist, y+@dist, z],[x+@dist+@d/2, y+@dist, z])
                  e.find_faces
                  e.faces.first.pushpull @thick

                  do I understand the following correctly?

                  "e",collects the 3 entities (arc, line & line)

                  "e.find_faces" ,then makes the face out of the entities

                  now what does "first" do because without it pushpull still wont work?

                  tia

                  You are right - I misread. No, you don't understand correctly. πŸ˜‰ But you will soon enough.

                  @unknownuser said:

                  "e",collects the 3 entities (arc, line & line)

                  No. This assignment to "e" only assigns that last line (edge). You only need to .find_faces on a single edge for a closed loop of lines in order to get a face. So, your assignment is correct. You could have performed the .find_faces on the other line, or, any segment of the arc, and you would get the face like you want.

                  @unknownuser said:

                  "e.find_faces" ,then makes the face out of the entities

                  Basically, yes. The method looks at the edge you pass, then goes through all edges connected to the edge you passed, and for every closed and coplanar loop of edges that can be found, faces get made.

                  @unknownuser said:

                  now what does "first" do because without it pushpull still wont work?

                  The .first method will pass the first array element to pushpull. Your code is:

                  @unknownuser said:

                  e.faces.first.pushpull @thick

                  e is an edge.
                  e.faces is an array of all the faces that use this edge.
                  e.faces.first is the first element (the first face) in the faces array.
                  e.faces.first.pushpull calls the pushpull method for the passed face. (e.faces.first).

                  See the doc here: http://www.ruby-doc.org/docs/ProgrammingRuby/ for the Array class and its methods.

                  The .pushpull method is defined to be called for a face, not for an array. When you use the .first method on the faces array, you are picking a random face (the first one in the array at position face[0]), and it will pushpull just fine. Note that you are doing nothing in your code to identify the exact face you want to pushpull - you're just picking, essentially, a random face. So, yes, the pushpull works, but no, it's probably not acting on the face you want. If it is acting on the face you want, they you are a lucky person, because of all the newly created faces, the one you wanted jut happened to be the first one in the array.

                  Todd

                  1 Reply Last reply Reply Quote 0
                  • Didier BurD Offline
                    Didier Bur
                    last edited by

                    Hi,
                    The simplest way:

                    arc= model.entities.add_arc([x+@dist, y+@dist, z], vecx, vecz, @d/2, 0, pi/2, @s)
                    line1 = model.entities.add_line([x+@dist, y+@dist, z],[x+@dist, y+@dist+@d/2, z])
                    line2 = =model.entities.add_line([x+@dist, y+@dist, z],[x+@dist+@d/2, y+@dist, z])
                    face = model.entities.add_face[arc,line1,line2]
                    face.pushpull @thick
                    
                    

                    πŸ˜›
                    Regards,

                    DB

                    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