Align Selection to Grease Pencil 1.2.3 (2.80)

Compatible with 2.80
2.80 note: Currently only works through hotkey. Toolbar buttons are TODO!

Note: Assigns the hotkey Alt + Right Mouse (double-click). This can be disabled.
Note: The proportional edit mode breaks when used with a big radius.

Addon for 2.80 - GITHUB
(Legacy 2.79b compatible branch)

What does it do?

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.

TODO:

  • Add buttons (compatible with 2.80)
8 Likes

Nice work! Very easy and fast. Thnx!
Is it possible for armature (bones) too? Disney has similar tool for animation…

Thanks!

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?

I’ll write it down and see what I can do :slight_smile:

@VolantKnave Great work!

Yes, try it for pose mode, please ( animation mode). It will be great. Thank you for your interest.

Is this different than LoopTools Gstretch, method Project ?

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.

Yes, they have little differencies, not much.
Your script = light blue vertices
Gstretch = orange
Grease pencil = green

Attachments


That’s pretty interesting.

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?

Gstretch has 3 methods: Spread evenly, Spread and Project.

Attachments


I dont know about that, but vertex normals are part of the algorithm, because sometimes edges overlaps each other.

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. :slight_smile:

That’s a great hotkey suggestion. I hadn’t thought of that one. The downside can be severe, though, as you mention.

Double-click D could also work well.

Select none(unselect all) and Grease pencil is fine :slight_smile:

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 :slight_smile:

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.

@VolantKnave maybe add Proportional Editing to options?

Ah, yes, proportional editing could be very nice. I’ll look into it :slight_smile:

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”?