[code] alias Sketchup as SU

Moderator: Jim

[code] alias Sketchup as SU

Postby Dan Rathbun » Thu Jan 27, 2011 5:12 pm

(code) alias Sketchup as SU

Code: Select all
Object.const_set('SU',Sketchup)  

Notes:
    Creates a global alias SU to refer to the Sketchup module.

Examples:

    model = SU.active_model
    SU.require('somefile.rbs')

SKX_alias_Sketchup_as_SU.rb

Can be added into the master skx.rb file.
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: [code] alias Sketchup as SU

    Postby thomthom » Thu Jan 27, 2011 5:15 pm

    Does Object.const_set('SU',Sketchup) have any advantage over SU == Sketchup ? Is it that it works regardless of the calling scope?
    0
    Thomas Thomassen — SketchUp Monkey & Coding addict
    List of my plugins and link to the CookieWare fund
    User avatar
    thomthom 
    PluginStore Author
    PluginStore Author
     

    Re: [code] alias Sketchup as SU

    Postby Dan Rathbun » Fri Dec 21, 2012 3:42 am

    thomthom wrote:Does Object.const_set('SU',Sketchup) have any advantage over SU == Sketchup ? Is it that it works regardless of the calling scope?

    Well first of all, you meant: SU = Sketchup

    It has no difference at the console, because you are already in the Object namespace.

    But to be precise, and to allow setting a global constant from ANY namespace, you need to call: Object.const_set('Name',object)
    You could call: Object.instance_eval("Name=object"), but that would be blurring what you are doing, just a bit.
    Better to use the const_set() method for readability.
    0


    Last bumped by Dan Rathbun on Fri Dec 21, 2012 3:42 am.
      I'm not here much anymore. But a PM will fire email notifications.
      User avatar
      Dan Rathbun 
      PluginStore Author
      PluginStore Author
       

      SketchUcation One-Liner Adverts

      by Ad Machine » 5 minutes ago



      Ad Machine 
      Robot
       



       

      Return to Skx Extension Library

      Who is online

      Users browsing this forum: No registered users and 1 guest

      Visit our sponsors: