Object vertex snapping script

free scripts, plugins, models, textures
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Object vertex snapping script

Post by clintonman »

This is an updated version of the script released on the caligari forums. It opens with a button and works with pivots. It's purpose is to snap the position of one object to another, snap an object to the position of a vertex selection, snap a vertex selection to the position of an object or another vertex selection. It also works with the shape skeleton tool to snap the positions of joints.

http://www.clintons3d.com/plugins/trues ... index.html"

original thread is here:
http://forums1.caligari.com/truespace/s ... post105750"
Clinton Reese

http://clintons3d.com
User avatar
Prodigy
Site Admin
Posts: 957
Joined: 21 May 2009, 14:46
Type the number ten into the box: 0
Location: Uruguay

Re: Object vertex snapping script

Post by Prodigy »

Excellent Clinton!
btw, it would be nice to have support for snapping faces.. 8-)
๑۩۞۩๑ prodigy ๑۩۞۩๑
v3rd3
Lieutenant Commander
Posts: 1191
Joined: 21 May 2009, 20:04

Re: Object vertex snapping script

Post by v3rd3 »

Thanks for the update....
User avatar
trueBlue
Captain
Posts: 5548
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Object vertex snapping script

Post by trueBlue »

Thanks Clinton!
I agree that snap to faces would be a nice addition.
I added these commands to your button scripts. Not pretty but it works when selecting faces.
But then again it might not be compatible with the rest of the scripting.

Node.Value('/Preferences/Mesh Editor Settings','PE selection mode') = 'vertex'; MeshModifiers.ActivatePointEditWidget('','','Default');
MeshModifiers.ConvertSelection('','');
Activity.Run('%THIS_NAME%' + "/getPoint2")
Node.Value('/Preferences/Mesh Editor Settings','PE selection mode') = 'context'; MeshModifiers.ActivatePointEditWidget('','','Default');
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: Object vertex snapping script

Post by clintonman »

Here's a preview of what I worked on today. Select the object to move and the target object by control clicking in the 3d view or marque in the link editor and push the "do it" button. PE mode will start. Choose a face on the moving object then select a face on the target object. PE mode will end and the moving object will move to the target object so their faces are touching. Sometimes they will even face the same direction, but only sometimes. ;)

BTW, Does anyone know how to keep the LE from rearranging the nodes?
Attachments
face2face45be.zip
(23.42 KiB) Downloaded 278 times
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: Object vertex snapping script

Post by clintonman »

Update to version 3.1

Fixes a bug that gets the wrong position of a vertex if the mesh has a pivot that has not been flattened. It does this by flattening the axis automatically.

Now automatically converts a selection to and from vertices.

Includes a status line update and cleaner traces in the output console.
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: Object vertex snapping script

Post by clintonman »

Update September 5 2011

Added option to snap the pivot instead of the mesh and another option to use the current selection for the start instead of explicitly clicking the button to set it.
Clinton Reese

http://clintons3d.com
Peter
Senior Chief Petty Officer
Posts: 170
Joined: 18 Apr 2010, 15:18
Type the number ten into the box: 0
Location: Texas

Re: Object vertex snapping script

Post by Peter »

Thanks Clinton.
Can this be used to change the pivot point of a polygon in pe mode?
I've often wanted to be able to rotate a polygon like it were on a hinge about one of it's edges but couldn't find a way.
-Pete
a day without orange juice is like... a day without orange juice
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: Object vertex snapping script

Post by clintonman »

Peter wrote:Thanks Clinton.
Can this be used to change the pivot point of a polygon in pe mode?
I've often wanted to be able to rotate a polygon like it were on a hinge about one of it's edges but couldn't find a way.
-Pete
Do you have trueBlue's unofficial patch for truespace installed? If so(from the read me)
"* Point Edit Widgets - Added PE Pivot Snap. Use the P key + LMB select any part of the Widget and release to set the Pivot on selected element. Use RMB + Drag on rotation Arcs to rotate from set pivot. Contributed by Clinton."
Clinton Reese

http://clintons3d.com
Peter
Senior Chief Petty Officer
Posts: 170
Joined: 18 Apr 2010, 15:18
Type the number ten into the box: 0
Location: Texas

Re: Object vertex snapping script

Post by Peter »

I installed the updates but I can't get the pivot snap to work. I'm sure I'm doing something wrong.

