Replacing edges by components?
-
Could be as simple as this
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection sel.empty? ? ents=ent.to_a ; ents=sel.to_a cdn = mod.definitions.reject{|cd|(cd.group?||cd.image?)}.map{|cd|cd.name} inp = UI.inputbox(["Component;"],[cdn[0]],"Edge to Component") if inp #assume that edge vector matches components z axis cd=mod.definitions[inp[0]];cl=cd.bounds.max.z ents.grep(Sketchup;;Edge).each{|e| tr1=Geom;;Transformation.scaling(1,1,e.length/cl) p,v=e.line;tr2=Geom;;Transformation.new(p,v) ent.add_instance(cd,tr2*tr1) } end
-
@sdmitch said:
Could be as simple as this.....(code above)
Thank you Sam! Almost perfect.
I "baptized" the code samuel.rb and tried it (in Plugin folder) in SketchUp 8
It starts immediately with the template when opening SketchUp, .... then uses all the basic edges and also uses the first component in the 'In Model' component list. I can't seem to be able to use the plugin afterwards on a selection with the component of choice. Where do the plugin end up, like in which menu?
How do I get it to work when using the program, not only when I start SketchUp?
Is there any way to see the available 'In Model' component options to choose from?
Also there is no 'Undo' this way?Thank you for taking the time to look at it!
-
That code was just a "snippet", not packaged as a Tool, not added to any menu or toolbar, and not installed as an extension. It just runs once as SketchUp loads it and then goes away. Needs some work to fill it out.
-
@slbaumgartner said:
That code was just a "snippet", not packaged as a Tool, not added to any menu or toolbar, and not installed as an extension. It just runs once as SketchUp loads it and then goes away. Needs some work to fill it out.
I realized that it was too simple the way I did it. But that's what Sam wrote: "Could be as simple as this"
These things aren't simple to me though.I then used AlexSchreyer's ruby code editor within SketchUp 2015 as a workaround, at least for me.
Once the code snippet is loaded it does the job on demand. Also with a redo available. So you'll just have to peek in the 'In Model' component library prior to making your choice.
I would prefere a plugin over the snippet though. Some interesting things you can achive with it, as mentioned before. -
@sdmitch said:
.... a complete plugin created from the snippet I previously posted. I gave the file the same name as you did so that it will replace the one in the plugins folder.....
I really appreciate it Sam, I just replaced the snipped rb in SketchUp 8's Plugin folder and it works as expected. Now I'll need to find where to put it in/for SketchUp 2015 where I never seem to be able to find where *.rb files are stored. My memory vaguely tells me that it isn't in the SketchUp main folder and isn't called Plugin anymore.
-
For 2014 and I'm guessing the same for 2015, the plugins are located in
"\AppData\Roaming\SketchUp\SketchUp 2014\SketchUp\Plugins" under your User Account.
In 2014 at least, the plugins folder wasn't automatically created for some reason so i had to create it.
This was a rather "quick and dirty" exercise so there will be things that need to be added or changed.
-
Post deleted.
-
@sdmitch said:
For 2014 and I'm guessing the same for 2015, the plugins are located in
"\AppData\Roaming\SketchUp\SketchUp 2014\SketchUp\Plugins" under your User Account....
Thanks, yes I found it for SU2015.
Thanks again for the script, works great.
Here is a file with examples of the horrible 3D Polylines that I was trying to get into position.
These lines do have some advantages over edges in cases where inferencing is bothering you.
Some use of short straight "one segmented" colored 3D Polylines
-
@wo3dan said:
@sdmitch said:
For 2014 and I'm guessing the same for 2015, the plugins are located in
"\AppData\Roaming\SketchUp\SketchUp 2014\SketchUp\Plugins" under your User Account....
Thanks, yes I found it for SU2015.
Thanks again for the script, works great.
Here is a file with examples of the horrible 3D Polylines that I was trying to get into position.
These lines do have some advantages over edges in cases where inferencing is bothering you.Great, I'm glad that it proved to be of some use. The version you have doesn't remove the edge and always just gives you the the first component in the definitions list. I have sent you, by Personal Message, a version that truly replaces the edge with the component as well as giving you a drop down list of all the components in the model to choose from.
-
@sdmitch said:
Great, I'm glad that it proved to be of some use. The version you have doesn't remove the edge and always just gives you the the first component in the definitions list. I have sent you, by Personal Message, a version that truly replaces the edge with the component as well as giving you a drop down list of all the components in the model to choose from.
I'll try to look into it (the new version) tonight.
Great about the drop down list of components. My memory doesn't always recall which component to type in. Now I can create dashed lines and proper centerlines (and other types), sort of a library to choose from.I may have one or two other suggestions:-
- (not always) delete the replaces edges, a choice so to speak.
- a choice whether all replacing components should be grouped or not. All 3D Polyline components into one big group (as visual reference) or not, by choice of the user.
But I'll have to see /experiment with converting floor plans, symbols etc. to see what works best.
And then I still have to rely on what you are willing to add.If anyone has suggestions or hints, please post them here..
Thank you!
Advertisement