Align Selection to Grease Pencil 1.2.3 (2.80)

Sorry for not responding! I suddenly stopped receiving email notifications for new posts.

Here’s a new version! DOWNLOAD v1.0.7 HERE

I’ve added working support for the following:

  • Edit mode bones
  • Paths/curves (except Free or Aligned type bezier curves)
  • Objects (using their origins)

I also added very basic (read: BAD) support for aligning pose mode bones. It’s probably not very helpful at this point. Don’t expect any magic and use it at your own risk. :slight_smile:

I had not thought of doing that. Added it now :slight_smile:

The default hotkey is now Shift + Double-click Left Mouse.

Traceback (most recent call last):
File “C:[…]\Blender Foundation\Blender\2.70\scripts\addons\mesh_align_ to_gpencil_view.py”, line 92, in poll
if len(bpy.data.grease_pencil[-1].layers) is 0:
IndexError: bpy_prop_collection[-1]: out of range.

location: <unknown location>:-1

This error should also be fixed now.

A quick question - how that Paths/curves feature works?

It works exactly like it works for vertices, for now. Path vertices can be snapped to a stroke.

But don’t worry, I have not forgotten your suggestion :slight_smile:

oh, OK thanks. :slight_smile:

Hi,

I just find this addon. great!
but it can’t perform with my part …

Traceback (most recent call last):
File “C:\Users\hp\AppData\Roaming\Blender Foundation\Blender\2.71\scripts\addons\mesh_align_to_gpencil_view.py”, line 148, in execute
align_vertices(context, self.influence)
File “C:\Users\hp\AppData\Roaming\Blender Foundation\Blender\2.71\scripts\addons\mesh_align_to_gpencil_view.py”, line 428, in align_vertices
nearest_point = get_nearest_interpolated_point_on_stroke(verts_world_2d[i], gpencil_to_screenpos(context), context)
File “C:\Users\hp\AppData\Roaming\Blender Foundation\Blender\2.71\scripts\addons\mesh_align_to_gpencil_view.py”, line 619, in gpencil_to_screenpos
gps = bpy.context.active_object.grease_pencil.layers[-1].active_frame
AttributeError: ‘NoneType’ object has no attribute ‘layers’

location: <unknown location>:-1

why?
thanks

I’ve got a quuestion)
Is it possible to align UV vertices to gpencli stroke in image editor?

Yes, that should already be possible with the latest version. It is perhaps a bit hidden, though. Assign a hotkey to call ‘uv.align_verts_to_gpencil’ in the UV editor. (Same limitations as elsewhere. Horizontal/vertical only.)

Make sure that you select the object you’re working on before entering edit mode. I’ll fix this in a future update. :slight_smile:

Wow, very spiffy. :yes:

When I try it, in Blender 2.71 or the 2.72 release candidate, I get what I think is a bug: it fails unless there is at least one scene in the .blend file that has the name “Scene” … If I have no scene with that exact name, the addon throws up an error.

Has anyone managed to use this with 2.74?

It should still work, but you have to switch grease pencil from Scene to Object.

I haven’t had time to fix this yet.

In the “N”-menu, click this:
http://i.imgur.com/n3xLf4b.png

Any strokes drawn when this is active should work just as before.

I’m getting unwanted results when trying to align UVs in the Image Editor (see image), i.e. verts are moved way too far from where the stroke is and they’re not aligned properly even at their new position (they always form straight lines ignoring the stroke curvature). Does anyone know how to fix this?


I managed to reproduce the bug here, so I will look into it. Stay tuned.

Hello,
Is the dropbox file yours ?
Because I DL from it and got a file with bl_info 1.08 and you have at least 1.07 release…
That file (i download) got an error indentation and run with the def poll class method doesn’t work.
I run this script time ago and it was ok… did you been hacked ?

Ah, sorry about that. My bad. Not hacked, but I had managed to overwrite the active Dropbox file with an unfinished version. It’s fixed now (reverted to 1.0.7).

Thanks for letting me know!

This is the best thing since sliced bread. Thank you very much. Without doubt it should be integrated into official Blender as fast as humanly possible.

Edit: If it works. >.<

Just tried it in 2.76 and it is just spilling out errors no matter what i do. If you are interested i can post it, but i assume you already know about it.

All is fine, i try it and work perfectly !

I saw in the script before the line :
def location_to_region(worldcoords):

that you put import bpy_extras, not needed at this place because it’s done on the top level of the script.

Thank’s for this so usefull addon !

Please post it :slight_smile:

Right you are. Removed it!

NameError: name ‘bpy_extras’ is not defined

this is easy to fix, just add
import bpy_extras
at the begin

so bad


Traceback (most recent call last):
  File "E:\greensoft\3d\blender\Blender 2.76 (With V-Ray Additions)\2.76\scripts\addons\mesh_align_to_gpencil_view.py", line 149, in execute
    align_vertices(context, self.influence)
  File "E:\greensoft\3d\blender\Blender 2.76 (With V-Ray Additions)\2.76\scripts\addons\mesh_align_to_gpencil_view.py", line 431, in align_vertices
    nearest_point = get_nearest_interpolated_point_on_stroke(verts_world_2d[i],gpencil_to_screenpos(context), context)
  File "E:\greensoft\3d\blender\Blender 2.76 (With V-Ray Additions)\2.76\scripts\addons\mesh_align_to_gpencil_view.py", line 622, in gpencil_to_screenpos
    gps = bpy.context.active_object.grease_pencil.layers[-1].active_frame
AttributeError: 'NoneType' object has no attribute 'layers'

Updated to 1.0.8, for real this time.
DOWNLOAD 1.0.8 HERE.

Link can also be found in the first post.

It now works properly with both scene and object context strokes and should be generally stable. I removed a bunch of code that was either half-finished or plain not working, and optimized some code that was being called more often than it needed to.

Merry christmas.