• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

How to create the pulldown menu for DC

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 2 Posters 212 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 16 Feb 2014, 10:56

    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 16 Feb 2014, 12:41

      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 16 Feb 2014, 14:30

        @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 16 Feb 2014, 15:14

          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 16 Feb 2014, 16:10

            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 16 Feb 2014, 16:19

              @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
              1 / 1
              • First post
                1/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement