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
1618 Views, 7 Replies

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

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

Message 3 of 8
Anonymous
in reply to: mcw0

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

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

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

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

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

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