mgear.core.curve module

NurbsCurve creation functions

mgear.core.curve.addCnsCurve(parent, name, centers, degree=1)

Create a curve attached to given centers. One point per center

Parameters:
  • parent (dagNode) – Parent object.

  • name (str) – Name

  • centers (list of dagNode) – Object that will drive the curve.

  • degree (int) – 1 for linear curve, 3 for Cubic.

Returns:

The newly created curve.

Return type:

dagNode

mgear.core.curve.addCurve(parent, name, points, close=False, degree=3, m=pymel.core.datatypes.Matrix, op=False)

Create a NurbsCurve with a single subcurve.

Parameters:
  • parent (dagNode) – Parent object.

  • name (str) – Name

  • points (list of float) – points of the curve in a one dimension array [point0X, point0Y, point0Z, 1, point1X, point1Y, point1Z, 1, …].

  • close (bool) – True to close the curve.

  • degree (bool) – 1 for linear curve, 3 for Cubic.

  • m (matrix) – Global transform.

  • op (bool, optional) – If True will add a curve that pass over the points This is equivalent of using”editPoint “ flag

No Longer Returned:

dagNode: The newly created curve.

mgear.core.curve.add_linear_skinning_to_curve(curve_name, joint_list)

Adds a skinCluster to a curve and sets the skinning weights linearly among the list of joints based on the number of control points.

Parameters:
  • curve_name (str) – The name of the curve to add the skinCluster to.

  • joint_list (list) – A list of joint names to be included in the skinCluster.

Returns:

The name of the created skinCluster.

Return type:

PyNode

mgear.core.curve.average_curve(crv, shapes, average=2, avg_shape=False, avg_scl=False, avg_rot=False)

Average the shape, rotation and scale of the curve bettwen n number of curves

Parameters:
  • crv (dagNode) – curve to average shape

  • shapes ([dagNode]]) – imput curves to average the shapes

  • average (int, optional) – Number of curves to use on the average

  • avg_shape (bool, optional) – if True will interpolate curve shape

  • avg_scl (bool, optional) – if True will interpolate curve scale

  • avg_rot (bool, optional) – if True will interpolate curve rotation

mgear.core.curve.collect_curve_data(objs, rplStr=['', ''])

Generate a dictionary descriving the curve data

Suport multiple objects

Parameters:
  • objs (dagNode) – Curve object to store

  • collect_trans (bool, optional) – if false will skip the transformation matrix

  • rplStr (list, optional) – String to replace in names. This allow to change the curve names before store it. [old Name to replace, new name to set]

Returns:

Curves data

Return type:

dict

mgear.core.curve.collect_curve_shapes(crv, rplStr=['', ''])

Collect curve shapes data

Parameters:
  • crv (dagNode) – Curve object to collect the curve shapes data

  • rplStr (list, optional) – String to replace in names. This allow to change the curve names before store it. [old Name to replace, new name to set]

Returns:

Curve shapes dictionary and curve shapes names

Return type:

dict, list

mgear.core.curve.collect_selected_curve_data(objs=None, rplStr=['', ''])

Generate a dictionary descriving the curve data from selected objs

Parameters:

objs (None, optional) – Optionally a list of object can be provided

mgear.core.curve.cox_de_boor(u, i, p, knots)

Cox-De Boor algorithm to evaluate B-Spline basis function.

Parameters:
  • u (float) – Parameter value.

  • i (int) – Index of control point.

  • p (int) – Degree of the curve.

  • knots (list) – Knot vector.

Returns:

Evaluated B-Spline basis function value.

Return type:

float

mgear.core.curve.createCurveFromCurve(srcCrv, name, nbPoints, parent=None)

Create a curve from a curve

Parameters:
  • srcCrv (curve) – The source curve.

  • name (str) – The new curve name.

  • nbPoints (int) – Number of control points for the new curve.

  • parent (dagNode) – Parent of the new curve.

Returns:

The newly created curve.

Return type:

dagNode

mgear.core.curve.createCurveFromOrderedEdges(edgeLoop, startVertex, name, parent=None, degree=3)

Create a curve for a edgeloop ordering the list from starting vertex

Parameters:
  • edgeLoop (list) – List of edges

  • startVertex (vertex) – Starting vertex

  • name (str) – Name of the new curve.

  • parent (dagNode) – Parent of the new curve.

  • degree (int) – Degree of the new curve.

Returns:

The newly created curve.

Return type:

dagNode

mgear.core.curve.createCuveFromEdges(edgeList, name, parent=None, degree=3, sortingAxis='x')

Create curve from a edge list.

Parameters:
  • edgeList (list) – List of edges.

  • name (str) – Name of the new curve.

  • parent (dagNode) – Parent of the new curve.

  • degree (int) – Degree of the new curve.

  • sortingAxis (str) – Sorting axis x, y or z

Returns:

The newly created curve.

Return type:

dagNode

mgear.core.curve.create_curve_from_data(data, replaceShape=False, rebuildHierarchy=False, rplStr=['', ''], model=None)

Build the curves from a given curve data dict

Hierarchy rebuild after all curves are build to avoid lost parents

