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

    skybum

    @skybum

    0
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    skybum Unfollow Follow
    registered-users

    Latest posts made by skybum

    • RE: How to subclass things?

      Hm. Strange that you can extend a Sketchup object, but not subclass it! One of the things which put me onto this path was a post (http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=10299&p=69423) on best practice in coding for Sketchup, which recommends: "Don't arbitrarily extend SketchUp or Ruby base classes. Subclass them with your own class, and extend your class." Perhaps I am misunderstanding what this means?

      Anyhow, what I'm trying to do is generate a bunch of objects automatically, based on user interaction with another object. The objects I'm generating would have a hierarchical structure -- just like a group hierarchy -- and would benefit from actually being groups which the user can modify at a later date. So, generally speaking, it would be ideal if they were groups. The reason I was wanting to subclass them is because they'll need a lot of associated metadata with various associated methods, and a subclass of a group would seem like an ideal way to accomplish that.

      Is there a better way that I should be pursuing? Thanks for your help, by the way!

      posted in Developers' Forum
      S
      skybum
    • How to subclass things?

      Greetings,

      I am new to Ruby, so forgive me if this question is terribly ignorant. I'm trying to create a new class of objects which behave exactly like Sketchup::Group objects, with a few additions. Now, I can go ahead and extend the Sketchup::Group class, but that seems like bad form. What I ought to be able to do -- I think -- is simply subclass it. But I've spent all day trying to figure out how to do so, to no avail.

      I can make a subclass of Sketchup::Group easily enough, but it's totally inert and useless unless it's placed in Sketchup.active_model.entities -- and I can't figure out how to get it there. As best as I can figure out, I could extend that class with an "add_foobar" method -- although I'm not sure what it would actually do -- and as long as I'm extending Sketchup classes directly, I might as well just do it to Sketchup::Group directly.

      So, I've reached the point where I'm going in circles. Rather than spend another few hours documenting all the stupid things I've tried that haven't worked -- can anybody tell me how to subclass a native Sketchup object and put it into the scene?

      Thanks a million!

      posted in Developers' Forum
      S
      skybum