Revit-like Adaptive Component

Revit-like Adaptive Component

Postby huajiet » Sun Jan 03, 2016 4:12 am

Hi Sketchucation,

I'm trying to create a Dynamic Component that will create a tubular member between 2 arbitrary points - very much like what Revit can do with its Adaptive Points.

I've attached what I've managed to come up with so far. Problem is: while the RotX/Y/Z parameters work well enough on their own axes, when they are run together, they seem to lose that accuracy.

Ideally, with the final product, you should be able to simply place the node and have the tube adapt its rotation and length accordingly.

Anyone can help me with this? Any feedback is appreciated.

First time making a DC


Re: Revit-like Adaptive Component

Postby pcmoor » Mon Jan 04, 2016 7:42 am

the insertion point and direction of a component is determined by its axis position and direction, and probably the only thing it has in common with a Revit adaptive component. There is only one insertion point, however the Dynamic component can react to scaling and movement depending on the conditions applied in its attributes.

you could create a rod centered at the insertion point, initially with direction in all planes, then use the scale tool to modify its length / direction

I would suggest a different work flow
importantly components can be swapped, but to bypass the set size, one must use a double wrapped component and expose some or all its size attributes.

For example a line can be changed to a component with an axis placement, then later swapped with a complex component.The complex component must be wrapped and refer to a current value, in this case current("LenY") {*2.54 if metric }

So draw some raw line geometry that represents a frame, select a line, type G, press "set component axis" on the dialog, place new axis at an end, rotate until get perpendicular, click and set the y axis along the length of the line. Make sure "Replace selection with component" is clicked and create. Now open attributes and click size(add all). Now this line component can be swapped with a component with scale-able LenY.

Attached is a steel beam component which you can swap (once saved to a folder) with the line you created. This component is the one enclosed within another, double wrapped with attributes passed to the child.

Further swaps can be made with components of a similar design (or family to use a Revit term) you can outershell or explode the inner parts of a complex component to form raw geometry, hence easier to edit, paint, can swap again with same or another. The steel beam can be simplified by this outershell and explode method


Re: Revit-like Adaptive Component

Postby huajiet » Mon Jan 04, 2016 6:30 pm

What do you mean by "double wrapped"?


Re: Revit-like Adaptive Component

Postby pcmoor » Tue Jan 05, 2016 9:57 am

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 ... ea38615784

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


Re: Revit-like Adaptive Component

Postby huajiet » Wed Jan 06, 2016 11:07 am

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?


Re: Revit-like Adaptive Component

Postby pcmoor » Wed Jan 06, 2016 12:51 pm

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.


Re: Revit-like Adaptive Component

Postby pcmoor » Fri Jan 08, 2016 12:13 am

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.


Re: Revit-like Adaptive Component

Postby pcmoor » Mon Jan 11, 2016 2:11 am

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

from examples

use the linetool.rb

idea: check out how it works and modify to suit


Re: Revit-like Adaptive Component

Postby huajiet » Wed Jan 13, 2016 8:41 am

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.


Re: Revit-like Adaptive Component

Postby pcmoor » Wed Jan 13, 2016 12:52 pm

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"
I recommend that (if you haven't already) download Alex Schreyer: Ruby Code Editor

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

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.

# 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"Draw").add_item($exStrings.GetString("Box")) { create_box }


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")"Draw").add_item($exStrings.GetString("construct line")) { linetool }

# same for the cylinder

add_separator_to_menu("Draw")"Draw").add_item($exStrings.GetString("pipe line")) { cylindertool }


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


Re: Revit-like Adaptive Component

Postby pcmoor » Mon Jan 18, 2016 12:13 pm


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,

vec = pt2 - pt1
length = vec.length
if( length == 0.0 )
puts "Cannot create a zero length cylinder"

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.

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
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

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
Last edited by pcmoor on Thu Jan 21, 2016 7:09 am, edited 1 time in total.


Re: Revit-like Adaptive Component

Postby pilou » Mon Jan 18, 2016 12:44 pm

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

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!
Speedy Galerie
User avatar
Top SketchUcator

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Ad Machine 


Return to Dynamic Components

Who is online

Users browsing this forum: No registered users and 3 guests

Visit our sponsors: