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

    Posts

    Recent Best Controversial
    • RE: Global Object Stupidity, Ruby Question

      Martin,

      I knew you'd get back to this...

      This topic could almost be 'how do you like to code?', as there's lots of thoughts on it, much of it not Ruby specific.

      Some things I've seen and done --

      1. Wrap everything in modules with names like MR1.0, etc
      2. Prefix all public functions and class defs with something like MR1.0
      3. Make all methods and 'getters/setters' in classes private if there is no reason for them to be called from outside the class. Same thing for functions and class defs in modules
      4. I don't use global objects. Many coders never use them. I use '@@' variables in the module that loads everything
      5. We're not, but pretend we're writing code for the government, and everyone wants to break/hack it...

      I wrote a lot of my code with class variables, and at present on Windows that seems to be fine. For instance, the active model would be a class variable. It works now, but I don't know about mac's, and SU could change to allow multiple drawings in one instance, and hence, using class variables that way could break. When I get to it, I intend to rewrite my code. Put simply, at present, the Ruby environment is scoped to a single model. What if that changes?

      HTH,

      Greg

      posted in Developers' Forum
      M
      MSP_Greg
    • RE: [Plugin] VisMap - Layer/Scene Visibility Map

      Martin,

      I'm already pretty clean, namespace wise. (Only one public var, $vismap_model).

      I was referring to procedure / function / class visibility, not variable visibility.

      For instance, 'Model' may not be the best unqualified name for a class. IOW, what if someone has a lot of installed plug-ins? You don't want name resolution issues...

      Thanks,

      Greg

      posted in Plugins
      M
      MSP_Greg
    • RE: [Plugin] VisMap - Layer/Scene Visibility Map

      Martin,

      I don't use scenes much, but congrats on your plug-in (I thought you said it was your first somewhere.)

      For loading and unloading models, you may want to use the Sketchup::AppObserver and hook the onOpenModel(model) and onNewModel(model) events.

      Secondly, you might consider wrapping all your code in a module and use 'self' for the methods, and using 'private' to control for external visibility. Helps with 'namespace type' collisions.

      Lastly, I put the html as a string in my rb/rbs files and load it with dialog.set_html. It's easy to change the font size in the (inline) CSS before loading it in the dialog box, and I used 'em' for all the html size/layout units. HTML needs the same kind of escaping as strings passed between ruby and javascript.

      HTH,

      Greg

      posted in Plugins
      M
      MSP_Greg
    • RE: The Bug from Hell, Redux

      Martin,

      When writing a component stepper and a layer stepper, I had to escape () both single and double quotes everywhere when used in string data passed to a JS function using execute_script.

      Greg

      posted in Developers' Forum
      M
      MSP_Greg
    • RE: WebDialog.new Documented

      Re scrollbars, for IE use the following in the body css

      overflow:auto;

      This shows scrollbars if they're needed, otherwise they disappear

      Greg

      posted in Developers' Forum
      M
      MSP_Greg
    • RE: Assigning Event Handlers in JS-written UI

      Martin,

      1. I write all my code for Windows & IE
      2. I noticed some of your code had attributes that were not quoted. W3C says...
      3. Sometimes I assemble/modify the html as a string, then use set_html. All of my html is loaded as a string
      4. I've got 3 or 4 'dynamic' web dialogs in an extension at
        http://www.ChampionEnt.net/tech/ur/
        if any of it might interest you, let me know and I can post or send the code.
      5. Due to the 'modal window' issue, some of the code only works on a PC (settings window)
      6. Haven't really tested it lately on an Apple...
      7. Wrote some C# code to change an html file into a Ruby friendly string

      HTH,

      Greg

      posted in Developers' Forum
      M
      MSP_Greg
    • 1 / 1