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

    Dimensions returned as Sketchup::Drawingelement?

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 399 Views 3 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.
    • thomthomT Offline
      thomthom
      last edited by

      I noticed that linear dimensions and radial dimensions all returns objects of the type Sketchup::Drawingelement. While if I use .typename I get DimensionLinear and DimensionRadial. How come they aren't returned as Sketchup::DimensionLinear and Sketchup::DimensionRadial objects like the rest of SU's entities?

      And what defines what the .typename returns? I thought it was controlled by the class. But since DimensionLinear and DimensionRadial both are Sketchup::Drawingelement, where's the .typename data coming from?

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • AdamBA Offline
        AdamB
        last edited by

        Are you not confusing the name of an object and the object itself?

        So foo.class returns the object which is of class Class.

        foo.typename returns the name of the class of class String

        So there will be a method in the class that gives the string representation of itself (a .to_s() kind of thing).

        Adam

        Developer of LightUp Click for website

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          hmm..

          
          model=Sketchup.active_model
          #<Sketchup;;Model;0x610ba90>
          sel=model.selection
          #<Sketchup;;Selection;0x6a611a8>
          sel[0].class
          Sketchup;;Drawingelement
          sel[0].to_s
          #<Sketchup;;Drawingelement;0x67e5e68>
          sel[0]
          #<Sketchup;;Drawingelement;0x67e5e68>
          sel[0].typename
          DimensionLinear
          
          

          The only thing here giving an indication that it's a dimension is the typename. I thought that the dimension object would be based on the Drawingelement class. Something like DimensionLinear < Drawingelement. And then I'd expect sel[0] to return an object that identities itself as such. The default behaviour of classes' .to_s are to return a string representing the class name. But maybe it isn't a subclass after all? Or maybe I'm just being really dense at the moment. (not unlikely...)

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            Yea, I've noted that there isn't any exposed API for dimensions. Which is why I find it odd that we can identify dimensions elements using the .typename method.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

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

              The, as yet, unstated downside of all of this is that there are virtually no methods in SUp Ruby to make or manipulate Dimensions anyway...

              There has been some work over the years using a unit length dimension component that is imported and scaled in its length to suit, and then perhaps exploded. You could also do things by grouping pre-existing dims etc...

              .

              TIG

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

              Advertisement