sketchucation logo sketchucation
    • Login
    1. Home
    2. davesexcel
    3. Topics
    ℹ️ 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

    Topics

    • D

      Two different colors to the same shape

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      2
      0 Votes
      2 Posts
      13k Views
      TIGT
      Please use 'code' blocks to format long Ruby extracts. I've fixed your post for you this time... You need to find all 'vertical' faces in the group named 'Top'. After the last part of the code add this... vfaces = entities.grep(Sketchup;;Face).find_all{|f| f.normal.z == 0 } vfaces.each{|f| f.material = clr }
    • D

      Round an angled edge

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      1k Views
      BoxB
      Is there some reason this is in the Developer forum?
    • D

      Round straight with round ends

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      1k Views
      D
      Ah...yes, I didn't think of selecting more than 1 edge, thanks!
    • D

      Open sketchup from Excel VBA and run ruby code

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      6
      0 Votes
      6 Posts
      2k Views
      Dan RathbunD
      @davesexcel said: 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? I think Jim explained it better and more detailed.
    • D

      Get data from already opened workbook

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      616 Views
      D
      Wow, I got it to work!! require 'win32ole' xl = WIN32OLE;;connect('Excel.Application') xl.visible=1 worksheet = xl.Worksheets(1)
    • D

      Insert Picture into excel

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      3
      0 Votes
      3 Posts
      742 Views
      Dan RathbunD
      ~ (1) Only write to paths that the user has write permissions on. @davesexcel said: # Puts in SketchUp install directory by default This path is a binary program path and the normal user does not have write permissions there. This is not the default path for Ruby when SketchUp v13+ is running. After SketchUp loads Ruby and it's API, it sets the working directory to the User's "Documents" directory. SketchUp 2013 and higher: Dir.pwd %(green)[#=> C:/Users/Dan/Documents] SketchUp 8 and earlier just left the current working directory in SketchUp's program path (which was a bad thing.) (2) In code when you are doing a write then read, you need to wait until the file is finished being written, and the OS file system advertises that it is "ready" and available. (ie, the old file handle is closed.) The Ruby standard File class has some class methods to help you determine if paths are readable or writable by the current user, and whether the OS reports if the file is finished being written (ie, does it exist yet?) def image_from_model( write_path = 'S;/Stairs/Stair Pics/', keys = { ;filename => 'write_image.jpeg', ;width => 500, ;height => 400, ;antialias => false, ;compression => 0.5, ;transparent => false } ) return false unless File.writable?(write_path) image_path = File.join( write_path, keys[;filename] ) keys[;filename]= image_path model = Sketchup.active_model view = model.active_view view.zoom_extents Kernel.sleep(2.0) # wait for view to redraw view.write_image(keys) @tid = UI.start_timer(0.5,true) { if File.exist?(image_path) UI.stop_timer(@tid) insert_to_excel(image_path) end } end def insert_to_excel() 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 # write done message to SketchUp console; put "Finished inserting image in Excel." end
    • D

      Ruby saveas .XLSM, format code

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      5
      0 Votes
      5 Posts
      2k Views
      Dan RathbunD
      I did a search in the MS Excel Dev forum on "+SaveAs +xlsm +UndefinedConversionError", and got 947 hits. (You can browse those yourself.) https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=exceldev%26amp;filter=alltypes%26amp;brandIgnore=True%26amp;sort=relevancedesc%26amp;filter=alltypes%26amp;searchTerm=%2BSaveAs+%2Bxlsm+%2BUndefinedConversionError At this point I would double-check that any macros in the Workbook do not have errors, that could give the file export routine issues.
    • D

      Get a list of File names on the input box

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      9
      0 Votes
      9 Posts
      715 Views
      Dan RathbunD
      OH! I see your booboo: inputbox always returns an array (except when the user cancels it returns false. So always check the result boolean-wise.) input = UI.inputbox prompts, defaults,list, "File Name" return unless input j = input[0]
    • D

      Count excel rows

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      3
      0 Votes
      3 Posts
      792 Views
      Dan RathbunD
      More Specifically: Would the Range.Find method help? Range.Find method
    • D

      Trouble finding faces

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      2
      0 Votes
      2 Posts
      494 Views
      sdmitchS
      @davesexcel said: 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. It seems to me that you define 'edg' twice if l=="Yes" but don't define it at all if l=='No'. #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" edg=ent5.add_line [0,b+3,b-c], [0,b+3-1,b-c]#<<<< edg 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 [image: 9RTt_Stairs.gif]
    • D

      Geometric Calculation with ruby

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      6
      0 Votes
      6 Posts
      674 Views
      thomthomT
      Using the Geom methods, and the methods on Geom::Point3d, Geom::Vector3d as much as possible is beneficial for performance. The SketchUp API methods are implemented in C++ and will be faster than pure Ruby code.
    • D

      Get point at 30 degrees

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      3
      0 Votes
      3 Posts
      284 Views
      S
      The trig functions are available in the Ruby Math module, e.g. Math.tan(), and SketchUp's extended Numeric class knows how to convert between radians and degrees, so just rewrite your excel expression as SketchUp Ruby: side = Math.tan(30.degrees)*36.0 Note: SketchUp's radians and degrees functions name the source dimension and convert to the other, so 30.degrees means the value 30 is in degrees and you want radians. [sdmitch beat me to it!]
    • D

      Draw face from webdialog

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      2
      0 Votes
      2 Posts
      276 Views
      sdmitchS
      add an action to the form <form action="skp:ruby_messagebox@"> change button type to "submit" In the callback tokens=params[1..-1].split("&"); tokens.each{|t| var,val = t.split("="); case var when "pt1" then pt1=Geom::Point3d.new(val) . . end
    • D

      Save workbook with input box entry

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      5
      0 Votes
      5 Posts
      453 Views
      D
      Right on, thanks!
    • D

      Need a way to round up

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      3
      0 Votes
      3 Posts
      272 Views
      D
      Right on, thanks, forgot about that.
    • D

      Script won't find face

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      290 Views
      D
      Thank you, That worked.
    • D

      Draw parallel line, distance=11

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      21
      0 Votes
      21 Posts
      3k Views
      D
      Thanks
    • D

      Change variable after certain number of loops

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      14
      0 Votes
      14 Posts
      652 Views
      jolranJ
      @unknownuser said: Thanks, I'm just trying to find a way not to have to keep pressing 'Ctrl & "A" then delete, every time I want to test a code. Ah, right! Understood. Well TT and Driven got the answers already. Another handy plugin is using Alex Ruby-code editor. You don't have to wrap code in Start Operation cause there's an inbuilt Play and Undo button. Very useful for testing loose code snippets. Copy and paste from Notepad for ex..
    • D

      Smooth Line after push/pull

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      334 Views
      sdmitchS
      @ktkoh said: sdmitch I am trying to learn from you code. How is the smoothing only applied to the edges created by the add arc? It needs some English description if you will!! Keith I save the vertices, vrt1 and vrt2, at the beginning and end of the arc. Then I look at all the edges associated with those vertices and eliminate all that are not the proper length. This leaves me with a single edge that is softened.
    • D

      Round front edge of

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      5
      0 Votes
      5 Posts
      418 Views
      D
      Thanks a lot for the replies. The code actually draws it the way I would draw it manually. Thanks!
    • 1
    • 2
    • 1 / 2