Giter VIP home page Giter VIP logo

Comments (8)

scottlininger avatar scottlininger commented on May 25, 2024

I wondered how many seconds it would take for you to notice that. ;)

This was an added feature in a recent maintenance release, so only up to date clients will have this.

It occurs to me that this whole block needs to be wrapped in a version check. I'm not sure what behavior would be on older versions of SketchUp.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

No need for version checking - we can use feature checking:

SketchUp 6:

Sketchup::Menu.instance_method( :add_item ).arity
# > 1

SketchUp 8 M4:

Sketchup::Menu.instance_method( :add_item ).arity
# > -1

So one can do:

if Sketchup::Menu.instance_method( :add_item ).arity == 1
  UI.menu("File").add_item("Export STL...")
else
  UI.menu("File").add_item("Export STL...", insert_index)
end

So the version that support it accepts any number of argument, but the old ones only accepts one.

On the other hand - not all SketchUp classes works like this. UI.menu accepts any number of arguments without caring. UI.menu('Plugins', 123, 456, 789) doesn't raise any errors. (I checked to see if one could pick a sub-menu...)

from sketchup-stl.

scottlininger avatar scottlininger commented on May 25, 2024

Yeah, if it works in older versions, then awesome. Nice trick with the arity check! I learn something new every time you guys post.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

I just pushed a guard for it.

from sketchup-stl.

ChrisFullmer avatar ChrisFullmer commented on May 25, 2024

Great catch Thom! Hehe we learn new things when you post as well scott :)

On Tue, Oct 30, 2012 at 8:55 AM, Thomas Thomassen
[email protected]:

I just pushed a guard for it.


Reply to this email directly or view it on GitHubhttps://github.com//issues/30#issuecomment-9910966.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Closing this one now. Feature guard has been pushed to master.

from sketchup-stl.

jimfoltz avatar jimfoltz commented on May 25, 2024

The thing about feature checking is that you don't always know who added or changed the feature. It's possible that some feature has been implemented poorly by a "rogue" plugin".

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

You can test on a plain vanilla installation.

from sketchup-stl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.