Parameters:
  • data (dict) – serialized curve data

  • replaceShape (bool, optional) – If True, will replace the shape on existing objects

  • rebuildHierarchy (bool, optional) – If True, will regenerate the hierarchy

mgear.core.curve.create_curve_from_data_by_name(crv, data, replaceShape=False, rebuildHierarchy=False, rplStr=['', ''], model=None)

Build one curve from a given curve data dict

Parameters:
  • crv (str) – name of the crv to create

  • data (dict) – serialized curve data

  • replaceShape (bool, optional) – If True, will replace the shape on existing objects

  • rebuildHierarchy (bool, optional) – If True, will regenerate the hierarchy

  • rplStr (list, optional) – String to replace in names. This allow to change the curve names before store it. [old Name to replace, new name to set]

  • model (dagNode, optional) – Model top node to help find the correct parent, if several objects with the same name

mgear.core.curve.create_locator_at_curve_point(object_names, percentage)

Create a locator at a point on a cubic NURBS curve in Maya.

Parameters:
  • object_names (list) – The names of the objects representing control points in Maya.

  • percentage (float) – Curve position as a percentage (0 to 100).

Example usage in Maya Select objects representing control points in Maya before running the script

object_names = cmds.ls(selection=True) create_locator_at_curve_point(object_names, 100)

mgear.core.curve.crv_parenting(data, crv, rplStr=['', ''], model=None)

Parent the new created curves

Parameters:
  • data (dict) – serialized curve data

  • crv (str) – name of the curve to parent

  • rplStr (list, optional) – String to replace in names. This allow to change the curve names before store it. [old Name to replace, new name to set]

  • model (dagNode, optional) – Model top node to help find the correct parent, if several objects with the same name

mgear.core.curve.curl_curve(crvs, amount=0.3, frequency=10)
mgear.core.curve.evaluate_cubic_nurbs(control_points, percentage, knots=None, weights=None)

Evaluate a cubic NURBS curve at a given percentage.

Parameters:
  • control_points (list) – List of control points, each as [x, y, z].

  • percentage (float) – Curve position as a percentage (0 to 100).

  • knots (list, optional) – Knot vector.

  • weights (list, optional) – List of weights corresponding to control points.

Returns:

Evaluated point as [x, y, z].

Return type:

list

mgear.core.curve.export_curve(filePath=None, objs=None, rplStr=['', ''])

Export the curve data to a json file

Parameters:
  • filePath (None, optional) – Description

  • objs (None, optional) – Description

Returns:

Description

Return type:

TYPE

mgear.core.curve.findLenghtFromParam(crv, param)

Find lengtht from a curve parameter

Parameters:
  • param (float) – The parameter to get the legth

  • crv (curve) – The source curve.

Returns:

Curve uLength

Return type:

float

Example

oParam, oLength = cur.getCurveParamAtPosition(upRope, cv)
uLength = cur.findLenghtFromParam(upRope, oParam)
u = uLength / oLength
mgear.core.curve.getCurveParamAtPosition(crv, position)

Get curve parameter from a position

Parameters:
  • position (list of float) – Represents the position in worldSpace exp: [1.4, 3.55, 42.6]

  • crv (curve) – The source curve to get the parameter.

Returns:

paramenter and curve length

Return type:

list

mgear.core.curve.getParamPositionsOnCurve(srcCrv, nbPoints)

get param position on curve

Parameters:
  • srcCrv (curve) – The source curve.

  • nbPoints (int) – Number of points to return.

Returns:

world positions.

Return type:

tuple

mgear.core.curve.get_color(node)

Get the color from shape node

Parameters:

node (TYPE) – shape

Returns:

Description

Return type:

TYPE

mgear.core.curve.get_uniform_world_positions_on_curve(curve, num_positions)

Get a specified number of uniformly distributed world positions along a NURBS curve.

Parameters:
  • curve (str or PyNode) – The name or PyNode of the NURBS curve.

  • num_positions (int) – The number of uniformly distributed positions to return.

Returns:

A list of tuples, where each tuple represents a world

position (x, y, z).

Return type:

tuple

mgear.core.curve.import_curve(filePath=None, replaceShape=False, rebuildHierarchy=False, rplStr=['', ''])
mgear.core.curve.keep_lock_length_state(func)
mgear.core.curve.keep_point_0_cnx_state(func)
mgear.core.curve.lock_first_point(crv)
mgear.core.curve.lock_length(crv, lock=True)
mgear.core.curve.rebuild_curve(crvs, spans)
mgear.core.curve.set_color(node, color)

Set the color in the Icons.

Parameters:
  • node (dagNode) – The object

  • color (int or list of float) – The color in index base or RGB.

mgear.core.curve.set_thickness(crv, thickness=-1)
mgear.core.curve.smooth_curve(crvs, smooth_factor=1)
mgear.core.curve.straighten_curve(crvs, straighteness=0.1, keep_lenght=1)
mgear.core.curve.update_curve_from_data(data, rplStr=['', ''])

update the curves from a given curve data dict

Parameters:

data (dict) – serialized curve data

mgear.core.curve.update_curve_from_file(filePath=None, rplStr=['', ''])