This script will allow you to align the selection to the current grease pencil stroke.
(Works with vertices, objects, paths, bezier curves (except Aligned and Free type curves), edit mode bones.)
All of this happens in screen space (2D), which means works just like moving vertices around using the “G” hotkey.
It has now been updated
If you have suggestions, find a bug or otherwise have trouble using it, let me know and I will do my best to accommodate!
Here’s a little video of it in action:
Note: In the video it looks pretty automatic, but you have to press a button or hotkey to actually align the vertices after painting a stroke.
CHANGELOG:
1.2.3: Thanks to @pullup: Fixes to keymap registration order, more tweakable options for hotkey.
1.2.2: Changed default hotkey to Alt+Double-Click Right Mouse and made it possible to disable auto setting of the hotkey.
1.2.1: Fixes for 2.80. Moved to github.
1.2.0: Updated for 2.80 API changes. Separated code so individual hotkeys can be assigned for vertices, edit mode bones, curves, uvs, etc.
1.0.8: Removed buggy pose mode support. Fixed support for “Scene” type grease pencil strokes. Some optimizations.
1.0.7: Added hotkey, fixed bugs in poll function
1.0.6: Basic support for UVs
1.0.5: Better proportional editing (but still buggy), pose bones, curves
1.0.2: Code cleanup, basic support for bones, objects and proportional editing
1.0.1: Fixed error caused by not importing view3d_utils
1.0.0: Addon released. Can align vertices to gpencil stroke.
Adding support for bones should be pretty simple, at least for bone edit mode. Would be interesting to try and implement it for pose mode as well. I’m guessing that’s what you would rather have?
Hi, wanted to share my suggestion for shortcut: “D - on release”, then it applies as soon as you stop drawing. Downside is, grease pencil isnt usable otherwise in edit mode anymore.
From what I can see, Gstretch places the vertices along the entire gpencil stroke, in world space. This little script pushes vertices only horizontally or vertically until it aligns with the gpencil stroke in screen space, regardless of where the stroke actually is placed in the world. This makes my script a bit easier to use for quick adjustments. Gstretch is very useful for other tasks, though.
What settings/mode of the Gstretch tool is that? I could not get it to work quite like that.
EDIT: Ok, scratch that. I got it to work like that now. Am I correct that the vertex normals have to actually “hit” the gpencil stroke in order for the Project mode to work?
I had some trouble with Project mode where it doesn’t do anything, or it only moves a single vertex. I’m assuming that has to do with the vertex normals and how they are used. It did work when the stroke was on the same plane as the vertices I used it on, and the vertex normals pointed directly at it (They were on the edge of a plane).
Anyway, it’s good to investigate this, as I did have a couple of moments when I wrote it where I wondered if I was just duplicating functionality. At least to me, my own script fills a niche that isn’t covered by Gstretch. Then I guess it’s up to everyone if they want to install an extra addon for a little thing like this.
Yes, you are right. I actually tried that, but I was concerned by the fact that the stroke disappears after drawing. Now I just remembered, there is an option where I told the addon to act just like that! Was a bit confused I guess
amazing just looked for something like this, 2 days ago. Will be awesome for doing shape keys facial animations. So much faster to place vertices after a grease stroke.
Hey riidom, what if there was a checkbox for activating such the feature of “D - on release,” just as there is one for activating “Sketch session”?