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

    Convert sketchup files to ruby

    Scheduled Pinned Locked Moved Developers' Forum
    20 Posts 6 Posters 2.0k Views 6 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.
    • W Offline
      wadhahmm
      last edited by

      hi,I used the below progrem to get cube ,can I get program from this cube.I mean invers work
      .please tell me if it possible.
      many thanks
      point1 = Geom::Point3d.new (0,0,0)
      point2 = Geom::Point3d.new (0,0,100)
      depth = 100
      width = 100
      model = Sketchup.active_model
      entities = model.active_entities
      pts = []
      pts[0] = [0, 0, 0]
      pts[1] = [width, 0, 0]
      pts[2] = [width, depth, 0]
      pts[3] = [0, depth, 0]

      Add the face to the entities in the model

      face = entities.add_face pts
      line = entities.add_line point1, point2
      begin
      status = face.followme line
      rescue
      UI.messagebox $!.message
      end

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

        You CAN make a Ruby that'd read the geometry, groups, components etc that are in a SKP file and then save it into DATa file or within a .RB file itself. However, why would you want to do that ? If you have the SKP file you can simply import in into another SKP file using the built-in tools or with a simple Ruby...

        Exactly what is it you want to do ?

        TIG

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

          You are nearly there - draw the face and then you don't need the 'line', simply use a 'height' value...

          
          ...
          height = 200
          face.followme(height)
          
          

          @wadhahmm said:

          hi,I used the below progrem to get cube ,can I get program from this cube.I mean invers work
          .please tell me if it possible.
          many thanks
          point1 = Geom::Point3d.new (0,0,0)
          point2 = Geom::Point3d.new (0,0,100)
          depth = 100
          width = 100
          model = Sketchup.active_model
          entities = model.active_entities
          pts = []
          pts[0] = [0, 0, 0]
          pts[1] = [width, 0, 0]
          pts[2] = [width, depth, 0]
          pts[3] = [0, depth, 0]

          Add the face to the entities in the model

          face = entities.add_face pts
          line = entities.add_line point1, point2
          begin
          status = face.followme line
          rescue
          UI.messagebox $!.message
          end

          TIG

          1 Reply Last reply Reply Quote 0
          • W Offline
            wadhahmm
            last edited by

            hi
            if i use sketchup 7 for example,and I use the tools from menu and draw cube can i convert this drawing to ruby code (program)

            many thanks

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              No, not really. You can not reverse engineer a shape into ruby code.

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

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

                @chris fullmer said:

                No, not really. You can not reverse engineer a shape into ruby code.

                Reverse engineering from a .skp into a .rb IS possible, but the programming effort required to find all of the skp's edges, faces, materials, layers, groups and components etc etc would be disproportionate compared with what you'd get. There are tools and methods available within ruby to make edges, curves, faces, pushpull, followme, add layers and materials etc etc ,that will do what you want without first making it in a skp and wrenching the info out of it.

                .

                TIG

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

                  It's possible. Exporting a model as a Ruby file is a technique I thought of when thinking about how to connect and synchronize multiple instances of SketchUp over a network connection.

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • Chris FullmerC Offline
                    Chris Fullmer
                    last edited by

                    I agree its possible to store all the entities into ruby. But I sort of get the feeling he wants an easy button that you can just click on and it will turn his shape into a script. So I was trying to be more realistic about what I am guessing he wants. But again, more info on the final purpose would be nice.

                    @Jim, for the script, what if it was more of something like a database that stored the entity info. And then write a ruby that would just update the model by reading the database. Is something like that feasible?

                    Chris

                    Lately you've been tan, suspicious for the winter.
                    All my Plugins I've written

                    1 Reply Last reply Reply Quote 0
                    • W Offline
                      wadhahmm
                      last edited by

                      Hi every body
                      I hope you are fine.
                      Can you show me any example for converting sketchup to ruby coiding,
                      wadhah

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

                        @chris fullmer said:

                        @Jim, for the script, what if it was more of something like a database that stored the entity info. And then write a ruby that would just update the model by reading the database. Is something like that feasible?
                        Chris

                        Probably "required" is a better word to use than "feasable." I haven't really thought terribly deeply about it, but I would think a database would solve numerous issues that might arise from trying to synchronize SketchUps.

                        Hi

                        1 Reply Last reply Reply Quote 0
                        • Chris FullmerC Offline
                          Chris Fullmer
                          last edited by

                          @wadhahmm said:

                          Hi every body
                          I hope you are fine.
                          Can you show me any example for converting sketchup to ruby coiding,
                          wadhah

                          How do you want the code to work? You want a script that will take a model, and then store that model into a ruby script. Then what? It does no good just sitting there in ruby. What do you plan on doing with it once its stored as "ruby". Is the script supposed to be able to then re-draw that shape on another computer's sketchup?

                          Chris

                          Lately you've been tan, suspicious for the winter.
                          All my Plugins I've written

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

                            To take it to its logical conclusion you extract all of the skp data into a data file... That is in effect the skp file so why have you bothered ? You could for example extract only geometry - that's something like an exporter format... Simply take all of the edges and list their start and end XYZ with ref , all of the faces and list their edges refs. Then you could take the info into a ruby to build the geometry...

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              @tig said:

                              To take it to its logical conclusion you extract all of the skp data into a data file... That is in effect the skp file so why have you bothered ?

                              That's what I've been thinking as well. I think we need some clarification on the actual purpose of the original question. I could be that the question itself isn't correct.

                              Thomas Thomassen — SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              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