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
    • Two different colors to the same shape

      SidesGrey.jpgWith this code I am drawing a box and a box top, I am coloring the box gray and the top blue. I just require the top to be blue, the sides of the top need to be grey.

      l=96
      w=60
      h=60
      heel=8
      slope=4
      clr='Gray'
      rfClr='blue'
      ent = Sketchup.active_model.entities
      	
      		#---------Clear All
      Sketchup.active_model.entities.clear!		
      		#----------------
         model = Sketchup.active_model
      
          model.start_operation "Create Box"
      #-----------------------------------------------------------------------------      
      
          entities = model.active_entities
          group = entities.add_group
          entities = group.entities
             group.name="Box"
          @pt0 = [0, 0, 0]
          @pt1 = [0, l*12, 0]
          @pt2 = [w*12.0, l*12, 0]
          @pt3 = [w*12, 0, 0]
      
      newface = entities.add_face(@pt0, @pt1, @pt2, @pt3)
          newface.material=Sketchup;;Color.new clr
      newface.reverse!
          newface.pushpull h*12
      	    group = entities.add_group
          entities = group.entities
             group.name="Top"
      #-----------Top----------------
          @pt0 = [0, 0, h*12]
          @pt1 = [0, 0, h*12+heel]
          @pt2 = [w*12/2, 0, 12*h+heel+(w/2)*slope]
          @pt3 = [w*12, 0, 12*h+heel]
      	    @pt4 = [w*12, 0, 12*h]
      newface = entities.add_face(@pt0, @pt1, @pt2, @pt3, @pt4)
          newface.material=Sketchup;;Color.new rfClr
      
          newface.pushpull l*12
      
      posted in Developers' Forum
      D
      davesexcel
    • Round an angled edge

      I have not been able to figure out how to round an angled edge, and hope somebody has an idea.
      I use a half inch radius.Regular round noseAngled round nose
      For the straight angle, I draw a 1/2" line down the middle, then add a circle, then push the edge.

      I can draw the line for the angled board, but the circle gets all funky. The second image shows the way the curve should be for the angled board.

      Thanks.


      Sketchup File

      posted in Developers' Forum
      D
      davesexcel
    • RE: Round straight with round ends

      Ah...yes, I didn't think of selecting more than 1 edge, thanks!

      posted in Developers' Forum
      D
      davesexcel
    • Round straight with round ends

      [img]RoundTread3.jpg[/img]I cannot figure out how to round the edge on this , it always stops just before the turn. Follow me does not seem to work for this either.


      RoundTread.skp

      posted in Developers' Forum
      D
      davesexcel
    • RE: Open sketchup from Excel VBA and run ruby code

      Thanks,
      I think I understand the concept, from excel vba we are opening sketchup and passing on a variable that a plugin will recognize to run the plugin?

      posted in Developers' Forum
      D
      davesexcel
    • RE: Open sketchup from Excel VBA and run ruby code

      Thanks Jim,
      SendKeys does work for the interm, ENV variable looks promising, I will have to look into it.

      posted in Developers' Forum
      D
      davesexcel
    • Open sketchup from Excel VBA and run ruby code

      I found this code from google groups it opens sketchup from Excel.

      
      
      Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
      Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
      Sub fLaunchProgram(ByVal sProgram As String)
          Dim ProcessHandle As Long
          Dim ProcessId As Long
          On Error GoTo errExit
          ProcessId = Shell(sProgram, vbNormalFocus)
          ProcessHandle = OpenProcess(&H1F0000, 0, ProcessId)
          WaitForSingleObject ProcessHandle, INFINITE
          Exit Sub
      
      errExit;
          MsgBox "External program " & sProgram & " was not found", vbCritical, " fLaunchProgram"
      End Sub
      'To load SU
      Sub pTest()
          fLaunchProgram ("C;\Program Files\SketchUp\SketchUp 2015\SketchUp.exe")
      End Sub
      
      

      I have assigned the macro to a button, using sendkeys seems to take care of the splash screen when Sketchup opens.

      
      Sub Button1_Click()
          pTest
          SendKeys "~ (tilde)"
          
          'Shell ("C;\Users\dmorrison\AppData\Roaming\SketchUp\SketchUp 2015\SketchUp\Plugins\GetFromExcel.rb")
      
      End Sub
      
      

      How can I run a plugin from sketchup with vba?

      posted in Developers' Forum
      D
      davesexcel
    • RE: Get data from already opened workbook

      Wow, I got it to work!!

      
      require 'win32ole'
      xl = WIN32OLE;;connect('Excel.Application')
      xl.visible=1
      worksheet = xl.Worksheets(1)
      
      
      
      
      posted in Developers' Forum
      D
      davesexcel
    • RE: Get data from already opened workbook

      Thanks Dan,
      I did find that, just can't get it to work< using all sorts of options, It seems to want to open up a new excel, and not use the existing excel. So it errors when finding the range.

      
        require 'win32ole'
      #WIN32OLE.connect('Excel.Application')
      xl = WIN32OLE;;connect('Excel.Application')
      xl.visible=1
      
      #wb = xl.Workbooks('TestAddImage.xlsm')
      puts "a"
      worksheet = xl.activesheet
      puts "b"
      #worksheet2 = xl.Worksheets('Sheet2')
      puts "c"
      worksheet.Range('a1').Value=1111
      worksheet.Range('a2').Value
      
      
      posted in Developers' Forum
      D
      davesexcel
    • Get data from already opened workbook

      Hi,
      I have a workbook, that I use to input the values for the sketchup to draw. I seems to be working fine but would like it to be able to get the info from the workbook that is already opened, not having to open the workbook to get the data. Is there a way to get the info from an active workbook?

      This way when I run the code, it will get the info and insert the picture onto the sheet.

      
        UI.menu("PlugIns").add_item("Get From Excel") { get_from_excel }
      require('win32ole')
      	 def get_from_excel
      ents=Sketchup.active_model.active_entities
      require 'win32ole'
      
      
      xl = WIN32OLE.new('Excel.Application')
      xl.visible=1
      
      wb = xl.Workbooks.Open('C;\TestFolder\Stair_Info_to_Sketchup.xlsm')
      
      worksheet = wb.Worksheets('Sheet1')
      worksheet2 = wb.Worksheets('Sheet2')
      
      ent = Sketchup.active_model.entities
      Sketchup.active_model.entities.clear!		
      rise=worksheet.range('a2').value
      run=worksheet.range('b2').value
      b=worksheet.range('i2').value
      d=worksheet.range('h2').value
      c=worksheet.range('c2').value
      dado=worksheet.range('d2').value
      ns=worksheet.range('e2').value
      e=worksheet.range('f2').value
      wdth=worksheet.range('g2').value
      tr=7
      g=1.25
      f=worksheet.range('j2').value
      h=0.5
      
      ent.add_line [0,(run+1)+0*run-1.5,rise-c], [0,(1.5+0*run)-1.5,rise-c]  
      ent.add_line [0,1.5+0*run-1.5,rise-c+dado], [0,1.5+0*run-1.5,rise-c]
      ent.add_line [0,1.5+0*run-1.5,rise-c+dado], [0,1+0*run-1.5,rise-c+dado]
      ent.add_line [0,1+0*run-1.5,rise-c+dado], [0,1+0*run-1.5,rise-c]
      edg = ent.add_line [0,1+0*run-(1+0.5),rise-c],[0,e+0*run-(ns+1),rise-c]
      edg = ent.add_line [0,e+0*run-(ns+1),rise-c],[0,e+0*run-(ns+1),rise]
      edg = ent.add_line [0,e+0*run-(ns+1),rise],[0,(run+1)+0*run-1.5,rise]
       edg=ent.add_line [0,1+run-1.5,rise],[0,1+run-1.5,rise-c]
              edg.find_faces; face=edg.faces[0]
                face.pushpull wdth
         group1 = ent.add_group face.all_connected ;group1.name="Tread"
      		  group1.description="Tread"         
      #loop through treads--------------------
      for i in 1..tr-2
        group2 = group1.copy
        tran = Geom;;Transformation.translation [0, run*i, rise*i]
      group2.transform! tran ;group2.name="Treads"
        end
        #---Good
         group = ent.add_group(); group.name="Bottom riser"
       
      ent2 = group.entities
       pts = []
       pts[0] = [0, 0, 0]
       pts[1] = [0,-e,0]
       pts[2] = [0, -e,rise-c+dado]
       pts[3] = [0, 0, rise-c+dado]
       # Add the face to the entities in the model
      face = ent2.add_face pts
       face.pushpull wdth
       group.description = "Bottom riser"
       #---good
       group = ent.add_group(); group.name="Riser"
      ent3 = group.entities
       pts = []
      pts[0] = [0, run, rise-c]
      pts[1] = [0,run-e,rise-c]
       pts[2] = [0, run-e,2*rise-c+dado]
       pts[3] = [0, run, 2*rise-c+dado]
       # Add the face to the entities in the model
      face = ent3.add_face pts
       face.pushpull wdth
      group.description = "Riser"
      
      for i in 1..tr-3
        group2 = group.copy
        tran = Geom;;Transformation.translation [0, run*i, rise*i]
        group2.transform! tran
        end
        #----good
        #<<<<<<Top Hanger
      
      
      
        group = ent.add_group(); group.name="Top riser"
       
         ent5 = group.entities
       ent5.add_line [0,b-2,d-c], [0,b-2,d-(rise+1)]
        ent5.add_line [0,b-2,d-(rise+1)], [0,b-2+h,d-(rise+1)]
        ent5.add_line [0,b-2+h,d-(rise+1)], [0,b-2+h,d]
          edg=ent5.add_line [0,b-2,d-c], [0,b-2-1,d-c]#<<<< edg
        ent5.add_line [0,b-2-1,d-c], [0,b-3,d]
        ent5.add_line [0,b-3,d] , [0,b-2+h,d]
        edg.find_faces; face=edg.faces[0]
        face.pushpull wdth
        
       #<<<<<<<<<<<<<<<Stringer
        
              # offset vectors for rise and run
      		group = ents.add_group(); group.name="Stringer"
      		ent1 = group.entities
      		
              risevect = Geom;;Vector3d.new([0,0,0], [0,0,rise])
              runvect = Geom;;Vector3d.new([0,0,0], [0,run,0])
      	#<<<<<<<<<<<<<<#last tread
              lstrun = Geom;;Vector3d.new([0,0,0], [0,(run-e),0])
      	#<<<<<<<<<<<<<<<<<<<<Move Stringer
      	ms= Geom;;Vector3d.new [(-wdth-g),0,0]
      	ms2= Geom;;Vector3d.new [-wdth/2+g/2,0,0]
      		#<<<routed stringer
        group = ent.add_group(); group.name="Routed Stringer"
       
         ent6 = group.entities
         pts = []
      
         pts[0] = [0,b-(1+e),d]
         pts[1] = [0,b-(4+e),d]
         pts[2] = [0,-3, rise]
         pts[3] = [0, -3, 0]
          #calculate pts 4 & 5
        vec = pts[2].vector_to(pts[1])
        v = vec.axes[1].reverse
        tpt = pts[2].offset(v,f)
        pts[4]=Geom.intersect_line_line [pts[3],[0,1,0]],[tpt,vec]
        #pts[4] = [0,(run+2.5)*0.4256, 0]
        pts[5] = Geom.intersect_line_line [pts[0],[0,0,1]],[tpt,vec]
        #pts[5] = [0, b-(1+e), (d-12 )]
        
             #add the face to the entities in the model
          face = ent6.add_face pts
          face.pushpull g
          group.description = "Routed Stringer"
      	#copy routed stringer
       group1 = group.copy
        tran = Geom;;Transformation.translation ms
      group1.transform! tran
      
      #-----Pictures Insert Code---------------
      
       #require 'win32ole'
       model = Sketchup.active_model
       entities = model.active_entities
       view = model.active_view
       # Puts in SketchUp install directory by default
       status = view.write_image "test.jpeg"
       keys = {
         ;filename => "S;/Stairs/Stair Pics/write_image.jpeg",
         ;width => 500,
         ;height => 400,
         ;antialias => false,
         ;compression => 0.5,
         ;transparent => false
       }
       model = Sketchup.active_model
       view = model.active_view
       new_view = view.zoom_extents
       view.write_image keys
       #------------------------------------
      #-----Pictures Insert Code---------------
      pic = worksheet.Pictures.Insert('S;\Stairs\Stair Pics\write_image.jpeg')
      range = worksheet.Range('A5;F20')
      pic.ShapeRange.LockAspectRatio = false
      pic.Top = range.Top
      pic.Left = range.Left
      pic.Width = range.Width
      pic.Height = range.Height
      
      
      end
      
      

      Thanks

      posted in Developers' Forum
      D
      davesexcel
    • Insert Picture into excel

      This code works fine by itself:

      
       model = Sketchup.active_model
       entities = model.active_entities
       view = model.active_view
      
       status = view.write_image "test.jpeg"
       keys = {
         ;filename => "S;/Stairs/Stair Pics/write_image.jpeg",
         ;width => 500,
         ;height => 400,
         ;antialias => false,
         ;compression => 0.5,
         ;transparent => false
       }
       model = Sketchup.active_model
       view = model.active_view
       new_view = view.zoom_extents
       view.write_image keys
      

      and this works fine by itself:

      
      require 'win32ole'
      
      xl = WIN32OLE.new('Excel.Application')
      xl.visible=1
      
      wb = xl.Workbooks.Open('C;\TestFolder\Test2.xlsx')
      
      worksheet = wb.Worksheets('Sheet1')
      worksheet2 = wb.Worksheets('Sheet2')
      
      worksheet.Range('a1').Value=12
      worksheet.Range('a1;b4').Value
      
      #-----Pictures Insert Code---------------
      pic = worksheet2.Pictures.Insert('S;\Stairs\Stair Pics\Fellner-Landing.JPG')
      range = worksheet2.Range('A1;F15')
      pic.ShapeRange.LockAspectRatio = false
      pic.Top = range.Top
      pic.Left = range.Left
      pic.Width = range.Width
      pic.Height = range.Height
      

      I want to save the image then insert it into Excel.
      -My idea was to save the image, then insert that saved image into excel.
      The code does not like the jpeg file S:/Stairs/Stair Pics/write_image.jpeg, it will insert any other pic except the one that was created with the code above.

      
      
       require 'win32ole'
       model = Sketchup.active_model
       entities = model.active_entities
       view = model.active_view
       # Puts in SketchUp install directory by default
       status = view.write_image "test.jpeg"
       keys = {
         ;filename => "S;/Stairs/Stair Pics/write_image.jpeg",
         ;width => 500,
         ;height => 400,
         ;antialias => false,
         ;compression => 0.5,
         ;transparent => false
       }
       model = Sketchup.active_model
       view = model.active_view
       new_view = view.zoom_extents
       view.write_image keys
       #------------------------------------
      
      
      xl = WIN32OLE.new('Excel.Application')
      xl.visible=1
      
      wb = xl.Workbooks.Open('C;\TestFolder\Test2.xlsx')
      
      worksheet = wb.Worksheets('Sheet1')
      worksheet2 = wb.Worksheets('Sheet2')
      
      worksheet.Range('a1').Value=12
      worksheet.Range('a1;b4').Value
      
      #-----Pictures Insert Code---------------
      pic = worksheet2.Pictures.Insert('S;/Stairs/Stair Pics/write_image.jpeg')
      range = worksheet2.Range('A1;F15')
      pic.ShapeRange.LockAspectRatio = false
      pic.Top = range.Top
      pic.Left = range.Left
      pic.Width = range.Width
      pic.Height = range.Height
      
      
      posted in Developers' Forum
      D
      davesexcel
    • Ruby saveas .XLSM, format code

      I thought 52 was the code to save as an .xlsm file, but I get an UndefinedConversionError.

      
      workbook.SaveAs("C;\TestFolder\TestAddImage.xlsm",52)
      
      
      posted in Developers' Forum
      D
      davesexcel
    • RE: Get a list of File names on the input box

      The list works very well, but the workbook is not opening, I narrowed it down to it not recognizing "s" as a string.

      ` ents=Sketchup.active_model.active_entities
      def slashify(path)
      path.gsub(/\\|\|///,'/')
      end

      #Dir.new('C:\TestFolder\').each { |file| puts file }

      prompts = ["Find a file?"]
      defaults = ["a"]

      list = [Dir.entries("C:/TestFolder/Doit with Sketchup/")[2..-1].join('|')]

      input = UI.inputbox prompts, defaults,list, "File Name"
      j=input

      puts j
      #j = j.gsub(/[^a-zA-Z0-9-." "]/,"")

      puts j
         s='C:/TestFolder/Doit with Sketchup/' + j
      

      puts s

      excel = WIN32OLE.new('Excel.Application')
      excel.Visible = true

      #number_of_sheets = excel.SheetsInNewWorkbook
      #excel.SheetsInNewWorkbook = 1
      excel.Workbooks.Open(s)
      #workbook = excel.Workbooks.Add
      #excel.SheetsInNewWorkbook = number_of_sheets
      ws = excel.Worksheets(1)`
      
      posted in Developers' Forum
      D
      davesexcel
    • RE: Get a list of File names on the input box

      ListBoxThank you both for the answers,
      Both
      list = Dir["C:/Testfolder/*.*"].join("|")
      and
      Dir.entries("C:/TestFolder/")[2..-1].join('|')
      They list all the files, but all on one line and the list ends up in the title with a blank textbox.

      ` ents=Sketchup.active_model.active_entities
      def slashify(path)
      path.gsub(/\\|\|///,'/')
      end

      #Dir.new('C:\TestFolder\').each { |file| puts file }

      prompts = ["Find a file?"]
      defaults = ["a"]

      list = Dir.entries("C:/TestFolder/")[2..-1].join('|')

      input = UI.inputbox prompts, defaults,list, "File Name"
      a=input

      puts a
      puts list`

      posted in Developers' Forum
      D
      davesexcel
    • Get a list of File names on the input box

      The code
      Dir.new('C:\\TestFolder\\').each { |file| puts file } Will print out all the file names in the console.

      Is there a way to get that loop to populate the dropdown input box?

      ` ents=Sketchup.active_model.active_entities

      #Dir.new('C:\TestFolder\').each { |file| puts file }

      prompts = ["Find a file?"]
      defaults = [""]

      list=[Dir.new('C:\TestFolder\').each { |file| puts file }]

      input = UI.inputbox prompts, defaults,list, "File Name"
      a=input

      puts a`

      posted in Developers' Forum
      D
      davesexcel
    • Count excel rows

      I am opening putting data in an excel workbook, I am counting the rows with

      rw=ws.range("1;1").specialcells(11)
      

      Then add the code to the row below

      	ws.Cells(rw.row+1,1).Value = a
      	ws.Cells(rw.row+1,2).Value = b
      	ws.Cells(rw.row+1,3).Value = d
      	ws.Cells(rw.row+1,4).Value = rs
      	ws.Cells(rw.row+1,5).Value = rise
      

      This works as intended but the cell that has formatting is considered not empty.

      In excel vba I would use

      rw=cells(rows.count,1).end(xlup).row
      

      This will find the last row with something in it in column 1 and does not include formatting, such as borders.
      Is there an equivalent to this in Ruby?

      posted in Developers' Forum
      D
      davesexcel
    • Trouble finding faces

      I am using an If else statement, I got it to work earlier in the code, but now I am having an issue grouping a new entity and finding it's face, it has to do with adding an arc and not adding an arc.

      How would one name a group and find the faces in this situation?
      Arc and no Arc

       ents=Sketchup.active_model.active_entities
       
       
       
      		prompts = ["Stair Width", "Travel","Tread Thickness","Total Height","Riser Thickness","Stringer Width","Stringer Thickness","Top Hanger Thickness","Customer","Customer Address","Top Hanger Nose","Round Nose","Flight","No Nose"]
          defaults = [36.0,51.5,1.5,46.5,0.5,11.25,1.25,0.5,"My Builder", "234 Jimmys street","Yes","Yes","Main","Yes"]
      	list=["","","","","","","","","","", "Yes|No","Yes|No","Main","Yes|No"]
      	
          input = UI.inputbox prompts, defaults,list, "Stair Info"
              a,b,c,d,e,f,g,h,i,j,k,l,m,n=input
      		cst=i.to_s
      		adr=j.to_s
      ent = Sketchup.active_model.entities
      	tr=(d/8.0).ceil
      	rise=d/tr
      	run=((b-(1+h))/(tr-1))
      wdth=a-2.5
      	
      			prompts = ["Stair Width", "Number if Rises","Height","Travel","Hanger"]
          defaults = [36.0,tr,d,b,h]
      	list=[""]
      	
          input = UI.inputbox prompts, defaults,list, "Rise and Run"
              wth,rs,b,d,h=input
      		cst=i.to_s
      		adr=j.to_s
      ent = Sketchup.active_model.entities
      l
      	rise=b/rs
      	run=((d-(1+h))/(rs-1))
      	
      		#---------Clear All
      Sketchup.active_model.entities.clear!		
      		#----------------Make 1st tread
      ent.add_line [0,(run+1)+0*run-1.5,rise-c], [0,(1.5+0*run)-1.5,rise-c]  
      ent.add_line [0,1.5+0*run-1.5,rise-c+0.1875], [0,1.5+0*run-1.5,rise-c]
      ent.add_line [0,1.5+0*run-1.5,rise-c+0.1875], [0,1+0*run-1.5,rise-c+0.1875]
      ent.add_line [0,1+0*run-1.5,rise-c+0.1875], [0,1+0*run-1.5,rise-c]
      #Nose Yes/No<<<<<
      if n=="Yes"
      ns=1
      else 
      ns=0
      end
      puts ns
      puts d
      #End add nose<<<
      #ROUND Nose Yes/No<<<<<<
      if l=="Yes"
         puts "Round Nose"
      #add arc<<<<<<
      edg = ent.add_line [0,1+0*run-1.5,rise-c],[0,e+0*run-1.5,rise-c];vrt1=edg.end
      ent.add_arc [0,0.5+0*run-1.5,-c/2.0+(rise)],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,12
       edg = ent.add_line [0,1+run-1.5,rise],[0,0.5-1.5,rise];vrt2=edg.start
      #end Add Arc<<<<<
      else
      edg = ent.add_line [0,1+0*run-(1+0.5),rise-c],[0,e+0*run-(ns+1),rise-c]
      edg = ent.add_line [0,e+0*run-(ns+1),rise-c],[0,e+0*run-(ns+1),rise]
      edg = ent.add_line [0,e+0*run-(ns+1),rise],[0,(run+1)+0*run-1.5,rise]
      puts "SQUARE NOSE"
      end
      
      
       
        edg=ent.add_line [0,1+run-1.5,rise],[0,1+run-1.5,rise-c]
              edg.find_faces; face=edg.faces[0]
                face.pushpull wdth
      		  if l=="Yes" 
      		 edgs=vrt1.edges.reject!{|e| e.length<wdth};edgs[0].soft=true
               edgs=vrt2.edges.reject!{|e| e.length<wdth};edgs[0].soft=true
      		 else
      		 end
      		  group1 = ent.add_group face.all_connected ;group1.name="Tread"
      		  group1.description="Tread"
      for i in 1..tr-2
        group2 = group1.copy
        tran = Geom;;Transformation.translation [0, run*i, rise*i]
      group2.transform! tran
        end
        ents=Sketchup.active_model.active_entities
       
       
      
        #---Good
         group = ent.add_group(); group.name="Bottom riser"
       
      ent2 = group.entities
       pts = []
       pts[0] = [0, 0, 0]
       pts[1] = [0,-e,0]
       pts[2] = [0, -e,rise-c+0.1875]
       pts[3] = [0, 0, rise-c+0.1875]
       # Add the face to the entities in the model
      face = ent2.add_face pts
       face.pushpull wdth
       group.description = "Bottom riser"
       #---good
       group = ent.add_group(); group.name="Riser"
      ent3 = group.entities
       pts = []
      pts[0] = [0, run, rise-c]
      pts[1] = [0,run-e,rise-c]
       pts[2] = [0, run-e,2*rise-c+0.1875]
       pts[3] = [0, run, 2*rise-c+0.1875]
       # Add the face to the entities in the model
      face = ent3.add_face pts
       face.pushpull wdth
      group.description = "Riser"
      
      for i in 1..rs-3
        group2 = group.copy
        tran = Geom;;Transformation.translation [0, run*i, rise*i]
        group2.transform! tran
        end
        #----good
      
      #<<<<<<Top Hanger
        group = ent.add_group(); group.name="Top riser"
       
         ent5 = group.entities
       ent5.add_line [0,b+3,b-c], [0,b+3,b-15] 
        ent5.add_line [0,b+3,b-15], [0,b+3+h,b-15]
          ent5.add_line [0,b+3+h,b-15], [0,b+3+h,b]
      	#ROUND Nose Yes/No<<<<<<
      	if l=="Yes"
      	puts "top hanger round nose"
      	  #add arc<<<<<<
      	edg = ent5.add_line [0,b+3,b-c], [0,b+3-0.5,b-c] ;vrt1=edg.end
      
      		ent5.add_arc [0,b+3-0.5,b-(c/2)],[0,0,b+3-1],[-1,0,0],-c/2.0,0,180.degrees,12
      			  edg =  ent5.add_line [0,b+3+h,b], [0,b+2.5,b];vrt2=edg.start
      	#end Add Arc<<<<<	
      else
      puts "top hanger square nose"
       ent5.add_line [0,b+3,b-c], [0,b+3-1,b-c]
       ent5.add_line [0,b+3-1,b-c], [0,b+3-1,b] 
        ent5.add_line [0,b+3-1,b] , [0,b+3+h,b] 
      end
      	
      
             #add the face to the entities in the model
       
            edg.find_faces; face=edg.faces[0]
                face.pushpull -wdth
      
       
       
       
      
      posted in Developers' Forum
      D
      davesexcel
    • RE: Geometric Calculation with ruby

      Thanks a lot, I need to work on
      Geom.intersect_line_line more

      posted in Developers' Forum
      D
      davesexcel
    • RE: Geometric Calculation with ruby

      Hello,
      b & d are variables, rise and run are calculated from b & d.

      for this example rise=d/6 and run=(b-(1+e))/5

      I just put in the numbers so the code can easily be copied and run

      posted in Developers' Forum
      D
      davesexcel
    • Geometric Calculation with ruby

      ![11.25" width](/uploads/imported_attachments/Rd18_StringerWidth.jpg "11.25" width")
      Hi,
      I am trying to get a point so that my group ends up being 11.25" wide.
      ` Sketchup.active_model.entities.clear!

      b=51.5
      d=46.5
      e=0.5
      rise=7.75
      run=10

      #<<<routed stringer
      

      group = ent.add_group(); group.name="Routed Stringer"

      ent6 = group.entities
      pts = []

      pts[0] = [0,b-(1+e),d]
      pts[1] = [0,b-(4+e),d]
      pts[2] = [0,-3, rise]
      pts[3] = [0, -3, 0]
      pts[4] = [0,(run+2.5)*0.4256, 0]
      pts[5] = [0, b-(1+e), (d-12 )]

         #add the face to the entities in the model
      face = ent6.add_face pts`
      

      The calculation I came up with will only work when the variables are a specific value, has anybody an idea how to calculate the points, so my width stays 11.25 with variable inputs?

      Thanks

      posted in Developers' Forum
      D
      davesexcel
    • 1
    • 2
    • 3
    • 1 / 3