I created a cube object, went into pe mode, selected a face, held the p key while I left-clicked on part of the widget, with the buttons still held I moved the mouse, I released the mouse button and the p key, Then I right-click rotated on one of the arcs. It still rotates the polygon about it's center.

Any Ideas?

Thanks.
a day without orange juice is like... a day without orange juice
Peter
Senior Chief Petty Officer
Posts: 170
Joined: 18 Apr 2010, 15:18
Type the number ten into the box: 0
Location: Texas

Re: Object vertex snapping script

Post by Peter »

Disregard my last post. I figured it out.

Example usage: ( a cube with all rotations = zero )
in PE select an edge, click p + LMB on any part of the widget, select a face connected to that edge, RMB drag on a widget arc. Viola! I just pivoted a face about one of its edges.

Of course you could click on any element to set the pivot.

The only catch seems to be that this sets the origin of the rotation, not the orientation of the widget arcs. So the edge above is a hinge only if it's parallel to one of the coordinate frame axes.

Does this sound right?
a day without orange juice is like... a day without orange juice
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: Object vertex snapping script

Post by clintonman »

Peter wrote:Disregard my last post. I figured it out.

Example usage: ( a cube with all rotations = zero )
in PE select an edge, click p + LMB on any part of the widget, select a face connected to that edge, RMB drag on a widget arc. Viola! I just pivoted a face about one of its edges.

Of course you could click on any element to set the pivot.

The only catch seems to be that this sets the origin of the rotation, not the orientation of the widget arcs. So the edge above is a hinge only if it's parallel to one of the coordinate frame axes.

Does this sound right?
That sounds right to me. You can switch to object coordinate to get closer in some cases like 4 sided polygons.
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: Object vertex snapping script

Post by clintonman »

Update January 8, 2012

Automatic installer
Use axis locking option
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5548
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Object vertex snapping script

Post by trueBlue »

I am creating a widget using your objectVerticeSnap script.
I notice an error when you select more than one object and enter into PE, you will get this error even though I am in Vertice Selection mode.
Capture.PNG
Any ideas how to close an opened widget from script?
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: Object vertex snapping script

Post by clintonman »

trueBlue wrote:I am creating a widget using your objectVerticeSnap script.
I notice an error when you select more than one object and enter into PE, you will get this error even though I am in Vertice Selection mode.
Capture.PNG
Any ideas how to close an opened widget from script?
The only widget I have turns off and on by deleting it.

First line is from the button. The rest of the lines are from the toggleWidget script.

Code: Select all

Activity.Run("/Scripts/CustomCommands/cubeWidget/toggleWidget")

owner = System.ThisOwner();
if(Node.Exists("/Widgets/Active Widgets Layer2/CubeWidget"))
{
	Node.Delete("/Widgets/Active Widgets Layer2/CubeWidget");
}
else
{
	Node.Copy(owner + "/CubeWidget","/Widgets/Active Widgets Layer2");
}
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: Object vertex snapping script

Post by clintonman »

Tool has been updated to allow 2 objects in PE mode.
http://www.clintons3d.com/plugins/trues ... index.html"
Clinton Reese

http://clintons3d.com
stan
Master Chief Petty Officer
Posts: 584
Joined: 21 May 2009, 17:20

Re: Object vertex snapping script

Post by stan »

you might be able to turn off your widget this way:
Widgets.ToggleWidget( '{E8913C00-9A2A-43cf-8238-27B4BFB50A1F}' , '/Widgets/Tools/Rect tool', 'Default', '','')

the guid is the point edit group value, next is your widget name.
On toggle of command..
It opens the tool and closes what other edit tool that might be open
It closed the tool and returned to selection mode when toggled :D
User avatar
trueBlue
Captain
Posts: 5548
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Object vertex snapping script

Post by trueBlue »

Thanks Stan, I'll give that a try too.
Thanks Clinton!
Do you remember which script(s) you modified?
And or added any additional scripts?
Have not looked yet
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: Object vertex snapping script

Post by clintonman »

trueBlue wrote:Thanks Stan, I'll give that a try too.
Thanks Clinton!
Do you remember which script(s) you modified?
And or added any additional scripts?
Have not looked yet
modified:
save obj ref
first face select
second face select
selectFaceMode, 1

added:
reEnterPEmode
Clinton Reese

http://clintons3d.com

Return to “Repositorium”