sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    DC "Flipping" Script

    Scheduled Pinned Locked Moved Plugins
    19 Posts 2 Posters 1.3k 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.
    • E Offline
      ericschimel
      last edited by

      At Basecamp, I attended Scott's Dynamic Component discussion. One of the frustrations expressed for people that create dynamic components was the ability to "flip" them.

      Here is the nature of the problem:

      Lets say you draw a door that you want glued to a wall, but you draw that door as it would in installed, vertically. You then spend hours figuring out all of your formulas, only to realize that when you set your component to glue to a surface, it is the wrong way. Normally, with a dumb component, you can just flip the axis and you're all set. With a DC, if you do that, you blow it up because all the formulas reference off of the axis.

      Apparently, one could write a script to "flip" a DC automagically, however its above my head. This script could be useful for not only fixing mistakes, but for the DC's I build, it would allow me to create DC's for different situations.

      Anyone feeling up to the challenge? (Chris, Thomthim, Whaaat, are you listenting? πŸ˜„ )

      -Eric
      http://plugin.sketchthis.net
      Sketchup Kitchen Design Plugin
      Custom Models

      1 Reply Last reply Reply Quote 0
      • E Offline
        ericschimel
        last edited by

        Maybe this post would be more at home in the Dynamic Components sub forum?

        -Eric
        http://plugin.sketchthis.net
        Sketchup Kitchen Design Plugin
        Custom Models

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

          Did Scott outline what a script would need to do?
          I'm not all that familiar with DC - especially the scripting communication of it - I'm not immediately aware of what problems and issues there are.

          What exactly happens when a DC "blows up"?

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

          1 Reply Last reply Reply Quote 0
          • E Offline
            ericschimel
            last edited by

            Ok, let me see if I can explain this a little better.

            You have a Dynamic component. So lets say you drew a wall cabinet that you want glued to just vertical surfaces (walls). To get the gluing to work correctly, you have to draw your DC on the ground plane, face up. So for a wall cabinet component to glue itself to a vertical surface, and be facing the right way, its Z, or blue axis has to be the "depth" of the wall cabinet.

            So far, this is really easy to do. But, DC's are more complicated. You have the main component (the Wall cabinet) and then a ton of sub components. Things like doors, sides, backs, face frames, etc. All of these components reference off of the axis of the main component.

            So lets say that I want to take this wall cabinet, and turn it into a base cabinet, because I have spent hours and hours building a wall cabinet. To do this, I need to glue to the floor. Since currently this wall cabinet has its vertical, or blue axis set as the "depth" of the cabinet, when I place it on the floor, it sits on the floor, face up, which is no good. The only way to fix this is to change the axis of the component so that the Z, or blue axis is vertical, or the "height" of the cabinet, rather then the depth. This is all good on "dumb" components, but since every sub component relies on referencing information on the size of the main component, it "blows up" when you change the axis.

            The only way to fix this you have to manually swap the formulas in every sub component over and over again. Its really, really tedious, and usually results in errors. What Scott was saying at Basecamp is that its totally possible with the API to create some sort of script that can take a DC, as the user where they want the axis, and "flip" all the formulas that would need to be changed in order to make the DC work again.

            Does that make sense?

            -Eric
            http://plugin.sketchthis.net
            Sketchup Kitchen Design Plugin
            Custom Models

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

              Can you give an example of an formula? Before and after?

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

              1 Reply Last reply Reply Quote 0
              • E Offline
                ericschimel
                last edited by

                Ok, so here's a fairly basic DC. If I change the axis of the DC, it "blows up" because all of the formula's are referencing an axis that has changed.

                Pull this into your model, and use it to see how it works. Then, right click on it, and change the orientation of the axis and then try to use it again, you'll see what happens.


                E2000 Left Mitre.skp

                -Eric
                http://plugin.sketchthis.net
                Sketchup Kitchen Design Plugin
                Custom Models

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

                  Will look at it.
                  (Sorry - been a wee bit busy)

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

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

                    hmm.. are we talking about just flipping, or adjusting axis completely?
                    Is it swapping X for Y or Z etc?

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

                    1 Reply Last reply Reply Quote 0
                    • E Offline
                      ericschimel
                      last edited by

                      Lets say you took the above DC and rotate the axis about the Blue axis. In other words, you switched the direction of the green and red axis, leaving the blue one in the same direction. For the DC not to "Blow up" you'd need to switch every Red axis formula with Green axis references and vica versa, leaving the blue ones alone.

                      Doing this manually is really tedious and dangerous, even on a simple DC such as this one.

                      -Eric
                      http://plugin.sketchthis.net
                      Sketchup Kitchen Design Plugin
                      Custom Models

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

                        Ok - that's an easier scope. Arbitrary change of the axis would appear awfully complex. Even flipping, mirroring appear to be a bit of a problem. But axis swapping should be doable without too much fuzz. (famous last words...?)

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

                        1 Reply Last reply Reply Quote 0
                        • E Offline
                          ericschimel
                          last edited by

                          Ok, I am seeing what you are thinking. Flipping would be awesome, because then, like I said, I could change the gluing plane of DC's without having to rebuild them.

                          Later on, something that would mirror DC's would be killer, but that's a lot of math to wrap your brain around! (and how do you change small sections of formulas, instead of just swapping them around?)

                          -Eric
                          http://plugin.sketchthis.net
                          Sketchup Kitchen Design Plugin
                          Custom Models

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

                            @unknownuser said:

                            (and how do you change small sections of formulas, instead of just swapping them around?)

                            That'd be the key problem. To interpret forums. Just seem all too complex.

                            But let's have a look at swapping axis orientation.

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

                            1 Reply Last reply Reply Quote 0
                            • E Offline
                              ericschimel
                              last edited by

                              That would be really cool if axes could be rotated....

                              As far as changing snippets of formulas, is it impossible with the API, or just really friggin hard?

                              -Eric
                              http://plugin.sketchthis.net
                              Sketchup Kitchen Design Plugin
                              Custom Models

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

                                @unknownuser said:

                                As far as changing snippets of formulas, is it impossible with the API, or just really friggin hard?

                                It's easy if you know what to change. But the formula is basically source code and they can appear in so many mutations, you'd have to make the script be able to understand what the formula do, its intention.

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

                                1 Reply Last reply Reply Quote 0
                                • E Offline
                                  ericschimel
                                  last edited by

                                  Ahh ok, but a script that would say go through a change all the "LenX" references to "LenY" references would be fairly easy?

                                  -Eric
                                  http://plugin.sketchthis.net
                                  Sketchup Kitchen Design Plugin
                                  Custom Models

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

                                    Yea - much easier.
                                    But, what about sub-components? If you have multiple depths with components?

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

                                    1 Reply Last reply Reply Quote 0
                                    • E Offline
                                      ericschimel
                                      last edited by

                                      Oh yeah, there are always sub components, that's what makes this so hard to do. If I was just changing top level stuff, the script wouldn't be needed.

                                      -Eric
                                      http://plugin.sketchthis.net
                                      Sketchup Kitchen Design Plugin
                                      Custom Models

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

                                        Yea, but a the sub-components could themselves be DC's - would one have to flip the axis of these as well? Or would things work find if one only processed the first level of sub-components?

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

                                        1 Reply Last reply Reply Quote 0
                                        • E Offline
                                          ericschimel
                                          last edited by

                                          As far as sub components, it would be any sub components that reference the axis of the most top level component. And sub component that references an axis from another sub component that is below the top level wouldn't need to be changed.

                                          -Eric
                                          http://plugin.sketchthis.net
                                          Sketchup Kitchen Design Plugin
                                          Custom Models

                                          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