Created geometry on auto-move mode
-
Greetings all,
This is my first post to the forum, what i've read here so far, seems like an excellent forum, good work guys!So to the question at hand:
I've impleneted a small script that prompts for values and creates a window element from the values input, the problem is that the element pops into existance at 0,0,0 which in case of modeling a large house for example is not very handy. Is there a way to activate the move tool from ruby and set the grab point as one of the corners of the just created group? This would make my life a lot easier
Br,
Janne[lekonna]
-
Ah, this one took me a while to find too.
The method you are looking for is a method of the Model class called place_component. It attaches a ComponentDefinition to the mouse pointer for placement.
-
wow that was a fast reply, thanks jim!
Now i'll just have to dig out how the ComponentDefinition class works, as my geometry is at the moment only a group.
[lekonna]
-
@lekonna said:
wow that was a fast reply, thanks jim!
Now i'll just have to dig out how the ComponentDefinition class works, as my geometry is at the moment only a group.
Nah, just try it with the Group, it might work. But if not, you just create a new ComponentDefinition instead of a new Group and use the Defs entities. You shouldn't need to change but one line of code (maybe.)
-
Error; #<TypeError; wrong argument type (expected Sketchup;;ComponentDefinition)>
dang model.definitions seems to retrieve the list of component definitions in the model, but how do i go about creating one and assigning this group to it?
[lekonna]
-
cdef = Sketchup.active_model.definitions.add("Component Def Name")
Oh, you already have a Group. I forgot about Group.to_component !
-
alright. the documentation seems to be bit incomplete on that method.
what i tried was:
component = group.to_component status = model.place_component component
and what i got was
Error; #<TypeError; wrong argument type (expected Sketchup;;ComponentDefinition)>
so it would seem that it doesn't return a componentdefinition
[lekonna]
-
haa gotit!
the to_component returns a componentInstance which has the
definition method returing just what i needed.Thanks a ton Jim!
[lekonna]
-
hmm it seems that now i get double geometry, the one i place with the place_component and one created at 0,0,0 duh.
[lekonna]
-
Geez it seems i'm lost with this coding business, well it's been like 5 years, thats what managering stuff does to you i suppose.
Can you guys point a good way to get rid of the double geometry for me? If i just go ahead and upload the script here. Though i have to appologize for the code since the variables and texts are in finnish. Was bit too sure i could pull one simple script off by myselfs
So the problem being on how to get rid of the double geometry thats not folling the place_component.
Thanks in advance, should be no-brainer for you guys.
-Janne
http://www.sketchucation.com/forums/scf/sas/Ruby/windower.rb
[lekonna]
-
You want to create a ComponentDefinition from the start. Try these changes:
33; definition = Sketchup.active_model.definitions.add("New Def") 34; entities = definition.entities ... 113; (removed) 115; (removed)
-
perfect, thanks Jim!
[lekonna]
Advertisement