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

    A ruby code to display dynamic component

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 1.3k 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.
    • G Offline
      glro
      last edited by

      ...options dialog box

      do you know about any?

      when a dynamic component is introduced in a sketchup model, it is autmatically selected
      it would save time to automatically open the options dialog box too...

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        you need an App Observer that starts a Model Observer that contains an Components Observer that checks for Dynamic Attributes so you can then use a Sketchup.send_action)__if one exists...

        probably easier to set a shortcut key...

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

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

          @driven said:

          you need an App Observer that starts a Model Observer that contains an Components Observer that checks for Dynamic Attributes so you can then use a Sketchup.send_action)__if one exists...

          probably easier to set a shortcut key...

          john

          thank you for trying

          there is no component observer, and there is no sketchupsendaction related to dynamic components...at least i have not find any; i did find an Entityobserver, but it doesn't help...

          a shortcut key would be fine if it was possible to embed it in a ruby code line

          1 Reply Last reply Reply Quote 0
          • D Offline
            driven
            last edited by

            to get a component, you need to use

            class MyModelObserver < Sketchup;;ModelObserver
              def onPlaceComponent(instance)
               # check it's a DC in here. then trigger the dialog with a win32 call
              end
            end
            

            but it needs so many other checks as well...

            john

            learn from the mistakes of others, you may not live long enough to make them all yourself...

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

              @driven said:

              you need an App Observer that starts a Model Observer that contains an Components Observer that checks for Dynamic Attributes so you can then use a Sketchup.send_action)__if one exists...

              probably easier to set a shortcut key...

              john

              i found a way, using autoit
              https://www.autoitscript.com/site/

              this code:

                  SendKeepActive("[CLASS;Sketchup Pro 2017]")
              
                  ; Simulate entering a string of text.
              
                      Send("{ALT}")
              		Sleep(500)
              		Send("F")
              		Sleep(500)
              		Send("{ENTER}")
              		Sleep(500)
              		Send("{O}")
              

              can be compiled with Aut2Exe, and then launched from a plugin

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

                Taking John's example cross-platform:

                
                class MyModelObserver < Sketchup;;ModelObserver
                
                  # ! If the DC extension is ever changed, this example could break !
                
                  def onPlaceComponent(instance)
                    return nil unless defined?($dc_observers)
                    # check if it's a DC in here;
                    if instance.attribute_dictionaries &&
                    instance.attribute_dictionaries['dynamic_attributes']
                      # then set Selection Tool and trigger the dialog;
                      Sketchup.active_model.select_tool(nil)
                      dc_class = $dc_observers.get_latest_class
                      if dc_class.configure_dialog_is_visible
                        dc_class.get_configure_dialog.bring_to_front
                      else
                        dc_class.show_configure_dialog
                      end
                      dc_class.refresh_configure_dialog
                    end
                  end
                
                end
                
                

                âť— This code is fragile, because it deals with someone's else's extension. They could change it (such as method names,) at any time in the future and this example will break.

                I'm not here much anymore.

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

                  i have to work to understand what you wrote, observers a re new for me

                  thank you

                  @dan rathbun said:

                  Taking John's example cross-platform:

                  
                  > class MyModelObserver < Sketchup;;ModelObserver
                  > 
                  >   # ! If the DC extension is ever changed, this example could break !
                  > 
                  >   def onPlaceComponent(instance)
                  >     return nil unless defined?($dc_observers)
                  >     # check if it's a DC in here;
                  >     if instance.attribute_dictionaries &&
                  >     instance.attribute_dictionaries['dynamic_attributes']
                  >       # then set Selection Tool and trigger the dialog;
                  >       Sketchup.active_model.select_tool(nil)
                  >       dc_class = $dc_observers.get_latest_class
                  >       if dc_class.configure_dialog_is_visible
                  >         dc_class.get_configure_dialog.bring_to_front
                  >       else
                  >         dc_class.show_configure_dialog
                  >       end
                  >       dc_class.refresh_configure_dialog
                  >     end
                  >   end
                  > 
                  > end
                  > 
                  

                  âť— This code is fragile, because it deals with someone's else's extension. They could change it (such as method names,) at any time in the future and this example will break.

                  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