sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Storing File Specific Attributes

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

      I'm fairly well versed in storing attributes for various entities (groups, components etc...) but I would now like to store some attributes that are "file" or "model" specific. These are some global settings that will apply to the model that is opened up in SketchUp. I am wondering if there is a preferred way of doing this and any pitfalls to look out for.

      Nathaniel P. Wilkerson PE
      Medeek Engineering Inc
      design.medeek.com

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

        Assuming that...
        model = Sketchup.active_model
        To set a key/value...
        model.set_attribute("Some_Dict_Name", "Some_Key", value)
        To get a key/value...
        model.get_attribute("Some_Dict_Name", "Some_Key", default_value)
        If you don't pass a default_value and its "Some_Key" has not been set you get back ' nil'.
        The ' value' can be one of several types...
        boolean nil/false/true
        integer 1, 0, -1
        float 1.0, 0.0, -1.0
        string "cat", "or dog"
        array [true, 1, 2.345, "doh", [1,2,3]] (i.e. it can include any of the other 'types')

        TIG

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

          "Some_Dict_Name" needs to be "Medeek_SomePluginName" at a minimum, and can be expanded even more, like: "Medeek_SomePluginName_Purpose" if "SomePluginName" will have more than one dictionary, each used for different purposes.

          Or you can nest dictionaries inside another dictionary. So you can have one toplevel company dictionary for all your plugins, called "Medeek" (or whatever) and create child dictionaries for whatever plugins that need them. Those child dictionaries could have grandchild dictionaries.

          But it is most important to know that you must separate your dictionaries from those of other authors. (It is up to you how to separate your various plugin dictionaries.)

          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