SculptObject

New in version R15.037.

A SculptObject is what you use to interact with the data referenced by a SculptTag (SculptTag.GetSculptObject()).
The SculptTag on a PolygonObject references a SculptObject that is stored in a scene hook within the document.
When the SculptTag is deleted this SculptObject is also deleted.

Inheritance

Members

SculptObject.GetSubdivisionCount()

Get the number of subdivisions that this sculpt object currently has; i.e. how many times it has been subdivided by the user.

Return type:int
Returns:The number of subdivision levels.
SculptObject.GetPolygonCopy()

Get a copy of the sculpt object at a specific subdivision level.

Return type:c4d.PolygonObject
Returns:The PolygonObject for the subdivision level.
SculptObject.GetOriginalObject()

Get the original PolygonObject that the SculptTag is applied to.

Return type:c4d.PolygonObject
Returns:The original PolygonObject.
SculptObject.GetPolygonCount()

Get the number of polygons at the current subdivision level.

Return type:int
Returns:The number of polygons.
SculptObject.GetPointCount()

Get the number of points at the current subdivision level.

Return type:int
Returns:The number of points.
SculptObject.GetCurrentLevel()

Gets the current subdivision level that the sculpt object is currently at.

Return type:int
Returns:The current subdivision level.
SculptObject.GetMemoryUsage()

Get the amount of memory currently used for this sculpt object. This does not include any memory used by OpenGL.

Return type:int
Returns:The memory used in bytes.
SculptObject.GetCurrentLayer()

Get the currently layer, or folder, selected for this sculpt object.

Return type:c4d.modules.sculpting.SculptLayerBase
Returns:The current sculpt layer or folder.
SculptObject.AddLayer()

Create a new layer on the sculpt object at the current subdivision level.

Return type:c4d.modules.sculpting.SculptLayer
Returns:The sculpt layer added.
SculptObject.AddFolder()

Create a new folder for the sculpt object.

Return type:c4d.modules.sculpting.SculptFolder
Returns:The sculpt folder added.
SculptObject.DeleteSelectedLayer()

Deletes the currently selected layer (or folder) on the sculpt object (as specified in the Sculpting Layer Manager UI).

Note

If the currently selected layer is a folder then it will only delete the folder if all the layers that are contained in that folder are at the same subdivision level as the current subdivion level.

Return type:bool
Returns:True if the layer was deleted, otherwise False.
SculptObject.Update()

Recomposites all the layers and updates the sculpt object.

SculptObject.GetVertexNormal(index)

Get the vertex normal for the polygon object at index and at the current subdivision level.

Parameters:index (int) – The index of the vertex.
Raises:IndexError – If the vertex index is out of range : 0<=index<GetPointCount().
Return type:c4d.Vector
Returns:The vertex normal.
SculptObject.GetFaceNormal(index)

New in version R17.032.

Gets the face normal for the polygon object at index and at the current subdivision level.

Parameters:index (int) – The index of the face.
Raises:IndexError – If the face index is out of range : 0<=index<GetPolygonCount().
Return type:c4d.Vector
Returns:The face normal.
SculptObject.GetPoint(index)

Get read-only access to the point at index that will be used for the polygon object at the current subdivision level.

Parameters:index (int) – The index of the point.
Raises:IndexError – If the point index is out of range : 0<=index<GetPointCount().
Return type:c4d.Vector
Returns:The point.
SculptObject.Subdivide()

Subdivide the sculpt object to the next level.

Note

This method will only work if the sculpt object is already at the top most level and the memory limit (as specified in the preferences) has not been exceeded and also only if there is enough memory on the user’s computer to successfully do the subdivision.

Return type:bool
Returns:True if the object was successfully subdivided, otherwise False.
SculptObject.IncreaseSubdivisionLevel()

Increase the subdivision level to the next highest level. If it is already at the top subdivision level then it will do nothing.

Return type:bool
Returns:True if it was able go up a level, otherwise False.
SculptObject.DecreaseSubdivisionLevel()

Decrease the subdivision level to the down one level. If it is already at level 0 then it will do nothing.

Return type:bool
Returns:True if it was able go down a level, otherwise False.
SculptObject.GetFirstLayer()

Get the first layer. This is usually the Base Object layer.

Return type:c4d.modules.sculpting.SculptLayerBase
Returns:The first layer.
SculptObject.GetBaseLayer()

Get the Base Object layer, which is the special layer that has multiple SculptLayerData children, one for each subdivison level, that allows the user to sculpt on while at any subdivision level.

Return type:c4d.modules.sculpting.SculptLayerBase
Returns:The Base Object layer.
SculptObject.IsFrozen()

Check if the sculpt object is frozen. This is also able to be set on the SculptTag in Cinema 4D’s UI.

Return type:bool
Returns:True if the object is frozen, otherwise False.
SculptObject.SetFrozen(frozen)

Sets the frozen state of the sculpt object. In Cinema 4D UI this is shown in the SculptTag. When the object is frozen no changes to the sculpt object or any of its layers are allowed.

Note

If the polygon object has a Phong tag it will also become active when the sculpt object is frozen. When not Frozen then the sculpt object uses its own internal vertex normals and disables the Phong tag on the polygonobject.

Parameters:frozen (bool) – The frozen state.
SculptObject.GetAllowDeformations()

Check if the object allows to be deformed by any deformers. This is also able to be set on the SculptTag in Cinema 4D’s UI.

Note

This option only works if the object is also frozen. When both these options are enabled, any deformers that are children of the polygon object that the sculpt tag is applied to, will be able to deform the object in the viewport.

Return type:bool
Returns:True if the sculpt object allows deformations, otherwise False.
SculptObject.SetAllowDeformations(allowDef)

Set the Allow Deformations checkbox thereby allowing any deformers to have an effect on the display of the sculpt object, as long as it is also frozen. This option can also be found in the SculptTag’s UI.

Parameters:allowDef (bool) – True to allow deformations, otherwise False.
SculptObject.UpdateCollision()

Updates any collision data after any changes to the sculpt layer offsets have been made. This is required before you call the HitScreen()/HitObject() methods.

SculptObject.NeedCollisionUpdate(fullUpdate)

Tells the sculpt object that it requires a collision update before the user tries to use any of the sculpt tools. Then next time a user tries to use a tool it will first call UpdateCollision() to ensure that the HitScreen()/HitObject() calls will be correct.

Parameters:fullUpdate (bool) – Set to True to update the full mesh. This is not always required.
SculptObject.HitScreen(bd, mx, my, backfaces)

From a viewport cast a ray, in screen space, onto the sculpt object and return any data if the ray hits the object. This will return the closest hit point if multiple intersections are found.

Note

To use the Hit functions the mesh must be unfrozen and both NeedCollisionUpdate(True) and UpdateCollision() should be called to initialize the collision data.

Parameters:
  • bd (c4d.BaseDraw) – The BaseDraw that the user is casting the ray from.
  • mx (float) – The X coordinate (i.e. mouse coordinate) in screen space.
  • my (float) – The Y coordinate (i.e mouse coordinate) in screen space.
  • backfaces (bool) – Allow back facing polygons to be hit tested.
Return type:

dict{distance: float, normal: Vector, point: Vector, polygon: int}

Returns:

The intersection data will be returned if the object was hit:

distance: The distance from the ray point. normal: The normal of the hitpoint on the surface of the object in its local coordinate system. point: Location of the hit point on the surface of the object in its local coordinate system. polygon: The polygon that was hit.

SculptObject.HitObject(rayp, rayv, backfaces)

Given a ray in object space do a hit intersection against the sculpt object and return any data if the ray hits the object. This will return the closest hit point if multiple intersections are found.

Note

To use the Hit functions the mesh must be unfrozen and both NeedCollisionUpdate(True) and UpdateCollision() should be called to initialize the collision data.

Parameters:
  • rayp (c4d.Vector) – The starting position of the ray in object space.
  • rayv (c4d.Vector) – The direction the ray is pointing.
  • backfaces (bool) – Allow back facing polygons to be hit tested.
