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

    Topics

    • R

      [New scripter] Will need help on my project (now and then)

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      21
      0 Votes
      21 Posts
      2k Views
      Dan RathbunD
      @ruts said: In my calculations ... I want to use the base ruby class Matrix which is made for such operations. I found out that it's not just adding require 'matrix' to your code. Because SketchUp was not distributed with the Ruby Standard Library until version 2014. @ruts said: I did copy the matrix.rb and e2mmap.rb (which is required by matrix.rb) from the ruby2.2.2 folder ... This will not work, as you need to use the library compiled and distributed with the Ruby version that SketchUp uses. The constants RUBY_VERSION and RUBY_PATCHLEVEL typed at the console tell you what SketchUp embedded Ruby is. @ruts said: ... I believe this is the right way to require 'matrix'. Nope (when the standard library is properly installed,) just a simple require 'matrix' will do (because it will load it's own dependencies as it is evaluated.) @ruts said: I think I already have a solution for my problem. NO you don't, because you "don't have time to read the book," all this basic Ruby 101 knowledge is escaping you. So just go to my GitHub repo and get the Standard Ruby 1.8.6-p287 Library packaged for SketchUp 2013 and earlier on Windows ONLY. https://github.com/DanRathbun/sketchup-ruby186-stdlib-extension/releases/tag/2 With SketchUp closed: (1) Put the RBZ archive someplace where you can navigate easily to it. (2) Delete any manually copied library files (such as those you mentioned copying above.) (3) Then start SketchUp 8 and use the manual "Install Extension ..." button from Window > Preferences > Extensions (3a) Navigate to where you saved the RBZ archive, and select it, click OK. (4) Open the console and test that the paths are correctly set in $LOAD_PATH (aka $:) by typing: puts $: and ENTER You should see a listing similar to: puts $:%(green)[C:/Program Files (x86)/SketchUp/SketchUp 8/Plugins C:/Program Files (x86)/SketchUp/SketchUp 8/Tools C:/Program Files (x86)/SketchUp/SketchUp 8/Plugins/Ruby186/lib/ruby/1.8 C:/Program Files (x86)/SketchUp/SketchUp 8/Plugins/Ruby186/lib/ruby/1.8/i386-mswin32 C:/Program Files (x86)/SketchUp/SketchUp 8/Plugins/Ruby186/lib/ruby/site_ruby/1.8 C:/Program Files (x86)/SketchUp/SketchUp 8/Plugins/Ruby186/lib/ruby/site_ruby/1.8/i386-msvcrt]nil The actual program files path might also look like: %(green)[C:/Program Files (x86)/Google/Google SketchUp 8/...] (5) Then further test the loading of "matrix.rb" via: require "matrix" You should see true returned.
    • R

      Extract 3D information to regenerate the shape

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      689 Views
      Dan RathbunD
      SketchUp is a surface modeler. Everything in SketchUp is basically made up of edges, vertices, and faces. There are no complex built-in 3D shape classes in the SketchUp Ruby API. Instead primitives are either grouped into Group class instances, or ComponentInstance class instances. (Each have a defining ComponentDefinition class instance.) These mentioned classes are all sub-classes of Entity, and inherit it's functionality (as well as the intermediate Drawingelement class functionality.) Any Entity subclass instance can have any number of AttributeDictionary instances attached to them. You can put whatever custom data you wish into attributes in a custom dictionary, usually named the same as your plugin. (Ex: "Ruts_Shaper_Properties") Back to the grouped 3D shape. Groups and components have a built-in definition name and each instance of them can have a separate more unique instance name. Group and component instances have built-in transformation property, from which you can query all the translational, rotational, scaling and axial subproperties. See the Geom::Transformation class. All Drawingelement subclasses (the objects that can be seen in the model,) have an invisible boundingbox, from which you can get the corners and the center. See the Geom::BoundingBox class. It would be more efficient to create the basic shapes as an external SKP component library, and insert them into the model, rather than draw each using code, but drawing them adhoc can be done. You should most likely install the SketchUp Team's example Shapes plugin, and study the code. http://extensions.sketchup.com/en/search/site/Shapes
    • 1 / 1