To get an overview of the class members, check out the diagram.
|
c4d.utils.noise |
With this function one can apply nearly all modeling commands. The function is applied to the objects in list. With the parameter mode you can decide if the current selection should be used to control what points/polygons are affected.
This is a small example how you can use this function:
import c4d
from c4d import utils
from c4d import documents
settings = c4d.BaseContainer() # settings
settings[2033] = 50.0 # length of the extrusion. 'id' taken from toolextrude.h
document = documents.GetActiveDocument()
return_value = utils.SendModelingCommand(
command = utils.ID_MODELING_EXTRUDE_TOOL,
list= [document.GetFirstObject()], # don't forget to set the correct objects
mode=utils.MODIFY_POLYGONSELECTION, # mode
bc=settings,
doc = document)
if return_value is False:
print "Something went wrong"
elif return_value is True:
print "Command successfull"
elif isinstance(return_value, list):
print "Here you get the new created object"
| Parameters: |
|
||||||||
|---|---|---|---|---|---|---|---|---|---|
| Return type: | False, True or list of BaseObject's |
||||||||
| Returns: | Returns True if the command succeeded, otherwise False if something went wrong. Some commands don’t apply their task to the passed objects. They return a cloned object so just check for this, too. |
Calculates the angle of two vectors.
| Parameters: | |
|---|---|
| Return type: | float |
| Returns: | The angle. |
Map the value of a range to another. Similiar to the RangeMapper Node. Here is a small example:
print range_map(value=0.5, mininput=0, maxinput=1, minoutput=5, maxoutput=10, clampval=False)
#Output: 7.5
print range_map(value=0.5, mininput=0, maxinput=1, minoutput=5, maxoutput=10, clampval=True)
#Output: 30
| Parameters: |
|
|---|
Convert a degrees value into radians.
| Parameter: | r (number) – Input value in degrees. |
|---|---|
| Return type: | number |
| Returns: | Converted value in degrees. |
Convert a radians value into degrees.
| Parameter: | r (number) – Input value in degrees. |
|---|---|
| Return type: | number |
| Returns: | Converted value in degrees. |
Returns a mixed value of v1 and v2 using the parameter t, as calculated by v1+(v2-v1)*t.
| Parameters: |
|
|---|---|
| Math: | 0 < t < 1.0 |
| Return type: | float |
| Returns: | Mix amount, with 0 <= t <= 1.0. |
Mixes the two vectors together, such as mixing two colours.
| Parameters: | |
|---|---|
| Math: | 0 < t < 1.0 |
| Return type: | |
| Returns: | The mixed vector. |
Mixes two numbers together.
| Parameters: |
|
|---|---|
| Math: | 0 < t < 1.0 |
| Return type: | number |
| Returns: | The mixed number. |
Returns 1.0 if x is between or equal to either of a and b, else 0.0.
| Parameters: |
|
|---|---|
| Return type: | float |
| Returns: | The pulse value. |
Returns a if x is less than a and b if x is greater than b, else returns x.
| Note: | The order of parameters different to Peachey’s definition. |
|---|---|
| Parameters: |
|
| Return type: | float |
| Returns: | The clamped value. |
Returns 1.0 if x is greater than or equal to a, else 0.0.
| Parameters: |
|
|---|---|
| Return type: | float |
| Returns: | The step value (1.0 or 0.0). |
Returns 0.0 if x is less than a and 1.0 if x is greater than b, else returns x mapped on the range [a,b] (a number between 0.0 and 1.0). The mapping is smoothed using an ease-in/ease-out curve.
| Parameters: |
|
|---|---|
| Return type: | float |
| Returns: | The smoothed value. |
Returns 0.0 if x is less than a and 1.0 if x is greater than b, else returns x mapped on the range [a,b] (a number between 0.0 and 1.0).
| Parameters: |
|
|---|---|
| Return type: | float |
| Returns: | The stepped value. |
Creates a rotation matrix about the X axis.
| Parameter: | w (float) – The angle around X. |
|---|---|
| Return type: | Matrix |
| Returns: | The rotation matrix. |
Creates a rotation matrix about the Y axis.
| Parameter: | w (float) – The angle around Y. |
|---|---|
| Return type: | Matrix |
| Returns: | The rotation matrix. |
Creates a rotation matrix about the Z axis.
| Parameter: | w (float) – The angle around Z. |
|---|---|
| Return type: | Matrix |
| Returns: | The rotation matrix. |
Calculates rotation axis and angle from matrix m:
v, w = MatrixToRotAxis(m)
#v is the rotation axis, c4d.Vector
#w is the rotation angle, float
| Parameter: | m (Matrix) – Rotation matrix. |
|---|---|
| Return type: | list |
| Returns: | The rotation axis, and the angle. |
Modify hpb_new so that the “distance” to the last angle hpb_old is at minimum. This helps to avoid HPB singularity effects.
| Parameter: | hpb_old (Vector) – The old HPB. |
|---|
:param hpb_new The new HPB. :rtype: Vector :return: The optimal angle.
Calculates the distance from a point to a line.
| Parameters: | |
|---|---|
| Return type: | |
| Returns: | Point-line vector. |
Find the ray vector after a reflection about a surface normal.
| Parameters: |
|---|
Calculates the value of a spline at a point.
| Parameters: |
|
|---|---|
| Return type: | float |
| Returns: | The spline value. |
Calculates the value of a spline at a point.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The spline value. |
Converts RGB into the HSV color space and returns the converted value.
| Parameter: | col (Vector) – RGB color. |
|---|---|
| Return type: | Vector |
| Returns: | HSV color. |
Converts HSV into the RGB color space and returns the converted value.
| Parameter: | col (Vector) – HSV color. |
|---|---|
| Return type: | Vector |
| Returns: | RGB color. |
Check if vector v1 and v2 are within epsilon of each other.
| Parameters: | |
|---|---|
| Return type: | bool |
| Returns: | True if the vectors are equal. |
Returns the bias as the defined in the book “Texturing and Modeling” by Ebert.
The internal code:
def Bias(b, x):
return math.pow(x, -ln(b) / 0.693147180559945)
| Parameters: |
|
|---|---|
| Return type: | float |
| Returns: | The bias. |
Limit the value of a to between b and c.
| Parameters: |
|
|---|
Limit a color vector between 0.0 and 1.0.
| Parameter: | vec (Vector) – Bias value. |
|---|---|
| Return type: | Vector |
| Returns: | The limited color vector. |
Limit a color vector between 0.0 and 1.0.
The internal code:
def truncate(x):
if x >= 0.0:
return floor(x)
else:
return ceil(x)
| Parameter: | x (number) – The value to truncate. |
|---|---|
| Return type: | Vector |
| Returns: | The truncated value. |
Sum the vector components.
| Parameter: | x (Vector) – A color |
|---|---|
| Return type: | float |
| Returns: | The sum of the components. |
Sum the vector components and multiply by 1/3.
| Parameter: | vec (Vector) – A color |
|---|---|
| Return type: | float |
| Returns: | The gray value. |
Calculates the angle between two vectors in radians.
| Parameters: | |
|---|---|
| Return type: | float |
| Returns: | The angle in radians. |
Find the minimum component of the vector.
| Parameter: | vec (Vector) – The vector to find the minimum component of. |
|---|---|
| Return type: | float |
| Returns: | The minimum component of the vector. |
Find the maximum component of the vector.
| Parameter: | vec (Vector) – The vector to find the maximum component of. |
|---|---|
| Return type: | float |
| Returns: | The maximum component of the vector. |
Create a translation matrix.
| Parameter: | vec (Vector) – The translation vector. |
|---|---|
| Return type: | Matrix |
| Returns: | The translation matrix. |
Create a scaling matrix.
| Parameter: | vec (Vector) – The scaling vector for the axes. |
|---|---|
| Return type: | Matrix |
| Returns: | The scaling matrix. |
Calculate euler angles from the vector p. The bank is always set to 0.0.
| Parameter: | vec (Vector) – The rotation HPB. |
|---|---|
| Return type: | Vector |
| Returns: | The vector to find the HPB for. |
Calculate euler angles from the matrix m.
| Parameter: | vec (Vector) – The rotation HPB. |
|---|---|
| Return type: | Matrix |
| Returns: | The rotation matrix. |
Construct matrix from the euler angles hpb.
| Parameters: |
|
||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||
| Returns: | The rotation matrix. |
This is a helper function to modify a user chosen subdivision value. For example:
sub = CalcLOD(op[TUBEOBJECT_SUB, 1], hh["lod"], 1, 1000)
| Parameters: |
|
|---|
Compares if two floats are close to each other on a bit basis (rather than a fixed epsilon).
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if a and b are sufficiently close to each other, otherwise False. |
Get sine and cosine of w:
sn, cs = SinCos(80)
| Parameter: | w (float) – Value. |
|---|---|
| Return type: | list |
| Returns: | Sine and Cosine |
There are several groups of IDs to use:
MCOMMAND_SPLINE_HARDINTERPOLATION Hard interpolation MCOMMAND_SPLINE_SOFTINTERPOLATION Soft Interpolation MCOMMAND_SPLINE_REORDER Set first point MCOMMAND_SPLINE_REVERSE Reverse sequence MCOMMAND_SPLINE_MOVEDOWN Move down sequence MCOMMAND_SPLINE_MOVEUP Move up sequence MCOMMAND_SPLINE_JOINSEGMENT Join segment MCOMMAND_SPLINE_BREAKSEGMENT Break segment MCOMMAND_SPLINE_EQUALLENGTH Equal tangent length MCOMMAND_SPLINE_EQUALDIRECTION Equal tangent directio MCOMMAND_SPLINE_LINEUP Line up MCOMMAND_SPLINE_CREATEOUTLINE Create outline MCOMMAND_SPLINE_PROJECT Project MCOMMAND_SPLINE_ADDPOINT Add point MCOMMAND_SELECTALL Select all MCOMMAND_DESELECTALL Deselect all MCOMMAND_SELECTINVERSE Invert selection MCOMMAND_SELECTCONNECTED Select connected MCOMMAND_SELECTGROW Grow selection MCOMMAND_SELECTSHRINK Shrink selection MCOMMAND_SELECTPOINTTOPOLY Polygon selection from points MCOMMAND_SELECTPOLYTOPOINT Point selection from polygons MCOMMAND_SELECTADJACENT Select adjacent MCOMMAND_GENERATESELECTION Set selection MCOMMAND_HIDESELECTED Hide selected MCOMMAND_HIDEUNSELECTED Hide unselected MCOMMAND_HIDEINVERT Invert visibility MCOMMAND_UNHIDE Unhide all MCOMMAND_REVERSENORMALS Reverse normals MCOMMAND_ALIGNNORMALS Align normals MCOMMAND_SPLIT Split MCOMMAND_TRIANGULATE Triangulate MCOMMAND_UNTRIANGULATE Untriangulate MCOMMAND_DELETE Delete MCOMMAND_OPTIMIZE Optimize MCOMMAND_DISCONNECT Disconnect MCOMMAND_MAKEEDITABLE Make editable (returns object) MCOMMAND_MIRROR Mirror MCOMMAND_MATRIXEXTRUDE Matrix extrude. See toolmatrixextrude.h. MCOMMAND_SUBDIVIDE Subdivide MCOMMAND_EXPLODESEGMENTS Explode segments MCOMMAND_KNIFE Knife. See toolknife.h. MCOMMAND_CURRENTSTATETOOBJECT Current state to object (returns object) MCOMMAND_JOIN Join (returns object) MCOMMAND_CONVERTSELECTION Convert selection MCOMMAND_EDGE_TO_SPLINE Edge to spline MCOMMAND_BREAKPHONG Break phong. MCOMMAND_UNBREAKPHONG Unbreak phong. MCOMMAND_PHONGTOSELECTION Phong to selection. MCOMMAND_MELT Melt. MCOMMAND_RESETSYSTEM Reset System. Further modelling tools:
ID_MODELING_EDGECUT_TOOL Edge cut tool. See tooledgecut.h. ID_MODELING_FILL_SELECTION_TOOL Fill selection tool. ID_MODELING_OUTLINE_SELECTION_TOOL Outline selection tool. ID_MODELING_LOOP_TOOL Loop selection tool. See toolloopselection.h. ID_MODELING_RING_TOOL Ring selection tool. ID_MODELING_EXTRUDE_TOOL Extrude tool. See toolextrude.h. ID_MODELING_MELT_COMMAND Melt. ID_CONVERT_SELECTION_TOOL Normal move tool. See toolnormalmove.h. ID_VIEW_SCENEHOOKHIGHLIGHT Normal scale tool. See toolnormalscale.h. ID_VIEW_SCENEHOOKHUD Normal rotate tool. See toolnormalrotate.h. ID_MODELING_EDGE_SPLINE_COMMAND Smooth shift tool. See toolsmoothshift.h. ID_MODELING_MATRIX_EXTRUDE_TOOL Matrix extrude tool. See toolmatrixextrude.h. ID_MODELING_NORMALMOVE_TOOL Normal move tool. See toolnormalmove.h. ID_MODELING_NORMALSCALE_TOOL Normal scale tool. See toolnormalscale.h. ID_MODELING_NORMALROTATE_TOOL Normal rotate tool. See toolnormalrotate.h. ID_MODELING_SMOOTH_SHIFT_TOOL Smooth shift tool. See toolsmoothshift.h. ID_MODELING_EXTRUDE_INNER_TOOL Extrude inner tool. See toolextrudeinner.h. ID_MODELING_BEVEL_TOOL Bevel tool. See toolbevel.h. ID_MODELING_COLLAPSE_COMMAND Collapse. ID_MODELING_POLYGON_CREATE_TOOL Create polygon tool. See toolcreatepolygon.h. ID_MODELING_POINT_ADD_TOOL Add point tool. See tooladdpoint.h. ID_MODELING_BRIDGE_TOOL Bridge tool. See toolbridge.h. ID_MODELING_WELD_TOOL Weld tool. See toolpointweld.h. ID_MODELING_CLOSEHOLE_TOOL Close polygon hole tool. See toolclosehold.h. ID_MODELING_STITCHANDSEW_TOOL Stich and sew tool. See toolstitchandsew.h. ID_MODELING_SLIDE_TOOL Slide tool. See toolslide.h. ID_MODELING_IRON_TOOL Iron tool. See tooliron.h. ID_MODELING_SETVALUE_TOOL Set value tool. See toolsetvalue.h. ID_MODELING_DUPLICATE_TOOL Duplicate tool. See toolduplicate.h. ID_MODELING_ARRANGE_TOOL Arrange tool. See toolarrange.h. ID_MODELING_TRANSFER_TOOL Transfer tool. See tooltransfer.h. ID_MODELING_RANDOMIZE_TOOL Randomize tool. See toolrandomize.h. ID_MODELING_CENTER_TOOL Center tool. See toolcenter.h. ID_MODELING_KNIFE_TOOL Knife tool. See toolknife.h. ID_MODELING_LIVESELECTION Live selection tool. See toolliveselection.h. ID_MODELING_RECTSELECTION Rectangle selection tool. See toolrectselection.h. ID_MODELING_FREESELECTION Free selection tool. See toolfreeselection.h. ID_MODELING_POLYSELECTION Polygon selection tool. See toolpolyselection.h. ID_MODELING_SPLINE_ROUND_TOOL Spline round tool. See toolsplineround.h. ID_MODELING_CLONE_TOOL Clone tool. See toolclone.h. ID_MODELING_SPLINE_CHAMFER_TOOL Spline chamfer tool. See toolsplinechamfer.h. ID_MODELING_ARRAY_TOOL Array tool. See toolarray.h. ID_MODELING_SPLINE_PROJECT_TOOL Spline project tool. See toolsplineproject.h. ID_MODELING_MODIFY_TOOL Modify tool. See toolmodify.h. ID_MEASURE_TOOL Measure tool. See toolmeasure.h. ID_MODELING_BRUSH_TOOL Brush tool. See toolbrush.h. ID_MODELING_OM_SELECT_INVERT Invert object manager selection. Finally there are the modeling library menu commands. These have no parameters:
ID_NGON_RETRI_MENU Retriangulate N-gons. ID_NGON_REMOVE_MENU Remove N-gons. ID_NGON_FORCERETRI_MENU Force N-gon triangulation. ID_OBJECTHANDLES_ONOFF_MENU Object handles toggle. ID_SDS_INC_MENU Increment SDS. ID_SDS_DEC_MENU Decrement SDS. ID_SDS_ONFFF_MENU Toggle SDS. ID_MODELING_OM_SELECT_HIDE Hide selected objects. ID_MODELING_OM_SELECT_SHOW Show selected objects. ID_MODELING_SHORTCUT_SELECTVISIBLE Toggle select visible.