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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    How to create the pulldown menu for DC

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 255 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
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement