Revit-like Adaptive Component
-
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, takeoff...you can swap again with same or another. The steel beam can be simplified by this outershell and explode method
-
What do you mean by "double wrapped"?
-
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
https://3dwarehouse.sketchup.com/collection.html?id=ua9c5089a-a2f2-4ef5-913d-b0ea38615784
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 worksAfter 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
-
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:
- redraw the Edge
- redefine the axis for my Edge group
- 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?
-
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.
-
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.
-
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 linehttp://www.sketchup.com/intl/en/developer/
from examples
http://www.sketchup.com/intl/en/developer/docs/examplesuse the linetool.rb
idea: check out how it works and modify to suit
-
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.
-
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_rubyeditoropen 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 doneBut 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 folderNow 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 pipehopefully all works
any comments or code corrections,ideas welcomeso ends this part
-
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$)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)
http://www.youtube.com/watch?v=lxovS8smhGE
This another one is free! Click-Change
-
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 mathsbeing 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 methodthen 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
Advertisement