sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Ruby plugin?

    Scheduled Pinned Locked Moved Developers' Forum
    16 Posts 6 Posters 955 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.
    • T Offline
      Thomas214
      last edited by

      @unknownuser said:

      Maybe a little concept image, because this plug is maybe yet existing πŸ˜„

      There is an Example in the attachment of what I would like to do with it.


      From a line to a wall

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        for something like this it's probably quicker and easier to draw [rectangle tool] the profile, select all lines and click followMe tool.

        there are lot of rubies that deal with more complex versions of this, but the standard tools can do quite a bit...
        draw profile, select line then followMe tool

        learn from the mistakes of others, you may not live long enough to make them all yourself...

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

          @driven said:

          for something like this it's probably quicker and easier to draw [rectangle tool] the profile, select all lines and click followMe tool.

          there are lot of rubies that deal with more complex versions of this, but the standard tools can do quite a bit...
          [attachment=0:1tdufwpm]<!-- ia0 -->use_followMe.png<!-- ia0 -->[/attachment:1tdufwpm]

          This is somethin for my school project so to draw it this way it isn't an option πŸ˜„

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

            @thomas214 said:

            @driven said:

            for something like this it's probably quicker and easier to draw [rectangle tool] the profile, select all lines and click followMe tool.

            there are lot of rubies that deal with more complex versions of this, but the standard tools can do quite a bit...
            [attachment=0:3bwzyrmz]<!-- ia0 -->use_followMe.png<!-- ia0 -->[/attachment:3bwzyrmz]

            This is somethin for my school project so to draw it this way it isn't an option πŸ˜„

            So write down the plan for your code...
            . check the model.selection contains some connected Edges (>>>path)
            . use a UI.inputbox() dialog to get the height
            . add a rectangle_face at start.position (p0) of first edge in path, calculating the other three points as p0=p1.clone; p1.z=p1.z+height etc using rectangle_face=entities.add_face(p0,p1,p2,p3)
            . use rectangle_face.followme(path) to extrude the new face along the path.
            . done

            TIG

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

              @tig said:

              @thomas214 said:

              @driven said:

              for something like this it's probably quicker and easier to draw [rectangle tool] the profile, select all lines and click followMe tool.

              there are lot of rubies that deal with more complex versions of this, but the standard tools can do quite a bit...
              [attachment=0:2kbtp9i4]<!-- ia0 -->use_followMe.png<!-- ia0 -->[/attachment:2kbtp9i4]

              This is somethin for my school project so to draw it this way it isn't an option πŸ˜„

              So write down the plan for your code...
              . check the model.selection contains some connected Edges (>>>path)
              . use a UI.inputbox() dialog to get the height
              . add a rectangle_face at start.position (p0) of first edge in path, calculating the other three points as p0=p1.clone; p1.z=p1.z+height etc using rectangle_face=entities.add_face(p0,p1,p2,p3)
              . use rectangle_face.followme(path) to extrude the new face along the path.
              . done

              Hmmm what if I useEdge.all_connectedthen the code from the the plugin push/pull face I have?

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

                I got this far

                prompts = ["x:", "y:", "z:"]
                defaults = [10, 20, 100]
                input = UI.inputbox prompts, defaults, "Input data"
                x = input[0]
                y = imput[1]
                z = imput[2]
                model = Sketchup.active_model
                ent = model.entities
                sel = model.selection

                model = Sketchup.active_model
                entities = model.active_entities
                pts = []
                pts[0] = [0, 0, 0]
                pts[1] = [x, 0, 0]
                pts[2] = [x, y, 0]
                pts[3] = [0, y, 0]

                Add the face to the entities in the model

                face = entities.add_face pts

                I just happen to know that the second and third entities in the

                entities objects are edges.

                entity1 = entities[1]
                entity2 = entities[2]
                edges = entity1.all_connected
                if (edges)
                UI.messagebox edges.to_s
                else
                UI.messagebox "Failure"
                end

                faces = []

                sel.each do |e|
                	if e.is_a? Sketchup::Face
                         faces.push e
                	end
                end   
                
                 Sketchup.active_model.start_operation "Wall"     
                faces.each do |e|
                     ent.add_group e
                     e.pushpull (z)
                 end
                		Sketchup.active_model.commit_operation	
                

                end

                if( not file_loaded?('Wall.rb') )
                UI.menu('Plugins').add_item('wall') {wall }
                end

                file_loaded 'Wall.rb'

                I think I have to create a new entety for the faces theat are created to use it in push/pull ?

                1 Reply Last reply Reply Quote 0
                • GaieusG Offline
                  Gaieus
                  last edited by

                  Okay. When it comes to a point and I cannot understand what it is then I move the whole topic to the developers' forum.

                  Good luck! πŸ˜‰

                  Gai...

                  1 Reply Last reply Reply Quote 0
                  • sdmitchS Offline
                    sdmitch
                    last edited by

                    http://rhin.crai.archi.fr/rld/plugin_details.php?id=250 is the link to midline2wall.rb which looks to be exactly what you want.

                    Nothing is worthless, it can always be used as a bad example.

                    http://sdmitch.blogspot.com/

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

                      @sdmitch said:

                      http://rhin.crai.archi.fr/rld/plugin_details.php?id=250 is the link to midline2wall.rb which looks to be exactly what you want.

                      Hmmm yes but how can I select multiple lines?

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

                        Choose the Select tool.
                        Pick on an object [like a line].
                        Hold down Ctrl and pick on another object to add it to the selection.
                        Holding down Shift toggles an object in/out of the selection.
                        Holding down Shift+Ctrl and picking an object removes it from the selection.

                        With a face one click to pick face, two clicks to pick face and its edges and three clicks to select it AND all other edges and faces connected to it...

                        TIG

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

                          @tig said:

                          Choose the Select tool.
                          Pick on an object [like a line].
                          Hold down Ctrl and pick on another object to add it to the selection.
                          Holding down Shift toggles an object in/out of the selection.
                          Holding down Shift+Ctrl and picking an object removes it from the selection.

                          With a face one click to pick face, two clicks to pick face and its edges and three clicks to select it AND all other edges and faces connected to it...

                          I was talking about the plugin πŸ˜„

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

                            Why not preselect the lines BEFORE running the tool? Then you process the selection??
                            You can pick kinds of objects with a Tool using pickhelpers and add them to a 'selection' etc BUT it's pretty complex for a simple tool... πŸ˜’

                            TIG

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

                              Can someone explain to me what this lines are for? I know they are for creating faces and offset lines but witch ones do what?

                              width, height = results
                              

                              pts = tl[0].vertices
                              i = 0
                              pts2 = []

                              pts.each do |pt|
                              pts2[i] = pt.position + [0 , 0 , results[1]]
                              i = i +1
                              end
                              line_copy = entities.add_line pts2

                              pts_copy = line_copy.vertices

                              i = 0
                              j = 0

                              new_face = entities.add_face(pts[0], pts_copy[0], pts_copy[1], pts[1])
                              new_face.pushpull (width / 2)

                              model.commit_operation
                              end

                              if( not file_loaded?("zid.rb") )

                              UI.menu("Plugins").add_item("Zid") { zid }
                              

                              end

                              file_loaded("zid.rb")

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

                                Thomas

                                You really need to learn to crawl before you walk...
                                You expect 'random lines of code' to be interpreted for you !
                                Please structure your questions a little more friendly...

                                width, height = results
                                presumably this follows a UI.inputbox that results= ?
                                There were two answers... width & height ??

                                pts = tl[0].vertices
                                sets an array called 'pts' to be the vertices related to the first element in the array tl - as it's not named logically that couls be a list of faces OR edges...
                                i = 0
                                sets a reference called 'i' to be 0 [this is used later in the '.each do' loop ???

                                pts2 = []
                                Makes an empty array called 'pts2' - presumably this will be filled with elements later...

                                pts.each do |pt| pts2[i] = pt.position + [0 , 0 , results[1]] i = i +1 end
                                This process the vertices in 'pts' [it would've been better to call it 'verts' ??]
                                And for each vertex [pt !!!] it returns its position as a 3d-point BUT swaps its z-value for whatever the results[1] was = probably the 'height' so why wasn't 'height' used ??

                                line_copy = entities.add_line pts2
                                Tis makes a line in [whatever] 'entities' [is] using the array 'pts2' as the 2 points - these have had their z values set to 'height'...

                                pts_copy = line_copy.vertices
                                This sets the array 'pts_copy' to be the vertices used by the edge 'line_copy' ???

                                i = 0 j = 0
                                sets the references 'i' and 'j' to 0

                                new_face = entities.add_face(pts[0], pts_copy[0], pts_copy[1], pts[1])
                                This sets the reference 'new_face' to be the face [if any] that is made using the 4 points listed [if they are not coplanar it will fail!]

                                new_face.pushpull (width / 2)
                                It pushpulls the 'new_face' by half of the 'width [i.e. results[0] set earlier]
                                Do NOT leave a gap between the 'pushpull' and its argument in parentheses [i.e face.pushpull(xxx) NEVER face.pushpull (xxx)]

                                model.commit_operation end
                                This closes the 'operation' and 'end's something - presumably the ' def zid' ?
                                You must have a model.start_operation("MyTool") to 'close' it later...

                                [ruby:1dtqmkst]if( not file_loaded?("zid.rb") )
                                UI.menu("Plugins").add_item("Zid") { zid }
                                end
                                file_loaded("zid.rb")[/ruby:1dtqmkst]
                                This makes the Plugins menu item a called '[ruby:1dtqmkst]Zid[/ruby:1dtqmkst]' which in turn runs the [ruby:1dtqmkst]def[/ruby:1dtqmkst] called '[ruby:1dtqmkst]zid[/ruby:1dtqmkst]' ???
                                The [ruby:1dtqmkst]file_loaded[/ruby:1dtqmkst] parts need you to have a [ruby:1dtqmkst]require 'sketchup.rb'[/ruby:1dtqmkst] earlier and ensure that only one menu item appears even if you manually reload the script into the same SKP session...

                                πŸ˜’

                                TIG

                                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