sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🚨 Skimp | 25% Off until March 30 Buy Now

    How to create the pulldown menu for DC

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 370 Views 2 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.
    • G Offline
      goga63
      last edited by

      Hi !
      I learn to write scripts for Sketchup, вut has rested against a wall...
      I can set attributes of components this code:

      entity.set_attribute 'dynamic_attributes','price', '0'
      entity.set_attribute 'dynamic_attributes','_price_label', 'price'
      entity.set_attribute 'dynamic_attributes','_price_formlabel', 'Price'
      entity.set_attribute 'dynamic_attributes','_price_units', 'STRING' entity.set_attribute 'dynamic_attributes','_price_access', 'TEXTBOX'
      

      It works!
      But I could never understand how to write code using meta attributes to create the pulldown menu for DC ...
      Show me a code fragment which it does.
      Thanks !

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

        You know where the DC Attributes are stored, so now you can inspect the "dynamic_attributes" Dictionary to see how to recreate any DC you find.

        Here is a basic example of a dropdown list with 3 options:

        http://i.imgur.com/mKVm8qT.png

        Hi

        1 Reply Last reply Reply Quote 0
        • G Offline
          goga63
          last edited by

          @jim said:

          You know where the DC Attributes are stored, so now you can inspect the "dynamic_attributes" Dictionary to see how to recreate any DC you find.

          Here is a basic example of a dropdown list with 3 options:

          Code:

          sang = Sketchup.active_model.entities[0]
              sang_def = sang.definition
          
              sang_def.set_attribute 'dynamic_attributes','test', 'yes'
              sang_def.set_attribute 'dynamic_attributes','_test_access', 'LIST'
              sang_def.set_attribute 'dynamic_attributes','_test_formlabel', 'My test'
              sang_def.set_attribute 'dynamic_attributes','_test_label', 'my_test'
              sang_def.set_attribute 'dynamic_attributes','_test_options ','&yes=yes&no=no'
              sang_def.set_attribute 'dynamic_attributes','_test_units', 'STRING'
          

          Result on the image
          What do I do not so?


          menu.jpg

          1 Reply Last reply Reply Quote 0
          • G Offline
            goga63
            last edited by

            I have found a problem!
            It was necessary to use a symbol " instead of ' .

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

              You have an extra space in this line:

              ang_def.set_attribute 'dynamic_attributes','_test_options[highlight=#ff0000:2ph6o4z3]_[/highlight:2ph6o4z3]','&yes=yes&no=no'

              Hi

              1 Reply Last reply Reply Quote 0
              • G Offline
                goga63
                last edited by

                @jim said:

                You have an extra space in this line:

                ang_def.set_attribute 'dynamic_attributes','_test_options[highlight=#ff0000:169f3gnp]_[/highlight:169f3gnp]','&yes=yes&no=no'

                Yes, thanks!
                All has earned.

                1 Reply Last reply Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement