Array to or from objects
-
Hello,
I would like to know if its possible to have an object draw lines from itself to many other objects or conversely is it possbile to have various objects draw lines from themselves to a single selected object?
Right now I have 247 objects and would like this process repeated with each object. So for instance say i had four, I would want to take object 1 and have it array lines from itself to objects 2,3 and 4. I would like to then go on to repeat this process for each object so take object 2 and array lines to objects 1,3 and 4 and so on.
Is there any way to do this at all in sketchup? If anyone has seen this function in another programme I would be equally interested.
thanks all,
ninehundred
-
If the surrounding objects are instance of a single component arrayed radially around the central object, you could draw all those lines at once by making them part of the component.
-
What is the nature of these 'objects'?
If they are single lines or groups/component-instances etc then here's a way
One way is to preselect them all, and then run this one-liner.m=Sketchup.active_model;g=m.active_entities.add_group();e=g.entities;a=m.selection.to_a;m.start_operation('x');a.dup.each{|o|a.shift;a.each{|i|e.add_line(o.bounds.min, i.bounds.min)}};m.commit_operation
Copy paste into the Ruby Console+<enter>...
This adds the new edges [bb.min to bb.min] to a group - explode if if that's not what's wanted... It is one step undo-able. You can of course filter it to only work on certain sorts of objects, or filter you selection beforehand... At the moment all of the edges go into one group but you could create groups for each set in turn thus:m=Sketchup.active_model;a=m.selection.to_a;m.start_operation('x');a.dup.each{|o|;g=m.active_entities.add_group();e=g.entities;(a-[o]).each{|i|e.add_line(o.bounds.min, i.bounds.min)}};m.commit_operation
Which is probably more useful
-
Thank you so much for your reply, Im afraid im a bit of a novice when it comes to the ruby console so ive not been able to get it to work on my first go. ill tell you exactly what ive done. ive opened sketchup, made my 'components' (which are 2d circles) into actual components (using G). then ive opened up the ruby console and put in the second code. after i put the code in i changed every instance of '.min' to '.center' and then pushed enter. nothing has happened im afraid when i do this. what am i doing wrong?
-
It works on a selection so you need to select some objects before running the code.
Incidentally, I recommend that you do use a component for the marker, otherwise a raw geometry circle will have many 'parts' [face+all_edges] that with each return a 'center' !
Were there no messages in the Console?
It probably said 'true' when it immediately finished processing the empty selection !Try as I say and report what happens... It works for me.
here's the line with the 2 'center' methods added...m=Sketchup.active_model;a=m.selection.to_a;m.start_operation('x');a.dup.each{|o|;g=m.active_entities.add_group();e=g.entities;(a-[o]).each{|i|e.add_line(o.bounds.center, i.bounds.center)}};m.commit_operation
Advertisement