sketchucation logo sketchucation
    • Login
    1. Home
    2. davesexcel
    3. Posts
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    D
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 22
    • Posts 51
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Change variable after certain number of loops

      @sdmitch said:

      By the way, e-(e-0.5) = 0.5.

      Oh ya, I guess it would be e-0.5 so it would have to be pushpulled -(e-0.5)

      I keep getting pushpull stuck in the head.

      What I am looking for is on the last loop make b=0.5

      Thanks

      I have tried adding k into the mix mix with no success, now b is 0.5 on all the loops.

          prompts = ["length", "Run","height","Rise","Total Rises"]
          defaults = [36.0,10.0,1.0,7.75,7]
          input = UI.inputbox prompts, defaults, "Tread."
      
      
          
              a,b,c,d,e=input
      
              k = 0 #<<--- start k=0
              ent = Sketchup.active_model.entities
              for i in 0..e-1
              if k=e-1 then #<<<----if k=e-1
              b = 0.5
              end#<<<---
              ent.add_line [0,(b+1)+i*b,0+i*d-1], [0,(1.5+i*b),0+i*d-1]
              ent.add_line [0,1.5+i*b,0+i*d-1], [0,1.5+i*b,-d+(i*d)-1]
              ent.add_line [0,1+i*b,0+i*d-1], [0,1+i*b,-d+(i*d)-1]
              ent.add_line [0,1+i*b,-d+(i*d)-1], [0,1.5+i*b,-d+(i*d)-1]
              edg = ent.add_line [0,1+i*b,-1+i*d],[0,0.5+i*b,-1+i*d];vrt1=edg.end#<-----
              ent.add_arc [0,0.5+i*b,-c/2.0+(i*d)],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,20
              edg = ent.add_line [0,0.5+i*b,0+i*d],[0,b+(i*b)+1,0+i*d];vrt2=edg.start#<----_
              edg=ent.add_line [0,b+1+i*b,-c+i*d],[0,b+1+i*b,0+i*d]
              edg.find_faces; face=edg.faces[0]
      
           
              face.pushpull -a
              edgs=vrt1.edges.reject!{|e| e.length<a};edgs[0].soft=true#<-----
              edgs=vrt2.edges.reject!{|e| e.length<a};edgs[0].soft=true#<-----
                  #group1 = ent.add_group face.all_connected
              k=k+1#<<---add 1 to k
      end
        
      
      
      
      posted in Developers' Forum
      D
      davesexcel
    • RE: Change variable after certain number of loops

      @sdmitch said:

      Did you mean when i=e? Because i is never going to equal d(rise).

      Yep, you are correct,
      I wonder if it might be easier to find the back face and pushpull it e-(e-0.5)
      How do you pushpull the back face only?

      posted in Developers' Forum
      D
      davesexcel
    • Change variable after certain number of loops

      I am trying to figure out this loop,
      when i=e then I want b=0.5

      Thanks,
      Dave

      
      UI.menu("PlugIns").add_item("Draw stairs") { draw_stairs }
      
      def draw_stairs
      
      prompts = ["length", "Run","height","Rise","Total Rises"]
          defaults = [36.0,10.0,1.0,7.75,7]
          input = UI.inputbox prompts, defaults, "Tread."
      
      
          if input == false
          UI.messagebox("All Must Be Entered")
          else
            a,b,c,d,e=input
          #UI.messagebox("Tread input accepted!, #{input}!")
          end
      
      
          ent = Sketchup.active_model.entities
      for i in 0..e-1
      [b]#if i=e-1 then b=0.5[/b]
           
        ent.add_line [0,(b+1)+i*b,0+i*d-1],[0,(1.5+i*b),0+i*d-1]
        ent.add_line [0,1.5+i*b,0+i*d-1],[0,1.5+i*b,-d+(i*d)-1]
       ent.add_line [0,1+i*b,0+i*d-1],[0,1+i*b,-d+(i*d)-1]
      ent.add_line [0,1+i*b,-d+(i*d)-1],[0,1.5+i*b,-d+(i*d)-1]
        ent.add_line [0,1+i*b,-1+i*d],[0,0.5+i*b,-1+i*d]
        ent.add_arc [0,0.5+i*b,-c/2.0+(i*d)],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,20
          ent.add_line [0,0.5+i*b,0+i*d],[0,b+(i*b)+1,0+i*d]
          edg=ent.add_line [0,b+1+i*b,-c+i*d],[0,b+1+i*b,0+i*d]
           edg.find_faces; face=edg.faces[0]
         
          # #face = ent.add_face [0,0,0], [a,0,0], [a,b,0], [0,b,0]
          #face.reverse!
           face.pushpull -a
         
      	# edg.soft="true"
      	 #group1 = ent.add_group face.all_connected
          end   
            #group1_copy = group1.parent.entities.add_instance(group1.entities.parent, group.transformation)
      end
      
      posted in Developers' Forum
      D
      davesexcel
    • Smooth Line after push/pull

      Hello,
      When using the below code, how do I smooth the edges?

      ` prompts = ["length", "Run","height","Rise","Total Rises"]
      defaults = [36.0,10.0,1.0,7.75,7]
      input = UI.inputbox prompts, defaults, "Tread."

      if input == false
      UI.messagebox("All Must Be Entered")
      else
        a,b,c,d,e=input
      #UI.messagebox("Tread input accepted!, #{input}!")
      end
      
      
      ent = Sketchup.active_model.entities
      

      for i in 0..e-1
      ent.add_line [0,(b+1)+ib,0+id-1],[0,(1.5+ib),0+id-1]
      ent.add_line [0,1.5+ib,0+id-1],[0,1.5+ib,-d+(id)-1]
      ent.add_line [0,1+ib,0+id-1],[0,1+ib,-d+(id)-1]
      ent.add_line [0,1+ib,-d+(id)-1],[0,1.5+ib,-d+(id)-1]
      ent.add_line [0,1+ib,-1+id],[0,0.5+ib,-1+id]
      ent.add_arc [0,0.5+ib,-c/2.0+(id)],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,20
      ent.add_line [0,0.5+ib,0+id],[0,b+(ib)+1,0+id]
      edg=ent.add_line [0,b+1+ib,-c+id],[0,b+1+ib,0+id]
      edg.find_faces; face=edg.faces[0]

      # #face = ent.add_face [0,0,0], [a,0,0], [a,b,0], [0,b,0]
      #face.reverse!
       face.pushpull -a
      # edg.soft="true"
       #group1 = ent.add_group face.all_connected
      end   
        #group1_copy = group1.parent.entities.add_instance(group1.entities.parent, group.transformation)`
      

      Before Smooth

      https://drive.google.com/file/d/0ByXxMRXssekcaDdGRTJaN013dHc/view?usp=sharing

      After Smooth

      https://drive.google.com/file/d/0ByXxMRXssekcNC1GOWxRQTZWMmM/view?usp=sharing

      edg.soft="true" doesn't appear to do anything
      Thanks

      posted in Developers' Forum
      D
      davesexcel
    • RE: Round front edge of

      Thanks a lot for the replies. The code actually draws it the way I would draw it manually.
      Thanks!

      posted in Developers' Forum
      D
      davesexcel
    • Round front edge of

      ` prompts = ["length", "width","height"]
      defaults = [36.0,10.0,1.0]
      input = UI.inputbox prompts, defaults, "Tread."

      if input == false
      UI.messagebox("All Must Be Entered")
      else
      a,b,c=input
      UI.messagebox("Tread input accepted!, #{input}!")
      end

      ent = Sketchup.active_model.entities
      face = ent.add_face [0,0,0], [a,0,0], [a,b,0], [0,b,0]
      #face.reverse!
      face.pushpull c`

      I am using the above code, how can I round the front edge of my drawing. for example Height is 1, then I would like the front to be rounded with 1" diameter.

      thanks.

      posted in Developers' Forum
      D
      davesexcel
    • RE: Open Excel code to a Plug-in.

      Thank You Very much.

      posted in Developers' Forum
      D
      davesexcel
    • Open Excel code to a Plug-in.

      ` #UI.menu("PlugIns").add_item("Open Excel") { Open_Excel }

      #def Open_Excel
      require 'win32ole'
      excel = WIN32OLE.new('Excel.Application')
      excel.Visible = true
      number_of_sheets = excel.SheetsInNewWorkbook
      excel.SheetsInNewWorkbook = 1
      workbook = excel.Workbooks.Add
      excel.SheetsInNewWorkbook = number_of_sheets
      workbook.SaveAs('C:\TestFolder\YourWorkbook2.xlsx')

      workbook = excel.Workbooks.Open('C:\Users\Dave\AppData\Roaming\SketchUp\SketchUp 2014\SketchUp\Plugins\MyWorkbook.xlsx')
      #end`

      Hello,still new to Ruby
      This works when I run it through the ruby console, but I can't figure out the way to make it a Plug-in. I have added "#" to the lines that should make it a Plug-in.

      When I run the code throught the console, it creates a new workbook, saves it, then opens a different workbook. When I remove the "#" save the code and open Sketch-up.
      "Open excel" shows in the plug-in menu, when I click it though nothing happens.

      Thanks in advanced.

      posted in Developers' Forum
      D
      davesexcel
    • RE: Coordinates entered with InputBox

      Thanks, with your help I managed to clean it up a bit.
      I can draw the face now instead of just drawing the lines.

      I am now trying to select the face and offsetting it(Insetting).
      I can get the code to select it but it does not inset it.

      This is the error I get.
      **Error: #<NameError: undefined local variable or methodselection' for main:Object>
      C:/Program Files (x86)/SketchUp/SketchUp 2013/Plugins/first.rb:24
      (eval):24:in load' (eval):24**

      My final outcome will be to have a user input the rake dimensions. It will draw the rake and then draw the offset and move the offset to the right of the original.
      Basically, need the original, and then another one 1/4" smaller beside it.

      One thing at a time though

      This is the code I have so far.
      ` model = Sketchup.active_model
      entities = model.entities
      prompts = ["Hieght1", "Width","Height2"]
      defaults = [10,20,15]
      input = UI.inputbox prompts, defaults, "Rake Window."

      if input == false
      UI.messagebox("All Must Be Entered")
      

      else
      a,b,c=input
      UI.messagebox("Rake DATA accepted!, #{input}!")
      end
      #Coordinates from input box
      pt1 = [0, 0, 0]
      pt2 = [0, a, 0]
      pt3 = [b, c, 0]
      pt4 = [b,0,0]
      new_face = entities.add_face pt1, pt2, pt3, pt4
      Sketchup.send_action("viewFront:")
      Sketchup.send_action("viewTop:")
      #Select and offset
      model = Sketchup.active_model
      model.selection.add( model.active_entities.to_a )
      newFace = selection[1].offset(-.25)`

      Thanks for any replies.

      posted in Developers' Forum
      D
      davesexcel
    • RE: Coordinates entered with InputBox

      Thanks, it works

      posted in Developers' Forum
      D
      davesexcel
    • Coordinates entered with InputBox

      Very 1st attempt with Ruby Sketchup, I am trying to have somebody enter 3 numbers in input boxes and then draw the lines to create a rake.
      I don't know how to get the numbers entered into the coordinates.
      Thanks for any help in this

      Dave

      model = Sketchup.active_model
        entities = model.entities
        prompts = ["Hieght1", "Width","Height2"]
          defaults = [10,20,15]
          input = UI.inputbox prompts, defaults, "Rake Window."
      
          if input == false 
          UI.messagebox("All Must Be Entered")
          else
          UI.messagebox("Rake has been Drawn, #{input}!")
          end
          #Coordinates from inptut box
        pt1 = [0, 0, 0]
         pt2 = [0, 10, 0]#Height1
         new_face = entities.add_line pt1, pt2
        pt2 = [0, 10, 0]
         pt3 = [20, 15, 0]#Width
         new_face = entities.add_line pt2, pt3
        pt3 = [20, 15, 0]
         pt4 = [20, 0, 0]#Heights
         new_face = entities.add_line  pt3, pt4
        pt4 = [20, 0, 0]
         pt1 = [0, 0, 0]
         new_face = entities.add_line pt1, pt4
      
      
      Sketchup.send_action("viewFront;")
       Sketchup.send_action("viewTop;")
      
      posted in Developers' Forum
      D
      davesexcel
    • 1 / 1