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

    Save and recall parameters of an object created with ruby

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 601 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.
    • B Offline
      biervat
      last edited by

      I'm writing an extension to create a wall in a simular way as the profile builder plugin. Before you draw the wall you have to adjust several parameters (height, width, ...). But when the wall is drawn I want the possibility to modify these parameters. How can I save those parameters to the wall object en how can I recall them when I want to modify the object?

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Use an AttributeDictionary attached to the wall Component.

        You can attach the dictionary to either the ComponentInstance or the ComponentDefinition (or both) depending on your needs. AttributeDictionaries can be attached to any SketchUp Entity or the Model for that matter. AttributeDictionaries are saved with the model on disc.

        You use them similar to a Ruby Hash object, but they store the key/values to a SketchUp Entity. Use the #set_attribute and #get_attribute methods of Entity objects.

        Link Preview Image
        Class: Sketchup::AttributeDictionary

        The AttributeDictionary class allows you to attach arbitrary collections of attributes to a SketchUp entity.

        favicon

        SketchUp Ruby API Documentation (ruby.sketchup.com)

        Hi

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

          You should have a look at the SketchUp Team's Shapes and Window Maker example extensions. They (and a few others) use a library class called Parametric that handles creating a inputbox of parameters and saves them into an attribute dictionary attached to the (group or component) object.

          Why reinvent the wheel?

          I'm not here much anymore.

          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