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

    Revit-like Adaptive Component

    Scheduled Pinned Locked Moved Dynamic Components
    sketchup
    12 Posts 3 Posters 4.8k 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.
    • H Offline
      huajiet
      last edited by

      What do you mean by "double wrapped"?

      1 Reply Last reply Reply Quote 0
      • P Offline
        pcmoor
        last edited by

        By double wrap, I mean the contents of a component are made into another, so you end with a component containing a component. This method I believe, by passes the scale definition and the size based on the passed attribute values.

        From observation,
        -a component file when opened shows the child contents/attributes not the parent

        • a component can retain a scale factor, the steel beam examples of sketchup in the warehouse show this

        Link Preview Image
        3D Warehouse

        3D Warehouse is a website of searchable, pre-made 3D models that works seamlessly with SketchUp.

        favicon

        (3dwarehouse.sketchup.com)

        the series are built with a common 2.5" length, so after scaling a swap will update to the current scale.

        I found that the scaling failed on more complex DCs
        1m components.skp
        try component_1,and _2 swaps okay after scaling but _3 does not swap with _2 or _1 though the other way round works

        After a few different experiments I found the double wrap worked, this is advantageous as the second level can be multiple exploded or outer-shelled to leave the data component wrapper, ideal for report writing, painting...and after purge smaller file size

        in essence: simple to complex works, but without the wrap, complex to simple does not

        300x100 Beam.skp
        this is a simple beam with the geometry collected into a inner component. In this form the swaps seem to be successful both ways


        rods.skp

        1 Reply Last reply Reply Quote 0
        • H Offline
          huajiet
          last edited by

          OK, I think I follow you well enough. Yours is definitely a very intriguing solution.

          But I think I may not have explained my problem clearly.

          Suppose I need to change the length/rotation/position of one end of my Edges, I have to:

          1. redraw the Edge
          2. redefine the axis for my Edge group
          3. re-Swap the complex component

          This is very similar to what I can do with the Align plugin by D.Bur.

          Instead, what I'm looking to do is to have the member re-size and re-orient itself in reference to the position between the 2 nodes (which can be calculated using basic Trigonometry). Seems to me that this should be within the capability of the Dynamic Component System, or am I wrong?

          1 Reply Last reply Reply Quote 0
          • P Offline
            pcmoor
            last edited by

            Profile Builder could be the answer, it allows one to switch to a line path, edit this and the profile will follow the new path.

            1 Reply Last reply Reply Quote 0
            • P Offline
              pcmoor
              last edited by

              I have just discovered ThomThom "rotate and scale" (extension warehouse) which will move the objects to the desired position. Though you do require a redraw of the component after the move.

              1 Reply Last reply Reply Quote 0
              • P Offline
                pcmoor
                last edited by

                There is a problem with using the rotate and scale tool in that the DC is rotated as well.
                I believe the solution is to create or modify a ruby script. That is to go back to the line idea, and build a tool that draws a dynamic component line

                http://www.sketchup.com/intl/en/developer/

                from examples
                http://www.sketchup.com/intl/en/developer/docs/examples

                use the linetool.rb

                idea: check out how it works and modify to suit

                1 Reply Last reply Reply Quote 0
                • H Offline
                  huajiet
                  last edited by

                  Thanks PCMoor!

                  All the plugins you've recommended were very useful. I guess I just have to accept that I may not get all the functionality I want in a single plugin - until and unless I learn to script it myself.

                  1 Reply Last reply Reply Quote 0
                  • P Offline
                    pcmoor
                    last edited by

                    True, but we can hack at the problem given that the ruby script example allows

                    "Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted....provided that the above copyright notice appear in all"
                    Hi
                    I recommend that (if you haven't already) download Alex Schreyer: Ruby Code Editor
                    http://sketchucation.com/pluginstore?pln=as_rubyeditor

                    open it and checkout its features..

                    now to find the path to the plugin folder...
                    something like C:\Users\PHILIP\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Plugins (it may pay to set a short cut to this)

                    So assuming you have down loaded the su_examples
                    So using the ruby editor...looking at the linetool example, it would seem pointless or impossible at this stage to completely understand all of whats going on, and I must admit I'm fairly new to this.
                    the # bits (grey) are comments, there is a lot about the mouse control, but I skip that.. no point reinventing the wheel.. but hello this is actually two tools...the second,cylinders that inherit functions from the first line tool..we can build our tool(s) on this. Most of the work already done

                    But first you probably notice how darn hard it is to run this script. We need to borrow a bit of code say from the box.rb and overwrite the linetool.rb to have easy access.

                    Close linetool.rb and open boxtool.rb
                    what makes it visible?..looking for key words...load...menu?

                    the section below

                    if( not file_loaded?("su_examples/box.rb") )

                    # This will add a separator to the menu, but only once
                    #Note: We don't translate the Menu names - the Ruby API assumes you are 
                    #using English names for Menus.
                    %(#0000BF)[add_separator_to_menu("Draw")]
                    
                    # To add an item to a menu, you identify the menu, and then
                    # provide a title to display and a block to execute.  In this case,
                    # the block just calls the create_box function
                    %(#0000BF)[UI.menu("Draw").add_item($exStrings.GetString("Box")) { create_box }]
                    

                    end


                    can be copied and pasted into linetool.rb and change box in the two statements plus the menu text line to something descriptive

                    if( not file_loaded?("su_examples/linetool.rb") )
                    add_separator_to_menu("Draw")
                    UI.menu("Draw").add_item($exStrings.GetString("construct line")) { linetool }

                    same for the cylinder

                    add_separator_to_menu("Draw")
                    UI.menu("Draw").add_item($exStrings.GetString("%(#FF0000)[pipe line]")) { %(#FF0000)[cylindertool] }
                    

                    end

                    you can run it to check
                    then if okay save to an appropriate folder

                    Now you need to close Sketchup and overwrite the existing with this one (perhaps saving a copy if you need to return to a previous version)

                    I found by overwriting, I am able to have the menu items appear when Sketchup opens
                    So with menu items we can now create some keyboard shortcuts, (window/preferences/shortcuts) say shift L, for the constuct line, and shift P, for the pipe

                    hopefully all works
                    any comments or code corrections,ideas welcome

                    so ends this part

                    1 Reply Last reply Reply Quote 0
                    • pilouP Offline
                      pilou
                      last edited by

                      If you want see cool plugins made with only "Dynamic Components"! 😎

                      Click-Kitchen for Sketchup! A tricky use of Dynamic Components!

                      It's a tricky one who re-takes the Ikea models! (or your own)
                      Free and Pro Version (15$)

                      Numerous tutorials!

                      Made by a French guy friend of me! (Site English / French)
                      Have fun kitchen building! πŸ˜‰

                      Some numerous free Textures for apply inside the plugin (or for any Sketchup Models)

                      This another one is free! Click-Change

                      Frenchy Pilou
                      Is beautiful that please without concept!
                      My Little site :)

                      1 Reply Last reply Reply Quote 0
                      • P Offline
                        pcmoor
                        last edited by

                        Hi

                        It is possible to create components with ruby code, but i believe its much easier to use the ruby code to load a defined component and position it,

                        I will continue with the pipe line DC, I created earlier and develop that.

                        If you look at the cylinder code in the linetool example,

                        %(#000080)[vec = pt2 - pt1
                        length = vec.length
                        if( length == 0.0 )
                        UI.beep
                        puts "Cannot create a zero length cylinder"
                        return
                        end]

                        I used that as the starting point, initially changing the cylinder for a simple line.

                        I now need to load a component and scale, then rotate it to the line created.

                        %(#0000BF)[path = Sketchup.find_support_file('rod.skp', 'Plugins/su_examples/')
                        definitions = Sketchup.active_model.definitions
                        definition = definitions.load(path)]

                        to get a scaling factor I saved the pipe line DC with a length of 1 meter and used that to scale to the length of the line. I loaded that DC to the su_examples folder

                        http://ruby-doc.org/core-2.2.0/Math.html
                        gives the syntax for the maths

                        being a roof carpenter, I used my knowledge of the relationship between a rafter and a hip (bevel cuts, lengths) to create a transformation sequence for the rotation
                        searches in this forum helped to work out the method

                        then I deactivated the line as it was no longer required as a reference

                        added
                        dc_observers.get_latest_class.redraw_with_undo(componentinstance)
                        to redraw the scaled component (tig)

                        I have attached the amended rod.skp and linetool.rb, which can overwrite the existing in the C:\Users"computer name"\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Plugins\su_examples


                        links


                        the base component


                        linetool.rb

                        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