Object vertex snapping script
-
clintonman
- Captain
- Posts: 5659
- Joined: 21 May 2009, 21:08
- Type the number ten into the box: 0
- Location: California
Object vertex snapping script
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"
http://www.clintons3d.com/plugins/trues ... index.html"
original thread is here:
http://forums1.caligari.com/truespace/s ... post105750"
-
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
Excellent Clinton!
btw, it would be nice to have support for snapping faces..
btw, it would be nice to have support for snapping faces..
๑۩۞۩๑ prodigy ๑۩۞۩๑
-
v3rd3
- Lieutenant Commander
- Posts: 1191
- Joined: 21 May 2009, 20:04
Re: Object vertex snapping script
Thanks for the update....
-
trueBlue
- Captain
- Posts: 5548
- Joined: 06 Jul 2009, 22:50
- Type the number ten into the box: 10
Re: Object vertex snapping script
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');
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');
-
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
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?
BTW, Does anyone know how to keep the LE from rearranging the nodes?
- Attachments
-
- face2face45be.zip
- (23.42 KiB) Downloaded 278 times
-
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
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.
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.
-
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
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.
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.
-
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
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
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
-
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
Do you have trueBlue's unofficial patch for truespace installed? If so(from the read me)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
"* 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."
-
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
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.
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
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?
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
-
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
That sounds right to me. You can switch to object coordinate to get closer in some cases like 4 sided polygons.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?
-
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
Update January 8, 2012
Automatic installer
Use axis locking option
Automatic installer
Use axis locking option
-
trueBlue
- Captain
- Posts: 5548
- Joined: 06 Jul 2009, 22:50
- Type the number ten into the box: 10
Re: Object vertex snapping script
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. Any ideas how to close an opened widget from 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. Any ideas how to close an opened widget from script?
-
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
The only widget I have turns off and on by deleting it.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. Any ideas how to close an opened widget from script?
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");
}-
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
Tool has been updated to allow 2 objects in PE mode.
http://www.clintons3d.com/plugins/trues ... index.html"
http://www.clintons3d.com/plugins/trues ... index.html"
-
stan
- Master Chief Petty Officer
- Posts: 584
- Joined: 21 May 2009, 17:20
Re: Object vertex snapping script
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
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
-
trueBlue
- Captain
- Posts: 5548
- Joined: 06 Jul 2009, 22:50
- Type the number ten into the box: 10
Re: Object vertex snapping script
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
Thanks Clinton!
Do you remember which script(s) you modified?
And or added any additional scripts?
Have not looked yet
-
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
modified: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
save obj ref
first face select
second face select
selectFaceMode, 1
added:
reEnterPEmode
