Maya 2024.2 point snap to EPs not working

Maya 2024.2 point snap to EPs not working

emilp
Participant Participant
608 Views
5 Replies
Message 1 of 6

Maya 2024.2 point snap to EPs not working

emilp
Participant
Participant

Am I missing something with this new version?


Scene:

Create a NURBS circle.

Display->NURBS->Edit Points

Create a locator.

 

Expected behavior:

Using the move tool and holding "v" should snap the locator to the displayed Edit Points.

 

Problem:

The snapping happens to CVs despite the fact they are not even displayed.

0 Likes
609 Views
5 Replies
Replies (5)
Message 2 of 6

n8skow
Collaborator
Collaborator
Try resetting your 'move' tool, but yes - 'v' should be the hotkey for snap to point.

Alternatively - you can turn on 'snap to points' at the top of your screen (the middle magnet icon I believe), and MMB click where you want to snap it.
0 Likes
Message 3 of 6

emilp
Participant
Participant

I appreciate the reply; I have tried that. Also, trashed preferences and reinstalled Maya.

Interestingly it works on surface EPs. 

0 Likes
Message 4 of 6

n8skow
Collaborator
Collaborator
To snap to a curve, you need to use the "C" key.
0 Likes
Message 5 of 6

emilp
Participant
Participant

That is just taking it to a “free ride” on the curve. I need specifically snapping to EPs because EPs represent the correct curve parameterization where spans begin and end. This feature worked since 1998 with no issues. The fact that it works on surface EPs and not curve EPs is telling me this is a bug. I was hoping it’s human error (me). I guess I need to wait for 2024.3. Fingers crossed!

Message 6 of 6

emilp
Participant
Participant

If anyone is interested, here is a ChatGPT workaround. After the user snaps the transform node to the CV of a curve (unwanted behavior originally described) the script calculates the distance to the closest EP on the same curve and moves the transform node to that location. It's an extra step, but it can be used on a hotkey, so not too bad.

 

import maya.cmds as cmds
import maya.OpenMaya as om

def snap_transform_to_closest_curve_point():
    # Get selected objects
    selection = cmds.ls(selection=True, type='transform')
    
    if len(selection) < 2:
        cmds.error("Please select a transform node and a curve.")
        return

    transform_name = selection[0]
    curve_name = selection[1]

    # Check if the second selection is a curve
    curve_shapes = cmds.listRelatives(curve_name, children=True, shapes=True)
    if not curve_shapes or not cmds.objectType(curve_shapes[0], isType='nurbsCurve'):
        cmds.error("Second selection must be a curve.")
        return

    # Get Edit Points of the curve
    edit_points = cmds.ls(curve_name + '.ep[*]', fl=True)
    if not edit_points:  # Fallback to control vertices if no edit points
        edit_points = cmds.ls(curve_name + '.cv[*]', fl=True)

    # Get Transform Position
    transform_position = cmds.xform(transform_name, q=True, ws=True, t=True)
    if len(transform_position) == 3:
        transform_pos = om.MVector(transform_position[0], transform_position[1], transform_position[2])
    else:
        cmds.error("Could not determine transform position.")
        return

    # Find Closest Curve Point
    min_distance = float('inf')
    closest_point = None
    for point in edit_points:
        point_pos = om.MVector(*cmds.pointPosition(point))
        distance = (point_pos - transform_pos).length()
        if distance < min_distance:
            min_distance = distance
            closest_point = point_pos

    # Move Transform to Closest Curve Point
    if closest_point:
        cmds.move(closest_point.x, closest_point.y, closest_point.z, transform_name)

# Run the function
snap_transform_to_closest_curve_point()

 

0 Likes