OpenMaya get/set edit points positions for nurbscurve

OpenMaya get/set edit points positions for nurbscurve

Anonymous
Not applicable
2,014 Views
4 Replies
Message 1 of 5

OpenMaya get/set edit points positions for nurbscurve

Anonymous
Not applicable

Hi all,

OpenMaya has methods

OpenMaya.MFnNurbsCurve.cvPosition()
OpenMaya.MFnNurbsCurve.setCVPosition() 	

 for get and set CVs positions.

But what if i want to change position of some Edit Point. For example i want curve went through some specified position (1, 0.5, 2.3), so i need change Edit Point position for precise.

 

By cmds or mel we can get and set EP position with

epPos = cmds.pointPosition( 'curve1' + ".ep[1]", w=True )	
cmds.move( 1, 0.5, 2.3,  'curve1' + ".ep[1]", worldSpace=True, absolute=True )

But how perform the same with OpenMaya?

 

0 Likes
2,015 Views
4 Replies
Replies (4)
Message 2 of 5

zewt
Collaborator
Collaborator

I think the only native API related to EPs is MFnNurbsCurve::createWithEditPoints.  I don't know of any API to read or write EPs on an existing curve, other than calling out to MEL (which you shouldn't be doing from MPxNode::compute if you're doing this from a plugin node).  You can generate a curve with createWithEditPoints and then use the result as the output from a node attribute, though.

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

@zewt wrote:

You can generate a curve with createWithEditPoints and then use the result as the output from a node attribute, though.


What you mean, what result? I tryed both methods:

create()
createWithEditPoints() 

and as i see, anyway i can't get and set positions of EP from new curve shape node.

 

 


@zewt wrote:

other than calling out to MEL (which you shouldn't be doing from MPxNode::compute if you're doing this from a plugin node).


You mean that with the MEL calling a plugin node will be work more slower, then without it?

What if use method from MGlobal?

executeCommand()
or
executePythonCommand()

 

I want also make curve straighten from some selected EP. For example curve have 15 EPs, i want select EP[6] and then script will make curve straighten from EP[6] to EP[15] in direction to EP[15], but from EP[0] to EP[6] curvature of curve will be not changed.

I need use EPs type for get correct distance for each EP from selected EP, for preserve lenght of this part of curve after make it straighten. With using CVs type i think i will lost lenght of this part of curve.

So i want make curve straighten by some part of curve. Maya have special command in Curves/Straighten, but it will affect on full curve shape.

0 Likes
Message 4 of 5

zewt
Collaborator
Collaborator

createWithEditPoints creates curve data from a list of EPs.  It won't let you edit an existing curve as EPs, it only creates a new one from scratch.  The low-level API just doesn't do much with EPs.

 

I'm not sure if you're making a node, but a plugin node (an MPxNode) just can't make MEL or Python calls from MPxNode::compute.

 

I want also make curve straighten from some selected EP. For example curve have 15 EPs, i want select EP[6] and then script will make curve straighten from EP[6] to EP[15] in direction to EP[15], but from EP[0] to EP[6] curvature of curve will be not changed.

I need use EPs type for get correct distance for each EP from selected EP, for preserve lenght of this part of curve after make it straighten. With using CVs type i think i will lost lenght of this part of curve.

So i want make curve straighten by some part of curve. Maya have special command in Curves/Straighten, but it will affect on full curve shape.


I'm not sure if EPs will do what you're trying to do.  EPs just force the curve to cross through the EP positions, twisting the curve however it needs to to make that happen.  Changing any EP can cause the entire curve to change, and even if EPs are in a straight line, the curve itself might not be.

 

Note that all NURBS curves are CV curves, even if you edit them with EPs.  EPs are just a way to modify CVs, they can't do anything CVs can't.

 

0 Likes
Message 5 of 5

Anonymous
Not applicable

@zewt wrote:

createWithEditPoints creates curve data from a list of EPs.  It won't let you edit an existing curve as EPs, it only creates a new one from scratch. 

 


Yes, you right.

Just interesting fact in Maya -

1 - make NurbesCurve straight

2 - lock it lenght

3 - mesure curve length with  arclen command and remember value

4 - grab last CV and make some curl form

5 - again mesure curve length

In result, first lenght value will be different then second, despite the fact that curve length was locked.

Also visually curve lenght are changable despite the fact that curve length is locked

But seems for  Maya this fact is normal.

 

With make curve straight by EP method, curve length also the same, by value, also visually it have same lenght while straight and curl.

 

So, if Maya decide CV method is normal, - ok.  I will use too CV method.

 

0 Likes