sketchucation logo sketchucation
    • Login
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Sideview modeling

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 5 Posters 10.2k Views 5 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.
    • G Offline
      gashtan
      last edited by

      @jim said:

      Hi gashtan,

      It is possible to do this using Ruby. You can use the normals of the faces to get the vectors, and then look for intersections of each vertex. At the least, it should be easy enough to create a construction point grid of the object.

      This sounds like fun to me, so I might try it this weekend if I get a chance.

      It would be greatfull if you find some free time and write this script...and then I try to understand the script 😄
      thanks for your answer.

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Malaise, gashtan,

        I have some ideas on how to do it, but I'd like to hear your ideas for a strategy on how to accomplish the task.

        Hi

        1 Reply Last reply Reply Quote 0
        • G Offline
          gashtan
          last edited by

          Jim

          my idea is very close to your:
          "You can use the normals of the faces to get the vectors, and then look for intersections of each vertex. At the least, it should be easy enough to create a construction point grid of the object."
          But your last sentence inspire me. It is possible to make only construction point and then joint to the shape (vertex) and finaly to the group?
          Because I think it can be a problem make it in ruby like in modelling, especially in a more complex shapes.

          1 Reply Last reply Reply Quote 0
          • MALAISEM Offline
            MALAISE
            last edited by

            Hi Jim and Gashtan

            @ Jim, your tutorial on SU ruby helps me really.

            About projections, I would select the biggest external face, define the normal
            vector and create a box using the 2 vectors of this face and the normal
            one . About dimension, I would take the biggest one on each vector-direction.

            Then I would project the object on faces this "outer box" and rotate axes
            according space references ( Red, Green, Blue )....

            ( sorry for that kind of frenglish )

            MALAISE

            La Connaissance n'a de valeur que partagée

            1 Reply Last reply Reply Quote 0
            • K Offline
              kwistenbiebel
              last edited by

              @Gashtan,

              Your request is a good one.
              It is actually the way I build up my architectural models from plan.
              I import the elevations, facades and sections in SU as .dxf, place them into position so you get a 3D model wireframe and start 'filling in' and building up the model.

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                Here's the result of my first attempt. Circles and curves are not supported and I doubt a hole will show up either. But the result is not bad for a rough-in.


                sideview.jpg


                sideview1.skp


                sideview.rb

                Hi

                1 Reply Last reply Reply Quote 0
                • G Offline
                  gashtan
                  last edited by

                  fuu...so I thing the code can be so simply, but now I recognise my BIG mistake 😄
                  I don't understand the half of the code, so thank you one more time to start writing the script for that...

                  1 Reply Last reply Reply Quote 0
                  • P Offline
                    pav_3j
                    last edited by

                    wow, this is interesting, keep up the work guys!

                    pav

                    Just won the 'Who is Least Competitive Championships' where trying to win will make you lose. Trying to lose makes you win which makes you lose. Not trying at all makes you lose which makes you win which makes you lose.

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by

                      It's not hard, but I don't know how to explain it all. If you have a specific question, I will try to answer.

                      Here's a overview of my thought process.

                      Draw lines at all of the Vertices. The direction of the lines is the normal of Face that contains the Vertex. When a line intersects with at least 2 others, then you have a Point that defines a vertex of the 3D shape.

                      In order to find all the intersections, I have to test each line for an intersection with every other line. To do that, I need as list of all lines.

                      SketchUp's Geom module has a method that will tell you if 2 lines intersect, so I decided to use it instead of write my own. The method is:

                      Geom;;intersect_line_line(line1, line2)
                      

                      But what is a line? There is no official Line class in SketchUp - a line is agreed to be a 2-element Array of either a Point and a Vector, or 2 Points. (See Geom module documentation.)

                      
                      line = [Geom;;Point3d.new(0,0,0), Geom;;Vector3d.new(0,0,1)]
                      line = [Geom;;Point3d.new(0,0,0), Geom;;Point3d.new(0,0,100)]
                      
                      

                      The first 2/3 of the script is all about building a list of lines in the form shown above (an Array of Arrays.)

                      Once the lines list is built, then we can iterate through each line and compare it to every other line for an intersection point.

                      
                      l = lines.length
                        for i in 0..l-2
                          for j in (i+1)..l-1
                            pt = Geom;;intersect_line_line(lines[i], lines[j])
                            next if pt.nil?
                            draw_cline(lines[i][0], pt)
                            draw_cline(lines[j][0], pt)
                            pt = pt.to_a.map{|e| round_to(e)}
                            line_hash[pt] += 1
                          end
                        end
                      
                      

                      I use a Ruby Hash object to keep a count of the intersection points. I am not sure this is a robust way to track the intersections, but it seems to work. (The hash key is an Array of Floats. 😲 )

                      And once you have a list of intersection points, then you can do whatever you like with them; such as draw Contructionpoints at their positions.

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • MALAISEM Offline
                        MALAISE
                        last edited by

                        Hi Jim

                        Very interesting topic. Your explanations give us the key for
                        understanding Drawing process. We have now a little idea of 3D coding
                        using Ruby in SU.
                        You're welcome

                        MALAISE

                        La Connaissance n'a de valeur que partagée

                        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