Vertex selection/transofrm plugin
-
It's not very hard to do, but's probably a bit too hard for most casual scripters because it is a bit of a challenge to duplicate the functionality of the native SketchUp move, rotate and scale tools.
I guess I'll let one cat of the bag and say that it is planned in SDS2 to have vertex selection and transformation. However, that will be a commercial plugin and who knows when it will be released?
It would be good to have a free plugin with a few simple vertex tools, though. You should give it a try, Remus.
-
I might wait for chris tutorial, as ive never made a 'proper' tool before (i.e. using a class to access the mouse and keyboard.)
-
@whaat said:
and who knows when it will be released?
hmm, well if i had to make a wild guess, i'd say whaat has the best chance of knowing when it will be released
-
Heh. Seems that many have been thinking of various vertex tools. I've been thinking of "sticky vertices" where you select and link vertices together. So moving one around will move another. Linking stuff together.
-
@remus said:
Is there any reason why a plugin doesnt exist at the moment that allows you to modify vertices? I was thinking of having a crack at it but was wondering if theres some technical reason why it's hard/impossible to do.
There's nothing complex actually in writing any code about vertex deformations. The real issues is to know exactly what to do in real use cases, because moving one vertex is probably not really helpful as such.
In my next plugin, I am for instance deforming curves based on moving an extremity (something Sketchup does natively in the Move tool, but does not propose for one single vertex).
So I would suggest the Community elaborates a little bit more on real-life examples of vertex edition.Fredo
-
Here is an example of a fully functioning tool class Remus. Copy all of it into Jim's web dialog, then execute.
` class Remus_tooldef onMouseMove(flags, x, y, view)
ip = view.inputpoint x,y
@cursor = ip.position
view.invalidate
enddef draw(view)
view.draw_points @cursor, 10, 1, "red"
endend
Sketchup.active_model.select_tool Remus_tool.new`
The main things to learn from it are that tools are their own class. To start a tool, you have to use
Sketchup.active_model.select_tool( my_tool_object )
. Once you have the tool class, you can use all the cool tool methods defined in the tool classin the API. So you get access to the mouse and keyboard, for example.Also, in the onMouseMove, I am calling view.invalidate. Everytime that is called, SketchUp checks the draw method (if there is one(you need to add it like I did)). So everytime view.invalidate is called, the draw method does whatever it is told to do. It is only from within the draw method that you can call all the screen drawing methodsfound in the View class.
Also, the last thing I will note about the code is that the inputpoint is finding the 2d mouse coordinates and returning a 3d position. Because the view.draw method draws in 3d model space, not 2d screen space (yes there is a draw2d method, but it didn't want to cooperate today).
Heheehe, have fun!
Chris
-
@unknownuser said:
So I would suggest the Community elaborates a little bit more on real-life examples of vertex edition.
for me personally, i don't edit vertices too often.. (well, i use sandbox smoove sometimes and i like it's soft selection feature but the z axis only is sort of letdown)..
anyway, most of the times that i grab and move individual vertices is for cleaning up after certain ruby operations..
here's an example after bending..at this point, i'll use the move tool and click on misplaced vertices and drag them into place (sometimes using autofold.. sometimes erasing stray lines)
and i just work my way around the shape til it's clean..
so yeah, some form of auto join vertices plug would be awesome but really, i can see how it might be hard to get it too work right in multiple circumstances..
-
well, maybe first things first. This is an even simpler tool class that accesses the mouse movements. it puts the x,z coordintes to the ruby console:
` class Remus_tool
def onMouseMove(flags, x, y, view)
puts x.to_s + ", " + y.to_s
end
endSketchup.active_model.select_tool Remus_tool.new`
That might be slighlty simpler to look at, at first. Then start playing with all the tool class methods to see what you can do.
Chris
-
Cheers chris, thats a really cool little example. Im tempted to give it a bash now, just got to find some time in between all this uni work.
-
You need to transform any connected set of vertices in one go, with something like...
entities.transform_entities(transformation, [array_of_vertices])
The transformation can be any of the transformation types - like a rotation, scaling, translate etc...
the remaining argument(s) can be a number of comma separated entities or an array - since a vertex is an entity as far as this is concerned, so this is the way to manipulate vertices en mass. -
Cheers for the tips tog, just tried that out and have managed to get transformations working for the first time (not that i ever really tried before )
-
For what its worth I'm transforming vertices in my JS-Align script. You can take a look at the code.
http://www.pixero.com -
See my ArchTools VertexTool Plugin:
It is the part from my complex of plugins.
(WIP)
http://www.youtube.com/watch?v=R4WVAcu_nM0 -
Doesn't 1001 bit tools have a vertex move tool. At least that what I use to move a vertex. Maybe you need something else.
Ken
-
Also my 2D Polyline Edit Tool effectively lets you relocate a Polyline's Vertices by picking on them and their new location, one at a time... See its code for how it does those transformations, with a 'ghost polyline' till you end it...
Advertisement