Notifications
Clear all

[Closed] Snap object's pivot to a vertex

Hello,

I’m making my first steps in scripting… what I’m trying to do is feature that allows to snap an object’s pivot to certain vertex.

I’ve noticed that when I move the cursor (with vertex snapping ON) to a vertex
a message “Vertex snap on [object name] at [XYZ coordinates]” appears on the bottom of the screen.

Is there any way (I’m sure there is ;D) to use those current coordinates it a script ?

I would like the script to do steps, less more, like this:

  1. Affect Pivot Only Mode Toggle

  2. Read XYZ of vertex that the cursor is currently snapped to.

  3. Move pivot to this certain XYZ

  4. Affect Pivot Only Mode Toggle

So finally assign this script to a hot key… Move the cursor to a vertex, press the hotkey and have the pivot snapped to this vertex

I hope it makes any sense for you…

Cheers

1 Reply

I don’t know how to read these values from PromptLine but
you can use this…

on btn3DPMove pressed do undo “3DPivotMove” on
(
local sel = selection[1]
if sel != undefiend do
(
–1. Affect Pivot Only Mode Toggle + (store old settings)
local oldSnap = snapMode.Active
snapMode.Active = on
–2. Read XYZ of vertex that the cursor is currently snapped to.
local pp = pickpoint prompt:“Click to desired location.” snap:#3d
–3. Move pivot to this certain XYZ
if pp != undefiend do sel.pivot = pp
–4. Affect Pivot Only Mode Toggle + (restore old settings)
snapMode.Active = oldSnap
)
)