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=<sphinx.ext.autodoc.importer._MockObject object>)¶ 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.
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.
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.
curl_curve
(crvs, amount=0.3, frequency=10)¶
-
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=['', ''])¶