Return type:

dict{distance: float, normal: Vector, point: Vector, polygon: int}

Returns:

The intersection data will be returned if the object was hit:

distance: The distance from the ray point. normal: The normal of the hitpoint on the surface of the object in its local coordinate system. point: Location of the hit point on the surface of the object in its local coordinate system. polygon: The polygon that was hit.

SculptObject.StartUndo()

Call before any calls to AddOffset(), SetOffset(), AddToMask() or SetMask() if you wish it to be undone. This will only work if you are only making changes to a single layer. Changes to multiple layers or layers at different levels is not allowed.

Note

The method EndUndo() must be called after all calls to the above functions have been done.

SculptObject.EndUndo()

Must be called after StartUndo() once all the points and masks have been changed on the layers.

SculptObject.Smooth(count, respectMask)

Smooth the sculpt object and apply the offsets to the currently selected layer.

Parameters:
  • count (int) – The number of times to run the smooth algorithm.
  • respectMask (bool) – True to not smooth any masked out points, False to apply it to every point.
SculptObject.GetMaskCachePoint(id)

New in version R16.021.

Gets the mask value from the mask cache.

Parameters:id (int) – The index of the point.
Raises:IndexError – If the point index is out of range : 0<=index<GetPointCount().
Return type:float
Returns:The mask cache value.
SculptObject.UpdateMask(fullUpdate)

New in version R16.021.

Updates the mask on the sculpt object.

Parameters:fullUpdate (bool) – Pass True to force a full update of the mask.
SculptObject.InitOpenGL(bd)

New in version R16.021.

Initializes the sculpt object for the given viewport for OpenGL use. Private.

Parameters:bd (c4d.BaseDraw) – The viewport that is being updated. If None then the currently active view will be used.
SculptObject.IsPointSelected(index)

New in version R16.021.

For use in the SculptBrushToolData.FloodSelectedLayer() method to determine if a point should be moved or not.
When in Point Mode, and there is a selection, it returns True if a point is selected or False if the point is not selected. If there are no points selected it returns True.
When in Polygon Mode, and there is a selection, it returns True if a point on any of the selected polygons is selected or False if there is no point selected. If there are no polygons selected it returns True.
It returns False in all other cases.

Note

This method only works when the selected object being sculpted on is by a tool and is a Polygon Object without a SculptTag.

Parameters:index (int) – The index of the point.
Raises:IndexError – If the point index is out of range : 0<=index<GetPointCount().
Return type:bool
Returns:True if the point was selected, False if not.
SculptObject.IsPolygonSelected(index)

New in version R16.021.

For use in the SculptBrushToolData.FloodSelectedLayer() method to determine if a point should be moved or not.
When in Polygon Mode, and there is a selection, it returns True if a point on any of the selected polygons is selected or False if there is no point selected.
If there are no polygons selected it returns True. It returns False in all other cases.

Note

This method only works when the selected object being sculpted on is by a tool and is a Polygon Object without a SculptTag.

Parameters:index (int) – The index of the polygon.
Raises:IndexError – If the polygon index is out of range : 0<=index<GetPolygonCount().
Return type:bool
Returns:True if the polygon was selected, False if not.
SculptObject.GetPolygon(index)

New in version R16.021.

Gets the Polygon at the given index.

Parameters:index (int) – The index of the polygon.
Raises:IndexError – If the polygon index is out of range : 0<=index<GetPolygonCount().
Return type:c4d.CPolygon
Returns:The Polygon if it was found, otherwise None.
SculptObject.GetDisplayPolygonObject()

New in version R16.021.

Retrieves the Polygon Object that is currently being displayed in the viewport.
This is the internal Polygon Object and should never be changed.

Note

In SculptBrushToolData.FloodSelectedLayer() calls it returns the same as GetOriginalObject() when sculpting on a Polygon Object that have no SculptTag.

Return type:c4d.PolygonObject
Returns:The Polygon Object displayed in the viewport.