sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Plugin] AttributeInspector 1.1.1 – 2014-05-08

    Scheduled Pinned Locked Moved Plugins
    45 Posts 10 Posters 3.0k Views 10 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jiminy-billy-bobJ Offline
      jiminy-billy-bob
      last edited by

      Have you considered browsing through the read/write_default stuff?

      25% off Skatter for SketchUcation Premium Members

      1 Reply Last reply Reply Quote 0
      • A Offline
        Aerilius
        last edited by

        A "registry inspector" is - I believe - not possible with thr API. We can only read if we know the registry key to read.

        1 Reply Last reply Reply Quote 0
        • jiminy-billy-bobJ Offline
          jiminy-billy-bob
          last edited by

          Ok!

          25% off Skatter for SketchUcation Premium Members

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            .. and currently it is very dangerous as (on PC,) the keys written are mixed in among the application's keys.

            We can only ASK coders to prefix their keys similar to how they should prefix their plugin directories.
            ex: "Plugin_AE_AttributeInspector"

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • A Offline
              Aerilius
              last edited by

              I updated the plugin:
              • definitions (component/group/image definitions)
              • more data types: points and vectors
              • optimized column widths

              1 Reply Last reply Reply Quote 0
              • inteloideI Offline
                inteloide
                last edited by

                Hello Arilius !

                Your plugin is very useful for me thanks !

                Just missing an "update" button, in order to avoid closing an openning the window to refresh and it will be perfect !
                Thank you !
                Inteloide

                Humanity will do a huge step when the IT professionals will understand that computers are tools...

                1 Reply Last reply Reply Quote 0
                • jiminy-billy-bobJ Offline
                  jiminy-billy-bob
                  last edited by

                  @inteloide said:

                  Just missing an "update" button, in order to avoid closing an openning the window to refresh and it will be perfect !

                  +1 👍

                  25% off Skatter for SketchUcation Premium Members

                  1 Reply Last reply Reply Quote 0
                  • jiminy-billy-bobJ Offline
                    jiminy-billy-bob
                    last edited by

                    I found a conflict with TIG's 2DTools.

                    This plugin adds an attribute dictionnary to the model called "2Dtools", with a key "z" and a value of "0.0" in my case.
                    This causes the AttributeInspector to not load anything for the model, and the ruby console outputs this:

                    AE;;AttributeInspector;;Dialog Error for callback 'get_all'; 
                    comparison of Length with true failed
                    C;/Users/Marjorie/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/ae_AttributeInspector/AttributeInspector.rb;505;in `=='
                    C;/Users/Marjorie/AppData/Roaming/SketchUp/SketchUp 2014/SketchUp/Plugins/ae_AttributeInspector/AttributeInspector.rb;505;in `block (2 levels) in get_attributes'
                    Blablabla...
                    

                    (I was able to find the conflicting dictionnary using Eneroth's Attribute Editor)

                    25% off Skatter for SketchUcation Premium Members

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      That is the Trimble SketchUpAPI team's fault. They did not properly override the == method in the Length subclass.

                      It (the overridden method,) should have an unless clause that invokes super if the argument is not a Numeric subclass.

                      like:

                      
                        def ==(arg)
                          unless arg.is_a?(Numeric)
                            super
                          else
                            # check if arg is within SketchUp's
                            # tolerance of this Length instance
                          end
                        end
                      

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • TIGT Offline
                        TIG Moderator
                        last edited by

                        So any plugin which saves an attribute as a Length will return an error if the test on it is not sufficiently robust ?
                        So make a test like:
                        unless object.get_attribute(key, value, nil).class == NilClass ... else next ### end
                        So now if the key's value is NOT nil you do something...
                        BUT if it is nil you skip it ###...

                        But as I read this plugin's code its line #505 uses:
                        type = (value == true || value == false) ? "Boolean" : value.class.to_s
                        That is where the failure happens.
                        The Length is checked for true/false.
                        If it's recast as something more like:
                        type = value.class.to_s; type = "Boolean" if type =~ /TrueClass|FalseClass/
                        Then it'll work with Lengths too...
                        You could also add a trap for NilClass and perhaps skip that key/value pair ?
                        ; type = "Nil" if type =~ /NilClass/
                        OR take it as equivalent to FalseClass ??

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • A Offline
                          Aerilius
                          last edited by

                          Thanks for pointing this out!

                          I didn't think about that I could get an error when comparing things. I assumed something that doesn't compare would return "false". The ruby way would maybe be to do feature testing:
                          type = (value.is_a?(Comparable) && (value == true || value == false) ? "Boolean" : value.class.to_s
                          Which also fails due to SketchUp's bugged API method (Length is a Comparable).
                          This should be better (and without string comparison). Or shouln't ruby have a "Boolean" super class of which TrueClass and FalseClass are subclasses?
                          type = (value.is_a?(TrueClass) || value.is_a?(FalseClass)) ? "Boolean" : value.class.to_s

                          @unknownuser said:

                          You could also add a trap for NilClass and perhaps skip that key/value pair ?

                          I wanted to list all existing attributes. An attribute can persist with a value "nil" without being deleted/garbage collected.

                          1 Reply Last reply Reply Quote 0
                          • Dan RathbunD Offline
                            Dan Rathbun
                            last edited by

                            Every object, of every class inherits a .nil?() instance method (from Object.)
                            So:

                            val = thing.get_attribute(key, value, nil)
                            unless val.nil?
                              # do something
                            else
                              # recover gracefully
                            end
                            

                            I'm not here much anymore.

                            1 Reply Last reply Reply Quote 0
                            • Dan RathbunD Offline
                              Dan Rathbun
                              last edited by

                              BTW... you can currently use the triple equal method with Length class, so this will work:
                              true === length_value || false === length_value

                              I'm not here much anymore.

                              1 Reply Last reply Reply Quote 0
                              • Dan RathbunD Offline
                                Dan Rathbun
                                last edited by

                                @aerilius said:

                                Or shouln't ruby have a "Boolean" super class of which TrueClass and FalseClass are subclasses?
                                type = (value.is_a?(TrueClass) || value.is_a?(FalseClass)) ? "Boolean" : value.class.to_s

                                I always wondered why not ?

                                One thing I have done in the past is create a boolean?() query method for Object (or something else like Comparable.
                                Now this is frowned upon, and I never released it, just suggested, or had it in my test scripts.

                                
                                def boolean?()
                                  is_a?(TrueClass) || is_a?(FalseClass)
                                end unless method(;boolean?)
                                

                                AND / OR, ... create a Boolean mixin module, and then mix it into only TrueClass and FalseClass. The mixin module may not actually need any additional functionality, at all ?

                                Then the kind_of? (alias is_a?,) methods will return the appropriate true or false using a Boolean class argument, for any, and ALL objects.
                                The === will also work for all objects, which makes case statements work:
                                Boolean === value


                                Whichever one (or both,) ya'll want, would need to be adopted as an API extension, by the community. (And we'd need to convince the Trimble team to add it.)

                                I'm not here much anymore.

                                1 Reply Last reply Reply Quote 0
                                • tt_suT Offline
                                  tt_su
                                  last edited by

                                  The Length class is a bit of a special case. It's trying to be a sub-class of Float - but the Ruby API doesn't really let you do this. So there's some hackery in the background to make it work. I'll file an issue to see if we can avoid the argument error.

                                  1 Reply Last reply Reply Quote 0
                                  • Dan RathbunD Offline
                                    Dan Rathbun
                                    last edited by

                                    Thanks TT.

                                    Just returning false would be preferable, instead of raising an ArgumentError (when really TypeError occurs.)

                                    I'm not here much anymore.

                                    1 Reply Last reply Reply Quote 0
                                    • tt_suT Offline
                                      tt_su
                                      last edited by

                                      Yea, there's a few annoying inconsistency where the correct error isn't raised.

                                      1 Reply Last reply Reply Quote 0
                                      • 1
                                      • 2
                                      • 3
                                      • 1 / 3
                                      • First post
                                        Last post
                                      Buy SketchPlus
                                      Buy SUbD
                                      Buy WrapR
                                      Buy eBook
                                      Buy Modelur
                                      Buy Vertex Tools
                                      Buy SketchCuisine
                                      Buy FormFonts

                                      Advertisement