[Addon] Align Selection to Grease Pencil


(VolantKnave) #1

Note: Assigns the hotkey Shift + Left Mouse (double-click)
Note: The proportional edit mode breaks when used with a big radius.
DOWNLOAD V1.0.8 HERE (2.73 and above)

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.

I can only guarantee that it works in 2.73 and above.

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

  • None (feel free to suggest!)

(krokodil) #2

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


(VolantKnave) #3

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:


(floo) #4

@VolantKnave Great work!


(krokodil) #5

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


(JuhaW) #6

Is this different than LoopTools Gstretch, method Project ?


(riidom) #7

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.


(VolantKnave) #8

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.


(JuhaW) #9

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

Attachments



(VolantKnave) #10

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?


(JuhaW) #11

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

Attachments



(JuhaW) #12

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


(VolantKnave) #13

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:


(VolantKnave) #14

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.


(JuhaW) #15

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


(riidom) #16

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:


(aermartin) #17

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.


(floo) #18

@VolantKnave maybe add Proportional Editing to options?


(VolantKnave) #19

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


(MacroManJr) #20

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