Copy tool --> no preview
-
Hello everyone,
I know is useless because this tools already exist but I have created a plugin which copy a component and paste that copy every where you click on your design but I don't know how to have preview before putting the component on the design.
- You select the component
- launch the plugin
- click where you want to put the copy of the component (ex : a mailbox)
- push "space" bar to quit the component
The benefit of this plugin is you don't have to press "CTRL" or reselect the component you want to copy.
Original tool with the preview before putting the component
My tool :
Tool activate, before clickingafter clicking on design
But I cannot have the preview like the original plugin. Without this, the accuracy is bad...
Someone can tell me how to add this preview ? -
https://developers.google.com/sketchup/docs/ourdoc/model#place_component
model.place_component(component_definition, true)
-
Here is another way which can copy multiple objects (be they components, groups, primitives, or any combination of them.)
1) Select the component, or the selection contains anything(s) you wish to copy.
2)
Sketchup.send_action("copy:")
3)
Sketchup.send_action("paste:")
User presses ESC to unselect the copied things. (But the MoveTool is still active afterward.)
You can clear the selection viaSketchup.active_model.selection.clear()
and then reset the original selection if you have first saved it to an array.All this can be done with the Edit menu options, or the Copy and Paste buttons from the Standard toolbar, or CTRL+C/CTRL+V shortcuts.
-
@tig said:
https://developers.google.com/sketchup/docs/ourdoc/model#place_component
model.place_component(component_definition, true)
I LOVE YOU !!!
It works great !!!!!!!!!!!!!!!
Since monday, I try to find the solution on the observer but it didn't work ... lolJust for my personnal culture, what is the observer ? how do you use that ? (I read so many times the pdf and search on the net but I don't understand exactly the purpose)
I know it use for retrive any change on edge, entities, component ... but what for ?
Can you give me example ? -
@dan rathbun said:
Here is another way which can copy multiple objects (be they components, groups, primitives, or any combination of them.)
1) Select the component, or the selection contains anything(s) you wish to copy.
2)
Sketchup.send_action("copy:")
3)
Sketchup.send_action("paste:")
User presses ESC to unselect the copied things. (But the MoveTool is still active afterward.)
You can clear the selection viaSketchup.active_model.selection.clear()
and then reset the original selection if you have first saved it to an array.All this can be done with the Edit menu options, or the Copy and Paste buttons from the Standard toolbar, or CTRL+C/CTRL+V shortcuts.
Yeah, I think it could be a great solution but the tool i've made is really useful for people who works for making forest on sketchup for example.
You select your first tree, activate the plugin, and put your tree everywhere you click (like the video game SIMS on computer )
BUT I WOULD THANKS TO ALL OF YOU !
-
I think there is a component spray plugin that you could use to spray trees into a model.
-
@dan rathbun said:
I think there is a component spray plugin that you could use to spray trees into a model.
yeah ! but it's not only trees
-
I want to put a name on each copy
the name is store on that variable : @nameCompoI put that code
newCompo = @model.place_component(@composantDef, true)
I try
newCompo.name = "#{@nameCompo}"
but it didn't work
I try also
@model.place_component(@composantDef, true, "#{nameCompo})
didn't work too...
Can I have all parameters of "place_component" ? -
@njeremy2 said:
Can I have all parameters of "place_component" ?
There are only 2.
And the API is wrong.. the method always returns the
model
object. (It cannot return the new component instance because there may be many off them.)So instead do this:
before = @composantDef.instances.to_a toolset = Sketchup.active_model.tools @model.place_component(@composantDef, true) tid = UI.start_timer(1.0,true){ if toolset.active_tool_id != 21013 UI.stop_timer(tid) after = @composantDef.instances.to_a - before after.each {|inst| inst.name = @nameCompo } end }
-
@dan rathbun said:
@njeremy2 said:
Can I have all parameters of "place_component" ?
There are only 2.
And the API is wrong.. the method always returns the
model
object. (It cannot return the new component instance because there may be many off them.)So instead do this:
> before = @composantDef.instances.to_a > toolset = Sketchup.active_model.tools > @model.place_component(@composantDef, true) > tid = UI.start_timer(1.0,true){ > if toolset.active_tool_id != 21013 > UI.stop_timer(tid) > after = @composantDef.instances.to_a - before > after.each {|inst| inst.name = @nameCompo } > end > } >
I'm gonna try this now, I will tell you again when it's working
-
Dan, if you were a girl, I could fall in love with you !!!
It's working !
Thanks to Dan and TIG !!
If you need a help from me for Sketchup, ask me I'm a professional almost ! lol
-
Instead of a timer, wouldn't
DefinitionObserver.onComponentInstanceAdded
be better..?
https://developers.google.com/sketchup/docs/ourdoc/definitionobserver#onComponentInstanceAdded -
@thomthom said:
Instead of a timer, wouldn't
DefinitionObserver.onComponentInstanceAdded
be better..?
https://developers.google.com/sketchup/docs/ourdoc/definitionobserver#onComponentInstanceAddedHe is a month-old newbie.. I didn't want to go into observers with him yet.
-
@dan rathbun said:
@thomthom said:
Instead of a timer, wouldn't
DefinitionObserver.onComponentInstanceAdded
be better..?
https://developers.google.com/sketchup/docs/ourdoc/definitionobserver#onComponentInstanceAddedHe is a month-old newbie.. I didn't want to go into observers with him yet.
right ! thanks
not "month-old", I'm "week-old" newbie !
Advertisement