• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Possible to import DC attribute values?

Scheduled Pinned Locked Moved Dynamic Components
sketchup
7 Posts 4 Posters 9.1k Views
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.
  • M Offline
    marksolberg
    last edited by 24 Nov 2008, 23:25

    If I have a DC with a custom identifier attribute like ProductNum is it possible to import and set a different attribute, say LenZ based upon an external file? Basically I would like to use Sketchup to visualize performance data. An example file might be something like:
    A34 3.5
    B22 9
    B33 7

    Perhaps with a custom Ruby script?

    Thanks,
    Mark

    1 Reply Last reply Reply Quote 0
    • C Offline
      chrisglasier
      last edited by 24 Nov 2008, 23:40

      @marksolberg said:

      ... Basically I would like to use Sketchup to visualize performance data.

      Anything useful here:

      http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=14299 ?

      or on my web site (click button on left). I am interested in the versatility of import/export with webdialogs, so please let me know what you think.

      Chris

      edit: corrected link

      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

      1 Reply Last reply Reply Quote 0
      • C Offline
        chrisglasier
        last edited by 25 Nov 2008, 00:05

        Correct link is this:
        http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=14299

        Sorry

        Chris

        With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

        1 Reply Last reply Reply Quote 0
        • M Offline
          marksolberg
          last edited by 25 Nov 2008, 02:31

          Chris,
          I couldn't get the video to play in the linked topic. I don't know that it would matter though. I think this is beyond my knowledge. I didn't make it past the first paragraph before I got that look a dog gets when they hear an unfamiliar sound. Thanks just the same.

          Mark

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by 25 Nov 2008, 02:35

            @marksolberg said:

            If I have a DC with a custom identifier attribute like ProductNum is it possible to import and set a different attribute, say LenZ based upon an external file? Basically I would like to use Sketchup to visualize performance data. An example file might be something like:
            A34 3.5
            B22 9
            B33 7

            Perhaps with a custom Ruby script?

            Thanks,
            Mark

            Welcome Mark,

            It is possible, and actually not terribly hard to write a Ruby script to set some attributes from a file. It's a little late for me, but perhaps someone will pick this up in the morning.

            Also, Scott Lininger has posted some good information on the subject, which I will quote here:

            @unknownuser said:

            Hey folks,

            My name is Scott, and I'm one of the developers for DCs. I'll be
            floating around the groups from now on to help with all things Ruby or
            DC related. Hiya! First, let me say that we intend to provide more
            docs and examples of using your own Ruby scripts alongside DCs, but
            they are still under development, so I'll attempt to address specific
            questions as they come up.

            bveina has figured it out most of the way: DCs are implemented purely
            in Ruby, and all of the attributes that you can apply via the
            Component Attributes window can also be applied directly with script.
            There is a dictionary called "dynamic_attributes" that gets attached
            to both the Instance and the Definition, and this contains the
            attributes that drive DC behaviors.

            There are two kinds of attributes in these dictionaries: those that
            start with an underscore are "internal" attributes that do not show up
            in the Component Attributes window. Those that begin with anything
            else are the "visible" attributes. Here's an example of some
            attributes one might find in our dictionary (http://code.google.com/p/
            sketchupattributemanager/wiki/Welcome is a place where one can get a
            tool to view these attributes, and inspecting existing DCs is the best
            way to start to understand how everything is stored.)

            x=55
            _x_formula="5*11"
            _x_label="x"

            As bveina's script shows, there's nothing particularly secret or
            magical about setting these attributes. But how does one fire a
            redraw? First, there is an instance of the dc observers mechanism,
            which lives in this global variable:

            $dc_observers

            This object is, as its name suggests, essentially a collection of
            observers that watches for DC interactions, such as the scale tool,
            move tool, or component placement. Anyway, here's a code snippet that
            applies a color to Sang then redraws him (this assumes it's running in
            a template with Sang already in it):

            sang_instance = Sketchup.active_model.entities[0]
            sang_definition = sang_instance.definition
            ad = sang_definition.attribute_dictionary "dynamic_attributes"
            ad["_material_formula"] = '"Red"'
            $dc_observers.get_latest_class.redraw_with_undo(sang_instance)

            The only reason that we have to set the "_material_formula" instead of
            just the "material" is because Sang happens to contain formula
            already, so just replacing the material and then firing a redraw will
            result in the old formula overwriting your new value. (Formulas always
            get recalculated with a redraw, and their result is stored into the
            attribute.)

            Whew! How's that for a 10-minute intro. 😉

            As I say, all of this will be better documented soon, but that's no
            reason to keep you from diving in! DCs are "just another Ruby script,"
            after all.

            Cheers,

            Scott Lininger
            Sketchup Software Engineer

            (source)

            Hi

            1 Reply Last reply Reply Quote 0
            • M Offline
              marksolberg
              last edited by 25 Nov 2008, 03:07

              Thanks Chris,
              The info in your last post seems to be the type of info I'm looking for. I'll post this in a separate forum also, but do you have any recommendations as to where to start learning Ruby programming for Sketchup? About a hundred years ago I went to college for programming (pre-WWW days) but somehow ended up in the casino industry in a non-programming capacity. Wish I would have stayed with programming, I've always enjoyed it.

              Mark

              1 Reply Last reply Reply Quote 0
              • W Offline
                Witention Newcomers
                last edited by 1 Dec 2022, 00:56

                @marksolberg said:

                Thanks Chris,
                The info in your last post seems to be the type of info I'm looking for. I'll post this in a separate forum also, but do you have any recommendations as to where to start learning Ruby programming for Sketchup? About a hundred years ago I went to college for programming (pre-WWW days) but somehow ended up in the casino industry in a non-programming capacity. Wish I would have stayed with programming, I've always enjoyed it.

                Mark

                Good day. I have always liked the field of programming, I reported a lot of efforts to become a programmer, now I am programming in C ++. As for the casino theme, I like this business, I like to hang out in my free time https://forestcasinos.co.nz/casino-zodiac/. It helps me recover and relax from a hard day's work.

                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