mgear.core.curve

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=Matrix([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]))

Create a NurbsCurve with a single subcurve.

Parameters:
  • parent (dagNode) – Parent object.
  • name (str) – Name
  • positions (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.
Returns:

The newly created curve.

Return type:

dagNode

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)

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.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.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.export_curve(filePath=None, objs=None)

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.get_color(node)

Get the color from shape node

Parameters:node (TYPE) – shape
Returns:Description
Return type:TYPE
mgear.core.curve.import_curve(filePath=None, replaceShape=False, rebuildHierarchy=False, rplStr=['', ''])
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.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=['', ''])