c4d.PolygonObject¶
-
class
c4d.
PolygonObject
¶ Represents a Polygon object.
The instance object class of type Opolygon.
See also
Methods Signatures
|
Return the selected polygons. |
|
Return the hidden polygons. |
|
Get the selected edges.
|
|
Get the hidden edges.
|
|
Set a polygon. |
|
Get a polygon. |
|
Change the number of points and polygons in the object.
|
|
Get the phong break edges.
|
|
Gets a translation map from polygon indices to N-gon indices. |
|
Gets a translation map from N-gon indices to polygon indices. |
|
Returns all polygons. |
|
Returns a list with the stored phong normals of the object. |
|
Returns the count of polygons.
|
|
Gets the start of the read-only array of polygons. |
|
Gets the start of the writable array of polygons. |
|
Get the selected, hidden or phong break edges.
|
|
Set the selected, hidden or phong break edges.
|
|
Get the number of N-gons in the object, i.e. the number of polygons with more points than 4. |
|
Copies the current N-gon selection into sel. |
|
Copies the current hidden N-gon selection into sel. |
|
Deselects all selected edges in sel that are N-gon edges. |
|
Deselects all edges in ‘sel’ that are N-gon edges as specified by type. |
|
Retrieves a list that contains N-gon edges information for each polygon.
|
|
Gets the shading break edges based on neighbor polygons shading edges and a specified angle limit.
|
Inheritance
Parent Class:
Methods Documentation
-
PolygonObject.
__init__
(self, pcnt, vcnt)¶ - Parameters
pcnt (int) – Point count.
vcnt (int) – Polygon count.
-
PolygonObject.
GetPolygonS
(self)¶ Return the selected polygons.
- Return type
- Returns
A reference to the selected polygon structure.
-
PolygonObject.
GetPolygonH
(self)¶ Return the hidden polygons.
- Return type
- Returns
A reference to the hidden polygon structure.
-
PolygonObject.
GetEdgeS
(self)¶ - Get the selected edges.The edges are indexed by 4 * polygon + edge where polygon is the polygon index and edge is the edge index between 0 and 3.
Warning
If you change this selection you must make sure that its still valid, so that shared edges have a well-defined selection status.It is safer to useSetSelectedEdges()
.- Return type
- Returns
A reference to the selection of visible edges.
-
PolygonObject.
GetEdgeH
(self)¶ - Get the hidden edges.The edges are indexed by 4 * polygon + edge where polygon is the polygon index and edge is the edge index between 0 and 3.
Note
The edges are only hidden within the editor.
Warning
If you change this selection you must make sure that it is still valid, so that shared edges have a well-defined selection status.It is safer to useSetSelectedEdges()
.- Return type
- Returns
A reference to the selection of hidden edges.
-
PolygonObject.
SetPolygon
(self, id, polygon)¶ Set a polygon.
Note
Call
obj.Message
(c4d.MSG_UPDATE) after you set all your polygons to update the object.- Parameters
id (int) – The index.
polygon (c4d.CPolygon) – The polygon to set at index id.
- Raises
IndexError – If the polygon index id is out of range : 0<=id<
GetPolygonCount()
.
-
PolygonObject.
GetPolygon
(self, id)¶ Get a polygon.
- Parameters
id (int) – The index.
- Raises
IndexError – If the polygon index id is out of range : 0<=id<
GetPolygonCount()
.- Return type
- Returns
The polygon at index id.
-
PolygonObject.
ResizeObject
(self, pcnt, vcnt=- 1)¶ - Change the number of points and polygons in the object.If vcnt is -1 or not set, the method of
PointObject.ResizeObject()
is used.- Parameters
pcnt (int) – The new number of points.
vcnt (int) – The new number of polygons.
- Return type
bool
- Returns
Success of changing the number of points and segments.
-
PolygonObject.
GetPhongBreak
(self)¶ - Get the phong break edges.The edges are indexed by 4 * polygon + edge where polygon is the polygon index and edge is the edge index between 0 and 3.
Warning
If you change this selection you must make sure that its still valid, so that shared edges have a well-defined phong break status.it is safer to useSetSelectedEdges()
.- Return type
- Returns
The phong break.
-
PolygonObject.
GetPolygonTranslationMap
(self)¶ Gets a translation map from polygon indices to N-gon indices.
- Return type
Tuple[int, List[int]]
- Returns
The number of N-gons (and remaining polygons) and the list of N-gon indices. (0, []) if the function failed.
Changed in version R19.024: Was only returning the list of N-gon indices.
Note
The number of n-gon correspond to all N-gons and all remaining polygons which are not part of any N-gons.The list has an amount of entries corresponding to the Cpolygon count of the Polygon Object.Where each number of the list correspond to the Cpolygon id and the value to the N-gon this Cpolygon belongs to.An Abstract example [0, 4] means the CPolygon 0 belongs to the N-gon 0 and the CPolygon 1 belongs to the N-gon 4.
-
PolygonObject.
GetNGonTranslationMap
(self, ngoncnt, polymap)¶ Gets a translation map from N-gon indices to polygon indices.
New in version R19.024.
- Parameters
ngoncnt (int) – The number of N-gons. Pass the number of N-gons returned by
GetPolygonTranslationMap()
, not the value given byGetNgonCount()
.polymap (List[int]) – The polygon map. Pass the list returned by
GetPolygonTranslationMap()
, or a similarly formatted array.
- Return type
Optional[List[List[int]]]
- Returns
The polygon index map if successful, otherwise None.
Note
The number of polygons in N-gon i is stored in List[i][0].Then the polygon indices are stored in List[i][j] where j goes from 1 to List[i][0].
-
PolygonObject.
GetAllPolygons
(self)¶ Returns all polygons.
- Return type
List[c4d.CPolygon]
- Returns
A list of copied polygons.
-
PolygonObject.
CreatePhongNormals
(self)¶ Returns a list with the stored phong normals of the object.
- Return type
Optional[List[c4d.Vector]]
- Returns
The list or None if the object has no Phong Tag.
-
PolygonObject.
GetPolygonCount
(self)¶ - Returns the count of polygons.Is the fastest way to get the count of polygons.
- Return type
int
- Returns
The count.
-
PolygonObject.
GetPolygonR
(self)¶ Gets the start of the read-only array of polygons.
New in version R18.011.
Note
While this function may sound trivial and cheap, internally it is not.For performance reasons, it is not recommended to use this function inside a loop or inside a loop condition.- Return type
PyCObject
- Returns
The start of the read-only polygon array.
-
PolygonObject.
GetPolygonW
(self)¶ Gets the start of the writable array of polygons.
New in version R18.011.
Note
While this function may sound trivial and cheap, internally it is not.For performance reasons, it is not recommended to use this function inside a loop or inside a loop condition.- Return type
PyCObject
- Returns
The start of the writable polygon array.
-
PolygonObject.
GetSelectedEdges
(self, e, ltype)¶ - Get the selected, hidden or phong break edges.The edges are indexed uniquely by a
Neighbor
object, so each edge has a single index.Note
This is a convenience wrapper around
GetEdgeS()
,GetEdgeH()
andGetPhongBreak()
.- Parameters
e (c4d.utils.Neighbor) – The neighbor object with information about the edge topology. Must be initialized with all polygons, i.e. with
Neighbor.Init()
.ltype (int) –
The type of selection to get:
EDGESELECTIONTYPE_SELECTION
Selected edges.
EDGESELECTIONTYPE_HIDDEN
Hidden edges.
EDGESELECTIONTYPE_PHONG
Phong edges.
- Return type
- Returns
The selected edges.
-
PolygonObject.
SetSelectedEdges
(self, e, pSel, ltype)¶ - Set the selected, hidden or phong break edges.The edges are indexed uniquely by a
Neighbor
object, so each edge has a single index.Note
This is a convenience wrapper around
GetEdgeS()
,GetEdgeH()
andGetPhongBreak()
.- Parameters
e (c4d.utils.Neighbor) – The neighbor object with information about the edge topology. Must be initialized with all polygons, i.e. with
Neighbor.Init()
.pSel (c4d.BaseSelect) – The edge to select.
ltype (int) –
The type of selection to get:
EDGESELECTIONTYPE_SELECTION
Selected edges.
EDGESELECTIONTYPE_HIDDEN
Hidden edges.
EDGESELECTIONTYPE_PHONG
Phong edges.
- Return type
bool
- Returns
True if the selection succeeded, otherwise False.
-
PolygonObject.
GetNgonCount
(self)¶ Get the number of N-gons in the object, i.e. the number of polygons with more points than 4.
- Return type
int
- Returns
The number of N-gons for this object.
-
PolygonObject.
GetSelectedNgons
(self, sel)¶ Copies the current N-gon selection into sel.
- Parameters
sel (c4d.BaseSelect) – Assigned the current N-gon selection.
-
PolygonObject.
GetHiddenNgons
(self, sel)¶ Copies the current hidden N-gon selection into sel.
- Parameters
sel (c4d.BaseSelect) – Assigned the current hidden N-gon selection.
-
PolygonObject.
ValidateEdgeSelection
(self, sel)¶ Deselects all selected edges in sel that are N-gon edges.
- Parameters
sel (c4d.BaseSelect) – The selection to check for N-gon edges.
- Return type
bool
- Returns
True if successful, otherwise False.
-
PolygonObject.
GetEdgeSelection
(self, sel, type)¶ Deselects all edges in ‘sel’ that are N-gon edges as specified by type.
- Parameters
sel (c4d.BaseSelect) – The selection to check for N-gon edges.
type (int) –
The type of selection to check:
EDGESELECTIONTYPE_SELECTION
Selected edges.
EDGESELECTIONTYPE_HIDDEN
Hidden edges.
EDGESELECTIONTYPE_PHONG
Phong edges.
- Return type
bool
- Returns
True if successful, otherwise False.
-
PolygonObject.
GetNgonEdgesCompact
(self)¶ - Retrieves a list that contains N-gon edges information for each polygon.The edge compact value is based on the mask 1 << edgeIndex with edgeIndex between 0 - 3 for quads, and 0, 1, 3 for triangles.If the value for a polygon is zero then it has no N-gon edge.Otherwise check each edge of the polygon with edges[polyIndex] & (1 << edgeIndex) == 0 (with edges the list of N-gon edges compact values). If the condition is True then the edge is a N-gon edge.
- Return type
list
- Returns
N-gon edges information list.
-
PolygonObject.
GetShadingBreak
(self, includeBorderEdges, includeUserBreak, includeUserNormals, userNormalsAngle=0.0872665, autoNormalsAngle=3.14159)¶ - Gets the shading break edges based on neighbor polygons shading edges and a specified angle limit.Border edges can optionally be marked as break edges.Current break edges can optionally be included (merged) in the resulting break edges.Finally, user normal vectors can optionally be considered using a separate angle limit for this purpose.
New in version R19.
Note
The edges are indexed by 4 * polygon + edge where polygon is the polygon index and edge is the edge index between 0 and 3.
- Parameters
includeBorderEdges (bool) – True to mark border edges as break edges, otherwise False.
includeUserBreak (bool) – True to include the user break edges (same as obtained with
GetPhongBreak()
), otherwise False.includeUserNormals (bool) – True to consider user normals using the userNormalAngle parameter, otherwise False.
userNormalsAngle (float) – Optional angle limit, in radians, beyond which polygon vertex normals sharing edge vertices create a break edge.
autoNormalsAngle (float) – Optional angle limit, in radians, beyond which polygon normals sharing an edge create a break edge.
- Return type
- Returns
The shading break edges.