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!
    โš ๏ธ Update | Sketchucation Tools 5.0.8 released with licensing improvements and bugfixes Download

    Dynamic Component Redraw

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 8 Posters 5.0k Views 8 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.
    • J
      JonD
      last edited by

      Is there an observer to catch the 'event' when a user applies a change to a dynamic component that causes it to redraw? I need to beable to force a redraw of another dynamic component if a change happens to another. I thought I saw something on a dynamic component observer, but I cannot find any documentation on it...

      Thanks,
      Jon

      1 Reply Last reply
      Reply Quote 0
      • B
        bsnantes
        last edited by

        I have the same need. Did you find any solutions ?

        1 Reply Last reply
        Reply Quote 0
        • J
          JonD
          last edited by

          Nothing yet...

          1 Reply Last reply
          Reply Quote 0
          • Chris FullmerC
            Chris Fullmer
            last edited by

            well supposedly the refresh method will force a redraw. Did you try that method? It might need to be implemented inside of a tool class. Did you look into that method?

            Chris

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply
            Reply Quote 0
            • thomthomT
              thomthom
              last edited by

              @chris fullmer said:

              well supposedly the refresh method will force a redraw. Did you try that method? It might need to be implemented inside of a tool class. Did you look into that method?

              Chris

              He need the refresh method and an event callback...

              Thomas Thomassen โ€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

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

                I think it should be possible. The operation of DC's are not documented, but this blog post might contain some useful examples.

                Error 404 (Not Found)!!1

                favicon

                (sketchupapi.blogspot.com)

                Hi

                1 Reply Last reply
                Reply Quote 0
                • scottliningerS
                  scottlininger
                  last edited by

                  Hey guys,

                  There is no observer for DC redraw. I did think of a trick you could try, however.

                  The "functions" that can be called as part of a DC formula are defined in a class called DCFunctionsV1. Any protected methods inside that class are discovered by the DC plugin by reflection and can be called inside a DC spreadsheet formula. Since every formula is run each time a DC is redrawn, you can call your own ruby code this way.

                  For example, let's make a new DC spreadsheet function that shows a messagebox:

                  1. Save this script as customDCFunctions.rb into your plugins directory.
                  # Adds custom DC spreadsheet functions.
                  class DCFunctionsV1
                    
                    protected
                    
                    # Shows a messagebox from DC formula.
                    # Example Formula; =messagebox("something")
                    def messagebox(param_array)
                      val = param_array[0]
                      UI.messagebox(val.to_s)
                      return val
                    end
                  
                    # Returns first thing, alphabetically, in list of params.
                    # Example Formula; =firstAlpha("bob", "cal", "amy", "dan")
                    def firstalpha(param_array)
                      return param_array.sort.first
                    end
                  
                  end
                  
                  1. Restart SU, and create a new DC. Add a custom attribute called "onredraw" (or whatever you want) with the following formula:
                  =messagebox("Hello")
                  

                  Whenever that DC is redrawn (manipulate it with the scale tool, for example), you'll see your messagebox. You could just as easily call some more complex code. People who have your script installed will get the behavior you want. People without it won't, of course, so you'd need to be careful about that.

                  Hope that gets you started. ๐Ÿ˜„

                  • Scott Lininger
                    SketchUp Software Engineer
                    Have you visited the Ruby API Docs?
                  1 Reply Last reply
                  Reply Quote 0
                  • J
                    JonD
                    last edited by

                    Many thanks Scott, Thom and Chris. I will give this a try when I get back to the workstation.

                    1 Reply Last reply
                    Reply Quote 0
                    • J
                      JBPM
                      last edited by

                      @ScottLiningerย 
                      ย 
                      Hi!
                      You code is interesting. (customDCFunctions.rb)
                      I try it but I got a error message when I open SU

                      @unknownuser said:

                      Error Loading File CustomDCFunctions.rb
                      Error: #<SyntaxError: C:/Users/Design6/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/CustomDCFunctions.rb:11: void value expression
                      C:/Users/Design6/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/CustomDCFunctions.rb:17: void value expression>

                      Do you have a clue, why?

                      Thank you

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

                        Scott Lininger left Trimble/SketchUp several years ago to start his own company. (He is unlikely to see or reply to your question. Ie, this topic thread is at least 7 years old!)

                        There are more recent threads on making custom DC functions (but you should not publish any custom changes.)

                        See this thread:
                        http://sketchucation.com/forums/viewtopic.php?f=180&t=67235

                        I'm not here much anymore.

                        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