sketchucation logo sketchucation
    • Login
    1. Home
    2. Dan Rathbun
    3. Posts
    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!
    🚨 Skimp | 25% Off until March 30 Buy Now
    Offline
    • Profile
    • Following 0
    • Followers 1
    • Topics 92
    • Posts 4,904
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: Debug RUBY Code in SketchUp

      This is a uitility by the SketchUp Development Team to integrate SketchUp extension debugging with various IDEs.

      Link Preview Image
      GitHub - SketchUp/sketchup-ruby-debugger: Ruby API debugger for SketchUp 2014 and later.

      Ruby API debugger for SketchUp 2014 and later. Contribute to SketchUp/sketchup-ruby-debugger development by creating an account on GitHub.

      favicon

      GitHub (github.com)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Automatically load a component.

      Use:
      definition.instances[1..-1].each {|i| i.erase! }

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Automatically load a component.

      @tntdavid said:

      If someone shares one of my dynamic components with a user without my extension, it must be impossible to use these dynamic features!

      There is no way to make it impossible.

      If you must use a DC function try to use a refinement for Ruby 2.0+.
      Code example withdrawn. A refinement will not work, because the DC code files would themselves need to use the refinement.

      • Modifying the DCFunctionsV1 class may not pass inspection by the Trimple Developer extension signing page.
      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Automatically load a component.

      My response is why use a hidden geometric construct to "protect" other components ?
      I would instead use an AttributeDictionary.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Automatically load a component.

      @tntdavid said:

      I added "cube.skp" in "Components Sampler" folder, there is always the same error message.

      Why, there's always this error message?

      David, code files need to be encoded as UTF-8 without BOM (BOM = Bit Order Mark.)

      The first line of all SketchUp code files should also always be the "magic comment":
      # encoding: UTF-8

      See: Ruby Core docs: Encoding - Script encoding

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Automatically load a component.

      @tntdavid said:

      The only thing I find about "String Object" is on this page:
      http://www.sketchup.com/intl/en/developer/docs/ourdoc/string

      David, The SketchUp Ruby API is an extension to standard Core Ruby, and
      adds a few methods to the Ruby's core String class:
      http://ruby-doc.org/core-2.0.0/String.html

      You need to learn standard Ruby before you can really appreciate what SketchUp's API adds to Ruby.

      Here is a set of lists that will help (at the official SketchUp forum):
      [url=http://forums.sketchup.com/t/ruby-learning-resources-wikilists/22861:2epja1nk]Ruby Learning Resources [WikiLists][/url:2epja1nk]
      (There is similar, but perhaps older list, here ar SCF as well.)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Import 2 components with a single icon.

      @tntdavid said:

      As it is possible to protect all a collection of "Dynamic Components", with a single "Parent Component," I want to import the "Component Parent" along with my dynamic models.

      Create a template model that already has your set of component definitions loaded, and then the user can use that template when they start a new model.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Automatically load a component.

      @tntdavid said:

      Error Loading File C:/Users/DAVID/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/TNT_ClickWindow3D_Trial_mm/logic.rb Error: #<TypeError: no implicit conversion of nil into String> C:/Users/DAVID/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/TNT_ClickWindow3D_Trial_mm/logic.rb:6:inload'`

      Where are my errors, which seem obvious to you?

      The error message tells you where the error is:
      "C:/Users/DAVID/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/TNT_ClickWindow3D_Trial_mm/logic.rb:6:inload'`"

      The error is in file: "logic.rb", at line 6, in the load() method call.

      The error is: "TypeError: no implicit conversion of nil into String",...

      ... which means your code is expecting a String object, but the object is a reference to nil instead.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Reload or recharge

      I think you mean Component "Reload..." when right-clicking on an instance.

      (1) You might set a keyboard accelerator (shortcut) like "CTRL+R".

      (2) There is no persistent automation integer ID for this command (that I can find.) The context menus are created "on-the-fly" as needed, and the menu commands are created just before the menu is displayed, and destroyed soon after the menu disappears. (So the "Reload..." command ID is always changing.)

      (3) There is no reload API method. But requests have been filed for one. I think there have been some workaround snippets posted in the forums. (Do a search. This was talked about just in the past week.)

      (4) I do not see a Sketchup::send_action() string for it listed in this topic:
      http://sketchucation.com/forums/viewtopic.php?t=34840

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: How to cut from object

      Topics should not be prefixed with "[code]" unless the post is a code snippet or example.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: 'Scene manager' plugin

      @eidam655 said:

      Mainly I would be interested in the Layers per Scene selection matrix.

      I believe this was implemented in a cross-tab of checkboxes by Martin Rinehart.

      The plugin series is called VisMap. (I do not know if he ever finished the Pro edition.)

      See links to his plugins here:
      http://sketchucation.com/forums/viewtopic.php?f=323%26amp;t=28782#MartinRinehart

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Skp2xml Sample 2013 SDK crash VS 2012?

      If the DLL does not have Ruby interfaces, then you will need to load and use it via the Ruby Fiddle library.

      Index of Classes & Methods in fiddle: Ruby Standard Library Documentation (Ruby 2.0.0)

      favicon

      (ruby-doc.org)

      Link Preview Image
      Module: Fiddle (Ruby 2.0.0)

      Module : Fiddle - Ruby 2.0.0

      favicon

      (ruby-doc.org)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Storing File Specific Attributes

      "Some_Dict_Name" needs to be "Medeek_SomePluginName" at a minimum, and can be expanded even more, like: "Medeek_SomePluginName_Purpose" if "SomePluginName" will have more than one dictionary, each used for different purposes.

      Or you can nest dictionaries inside another dictionary. So you can have one toplevel company dictionary for all your plugins, called "Medeek" (or whatever) and create child dictionaries for whatever plugins that need them. Those child dictionaries could have grandchild dictionaries.

      But it is most important to know that you must separate your dictionaries from those of other authors. (It is up to you how to separate your various plugin dictionaries.)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: [Code] Geometry Creation from Excel worksheet data

      @picpic020960 said:

      how to for write data to excel from ruby ?

      Try something simple like:

            def set_value(row,col,val)
              #
              @xl.activesheet.cells(row,col).value = val
              #
            end ### set_value()
      
      

      @picpic020960 said:

      other question :

      [Do you know if there] exists 'macro' recorder as in Excel ?

      Whatever exists in Excel, and has a built-in VisualBasic interface, can be accessed via WIN32OLE (from Ruby.)

      So, refer to the VisualBasic object model for Excel:
      MSDN: Object model (Excel VBA reference)

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Add something to my *.rbs file

      The question is not asked using the proper terms.

      (1) DISKFILE:

      The scrambled file cannot be modified after encryption. File encryption (aka scrambling,) is a disk file protection only. With SketchUp version 2016 and higher, a signature hash is generated for most executable files in the plugin sub-folder. This hash is checked against the files for any changes, and if the files have been changed, then the plugin may not load, depending upon the user's extension load security policy setting.

      During extension load, the rbs file is decrypted into plain text Ruby code in memory, and then passed to Ruby for evaluation, IF the extension load policy check was verified.

      (2) RUBY OBJECTS:

      Ruby is a dynamic programming language.

      This means that Ruby objects (like modules and classes,) can be opened for editing during runtime, and modified. Such modifications can be adding, overriding or deleting methods; adding, changing or removing constants pointing at other objects of various kinds; adding or changing variables (instance or class vars); defining entirely new classes and modules, etc.

      SO, your plugin is loaded from a scrambled rbs file, which creates some plugin sub-module inside your author/company toplevel module. Inside this there is some functionality accessed via a method call.

      Later on, some other file (scrambled or not,) from another one of your plugins, or some statements executed in the Ruby Console, CAN modify the Ruby objects in memory that the previous rbs file created.

      But, the modifying code should be sure to first test the Ruby ObjectSpace, for the presence of the Ruby object (usually a module) to modified. A simple if block can do it.

      if defined?(BomaStudio;;SomePlugin)
        BomaStudio;;SomePlugin.module_eval {
          # code to evaluate within your submodule
          @@a="my text"
          run_my_function(@@a)
        }
      end
      
      

      Okay?

      There is one caveat. Module and Class definitions can be frozen to prevent runtime modifications, and there is no way to unfreeze objects at runtime. So objects to be modified must not have been frozen.

      Follow proper etiquette !

      Do not modify the classes and modules of: the Ruby core or standard Libraries; of other authors or companies; and especially the Trimble SketchUp Ruby API.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Adding a callback when vray is dynamically loaded

      @thomthom said:

      hm... that's a tricky one... There is an event for extensions being unloaded. But no generic load event...

      What I have done in the past is create a custom subclass of the SketchupExtension class. In this subclass, I override the load() method being sure to first call super then do what I need to do when the extension has been loaded.

      require "extensions.rb"
      
      module CAUL;;VrayAware
      
        class VrExten < SketchupExtension
          def load()
            super # call load() in superclass
            #
            # Do other on load stuff here.
            #
          end
        end
      
        @@ext = VrExten.new("Vray","CAUL_VrayLoader")
      
        # Set the rest of the extension variables (version, creator, etc.)
      
        Sketchup.register_extension(@@ext)
      
      end
      
      
      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Plugin to stop sticking geometry

      @caecarvalho said:

      After you create your model in SU, using groups and components, I could toggle this button and it would disable sticking geometry.

      This is not possible.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Launching ruby script from Java

      Just FYI, ...

      (1) your script does not use any of the features in the "sketchup.rb" file (which is trying to load "langhandler.rb",) and therefore it is not necessary (or desirable) for you to try to load "sketchup.rb" in your script.
      Ie, only require actual dependency files.

      (2) The Tools folder is protected in SketchUp version 2016 and higher. It is for Trimble use ONLY. Do not put your scripts in this folder.
      Put them in a sub-folder of the "plugins" subfolder, of the user %APPDATA% path. Ie,
      plugin_path = %USERPROFILE% + "\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\Plugins\\" + "YourCompany_YourPluginName"

      (3) SketchUp loads it's OWN implementation of Ruby. It does NOT use JRuby !
      So, ...
      ScriptEngine jruby = new ScriptEngineManager().getEngineByName("jruby"); jruby.eval(new BufferedReader(new FileReader("C:\\product\\SketchUp\\SketchUp 2016\\Tools\\api_dev.rb")));
      ... is worthless.

      You need to start the SketchUp application using a -RubyStartup parameter:
      "C:\\product\\SketchUp\\SketchUp 2016\\sketchup.exe" + " -RubyStartup " + plugin_path + "\\api_dev.rb"

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: List of entities and organisation ?

      And this diagram is a bit out of date. (There are some missing classes, and perhaps changes since it was drawn back in the v7 and v8 days.)

      http://www.sketchup.com/intl/en/developer/docs/diagram.php


      Also,...

      @iltis said:

      For example : ArcCurve (arcs and circles) is a subclass of the Curve class, and an edge is a part of a random curve ...

      Implies an incorrect assumption.

      The SKP document object hierarchy (ie, the model database tree) is a wholly separate construct than the Ruby class hierarchy and relationships.

      For example, the Sketchup::Edge class is not a sub-class of the Sketchup::Curve class. Both, are descendants of the Sketchup::Entity class. Sketchup::Curve and Sketchup::ArcCurve objects are special collection classes that connect edges together, but are not themselves an actual "model element". Sketchup::Edge objects are an actual model element, and so are a sub-class of Sketchup::Drawingelement.

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • RE: Starting a process in background using Ruby system()

      given:
      cmd = "c:\\program files\\..."

      one of::
      system( "start \"#{cmd}\"" )

      or:
      system( %[start "#{cmd}"] )

      or:
      system( "start", %["#{cmd}"] )

      or:
      %x[start "#{cmd}"]


      See Ruby docs on literal strings:
      http://ruby-doc.org/core-2.0.0/doc/syntax/literals_rdoc.html#label-Strings

      posted in Developers' Forum
      Dan RathbunD
      Dan Rathbun
    • 1
    • 2
    • 11
    • 12
    • 13
    • 14
    • 15
    • 245
    • 246
    • 13 / 246