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

    Topics

    • brewskyB

      [Plugin] BIMserver 0.3.0 (june 30, 2015)

      Watching Ignoring Scheduled Pinned Locked Moved Plugins
      1
      0 Votes
      1 Posts
      309 Views
      No one has replied
    • brewskyB

      C++ using swig

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      18
      0 Votes
      18 Posts
      2k Views
      thomthomT
      For my own extensions that I write now I usually drop support for anything older than SU2014 - due to Ruby 2.0 and other improvements since then.
    • brewskyB

      Unload / reload plugin without closing SketchUp

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      17
      0 Votes
      17 Posts
      2k Views
      thomthomT
      Yea - the key is that you're plugin is not the only one operating and observer events can trigger in the middle of other operations. That's why I talked about caching the observer data until you find a "safe point" to execute. Mapping out this is important to avoid headache. Keeping observers to a minimum is best IMO - reduces overhead and risk of conflicts. Consider each observer if you really need it. I'm a bit more liberal with observers when I use them within the operation of my own custom Tools. (Within a Tool class) as I then assume I have greater control over the environment.
    • brewskyB

      Ruby "good practice" using constants?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      23
      0 Votes
      23 Posts
      3k Views
      Dan RathbunD
      @brewsky said: And after thinking on this, maybe TT's way of just making a module as a base-object for the plugin is a better approach than my BimTools-class. Because is't only used once, the module-approach seems more fitting... Oh hell yes. If you need only one copy of a code object, then generally it should be a module. If you need multiple copies of a code object (usually because the code must adapt to many other instance objects,) then you make it a class, and instantiate instances that are syncronized to a particular instance object. Often coders try to avoid using a module, because they think it's a static kind of object, and they believe it is harder to use than a class instance. What they miss is, that a module definition, is really an instance of class Module. So for example, your nested module Brewsky::BimTools::Manager is actually an instance object, and the preceeding identifier is the reference to the instance. If you remember this... then it can be easier to understand how using an anonymous singleton proxy class instance inside your Module class instance, makes sense. Imagine the Module class is "the hen". It lays an egg, which is your nested Manager module instance, that could be created thus: ` Brewsky::BimTools::Manager = Module.new { plugin managerial code here }But the Ruby interpreter calls the new()` constructor for you on the C-side of things. (Ie, the defintion block syntax for scripts, was invented for human happiness and readability; Ruby itself does not really need it.) But having methods in modules communicate (call each other,) works a bit different than in a class definition. Instance method definitions in a module, are meant for Library Mixin modules. (Read up on the include and extend methods.) They become different kinds of methods, depending on whether they are mixed into a class or module, and whether include and extend is used to do the mixing.) So at first blush, the coder thinks they must define all methods in a module as module functions that must be called with self.method_name(), ... they find this cumbersome, and they switch back to using a class defintion, and using only one instance of it. (A sort of psuedo-singleton class.) BUT.. the egg can have a membrane inside it's shell. This membrane analogy is the anonymous singleton proxy class instance created with the following syntax: module Brewsky module BimTools end end module Brewsky;;BimTools;;Manager # module variables and constants declared here MGR_VERSION ||= '1.2.3' @@bimmenu ||= nil class << self # self evaluates to the module instance # Everything in here acts like a class # instance BECAUSE IT ACTUALLY IS ! # In here we can access the module @@vars directly. # In here we define instance methods, not module methods. # But if they are public, they can be called like module # functions, from anywhere outside the module. private def get_version() MGR_VERSION end # In here we can call any other method in here, # without module qualification. public def version() get_version() end end # proxy class # Out here we can call any of the methods inside # the proxy class directly, without qualification. unless @@bimmenu @@bimmenu = UI.menu('Plugins').add_submenu('BIMTools') @@bimmenu.add_item('Version') { UI.messagebox("BIMTools ver #{version()}") } end end # module Brewsky;;BimTools;;Manager # 99.9% of the time, there is no good reason to # have any executing code outside your namespace. EDIT(2012-12-16): changed post title to "Why use a module instead of a class ?"
    • brewskyB

      &quot;refresh&quot; Group BoundingBox

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      8
      0 Votes
      8 Posts
      532 Views
      thomthomT
      Note that you also have ComponentDefinition.image? as Image elements also have definitions. Important to note when iterating the definitions collection.
    • brewskyB

      [Plugin] bim-tools 0.13.4(june 22, 2015)

      Watching Ignoring Scheduled Pinned Locked Moved Plugins
      206
      0 Votes
      206 Posts
      219k Views
      A
      @brewsky said: @awadrummer said: Does anyone know if this plugin is compatible with Sketchup Pro 2018? I did a little test and I ran into some issues for su2018 I will try to find some time to look into them... @awadrummer said: I'm looking to upgrade, but can't live without this one. Great to hear you like it! Thank you Brewsky! The only issue I've found with 2018 is it freezes/takes a long time to process, but I generally have ALOT of lines. With that being said it is still usable. Thanks for your help and designing this awesome plugin!
    • 1 / 1