Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Centre pivot of CV curve

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
1731 Views, 7 Replies

Centre pivot of CV curve

Anonymous
Not applicable

Hey guys

Right, I'm trying to create a square from a CV curve in python for use as a control object on a joint, but everytime I spawn it the curve ends up like this. I'm creating the curve as a variable, how do I centre the pivot for the curve? Or is there another method to create a curve for it?

newCtrl = cmds.curve(d=1, p=[(0,0,0), (4,0,0), (4,0,4), (0,0,4), (0,0,0)])
base.parent(newCtrl, offsetGroup)

 

The problem illustrated on a joint.The problem illustrated on a joint.

 

Thanks

0 Likes

Centre pivot of CV curve

Hey guys

Right, I'm trying to create a square from a CV curve in python for use as a control object on a joint, but everytime I spawn it the curve ends up like this. I'm creating the curve as a variable, how do I centre the pivot for the curve? Or is there another method to create a curve for it?

newCtrl = cmds.curve(d=1, p=[(0,0,0), (4,0,0), (4,0,4), (0,0,4), (0,0,0)])
base.parent(newCtrl, offsetGroup)

 

The problem illustrated on a joint.The problem illustrated on a joint.

 

Thanks

Labels (4)
7 REPLIES 7
Message 2 of 8
mcw0
in reply to: Anonymous

mcw0
Advisor
Advisor

The "xform" command has a "cp" flag to centerPivot

0 Likes

The "xform" command has a "cp" flag to centerPivot

Message 3 of 8
Anonymous
in reply to: mcw0

Anonymous
Not applicable

Using the "xform" command was my first solution, but that doesn't seem to work with the variable. Either putting the xform command next to or after the curve command:

 

newCtrl = cmds.curve(d=1, p=[(0,0,0), (4,0,0), (4,0,4), (0,0,4), (0,0,0)]), base.xform(cp=True)

base.parent(newCtrl, offsetGroup)

 

 

newCtrl = cmds.curve(d=1, p=[(0,0,0), (4,0,0), (4,0,4), (0,0,4), (0,0,0)])

base.xform(newCtrl, cp=True)

base.parent(newCtrl, offsetGroup)

 

Neither of these methods work, is there another way?

 

Thanks

 

0 Likes

Using the "xform" command was my first solution, but that doesn't seem to work with the variable. Either putting the xform command next to or after the curve command:

 

newCtrl = cmds.curve(d=1, p=[(0,0,0), (4,0,0), (4,0,4), (0,0,4), (0,0,0)]), base.xform(cp=True)

base.parent(newCtrl, offsetGroup)

 

 

newCtrl = cmds.curve(d=1, p=[(0,0,0), (4,0,0), (4,0,4), (0,0,4), (0,0,0)])

base.xform(newCtrl, cp=True)

base.parent(newCtrl, offsetGroup)

 

Neither of these methods work, is there another way?

 

Thanks

 

Message 4 of 8
mcw0
in reply to: Anonymous

mcw0
Advisor
Advisor

import maya.cmds as cmds
offsetGroup = cmds.ls(sl=1)
newCtrl = cmds.curve(d=1, p=[(0,0,0), (4,0,0), (4,0,4), (0,0,4), (0,0,0)])
cmds.xform(newCtrl, cp=True)
cmds.delete(cmds.pointConstraint(offsetGroup, newCtrl))
cmds.parent(newCtrl, offsetGroup)

 

I'm assuming you have the joint selected.

import maya.cmds as cmds
offsetGroup = cmds.ls(sl=1)
newCtrl = cmds.curve(d=1, p=[(0,0,0), (4,0,0), (4,0,4), (0,0,4), (0,0,0)])
cmds.xform(newCtrl, cp=True)
cmds.delete(cmds.pointConstraint(offsetGroup, newCtrl))
cmds.parent(newCtrl, offsetGroup)

 

I'm assuming you have the joint selected.

Message 5 of 8
Anonymous
in reply to: mcw0

Anonymous
Not applicable

This is a step in the right direction, it produces this result: Control_Code_Problem_2.jpg

Now the axis just need to align with the joints and it's all good to go. Any ideas?

0 Likes

This is a step in the right direction, it produces this result: Control_Code_Problem_2.jpg

Now the axis just need to align with the joints and it's all good to go. Any ideas?

Message 6 of 8
mcw0
in reply to: Anonymous

mcw0
Advisor
Advisor

Sure...in your original "curve" command, rearrange your values so that the curve is created in the correct orientation.  You are currently creating your curve on the XZ plane.  Try YZ or XY.

0 Likes

Sure...in your original "curve" command, rearrange your values so that the curve is created in the correct orientation.  You are currently creating your curve on the XZ plane.  Try YZ or XY.

Message 7 of 8
olarn
in reply to: Anonymous

olarn
Advocate
Advocate
Accepted solution

You could try commands like

matchTransform -rotation

To match rotation. And then rotate, or just create your curve in the orientation matching your joint's in the first place

0 Likes

You could try commands like

matchTransform -rotation

To match rotation. And then rotate, or just create your curve in the orientation matching your joint's in the first place

Message 8 of 8
Anonymous
in reply to: olarn

Anonymous
Not applicable

That's done it 🙂 thanks!

0 Likes

That's done it 🙂 thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report