c4d.utils.ViewportSelect
¶
This class is used to extract information from a viewport about which objects and object elements are visible at which pixels. It is used internally for stuff like highlighting and modeling.
c4d.utils.
ViewportSelect
¶
ViewportSelect.GetPixelInfoPoint()
ViewportSelect.GetPixelInfoPolygon()
ViewportSelect.GetPixelInfoEdge()
ViewportSelect.
__init__
(
)
¶
Return type: | c4d.utils.ViewportSelect |
---|---|
Returns: | A new viewport select object. |
ViewportSelect.
Init
(
w
,
h
,
bd
,
ops
,
mode
,
onlyvisible
,
flags
)
¶
Initializes the viewport information for multiple objects. This has to be done before the pixel information can be retrieved. You have to retrieve the width and height of the viewport manually:
frame = bd.GetFrame() left = frame["cl"] right = frame["cr"] top = frame["ct"] bottom = frame["cb"] width = right - left + 1 height = bottom - top +1 viewportSelect.Init(width, height, bd, [op], c4d.Mpolyedgepoint, True, c4d.VIEWPORTSELECTFLAGS_IGNORE_HIDDEN_SEL)
Parameters: |
|
---|
ViewportSelect.
GetPixelInfoPoint
(
x
,
y
)
¶
Retrieves point information at the pixel position ( x , y ):
viewportSelect = utils.ViewportSelect() infopoint = viewportSelect.GetPixelInfoPoint(x, y) if not infopoint: return i = infopoint["i"] #int op = infopoint["op"] #c4d.BaseObject z = infopoint["z"] #float
Parameters: | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
dict{
i
: int,
op
:
|
||||||||||||||||||||||||||||
Returns: |
The retrieved pixel information or None if no information could be retrieved. |
ViewportSelect.
GetPixelInfoPolygon
(
x
,
y
)
¶
Retrieves polygon information at the pixel position ( x , y ):
infopolygon = viewportSelect.GetPixelInfoPolygon(x, y) if not infopolygon: return i = infopolygon["i"] #int op = infopolygon["op"] #c4d.BaseObject z = infopolygon["z"] #float
Parameters: | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
dict{
i
: int,
op
:
|
||||||||||||||||||||||||||||
Returns: |
The retrieved pixel information or None if no information could be retrieved. |
ViewportSelect.
GetPixelInfoEdge
(
x
,
y
)
¶
Retrieves edge information at the pixel position ( x , y ):
infopoint = viewportSelect.GetPixelInfoPoint(x, y) if not infopoint: return i = infopoint["i"] #int op = infopoint["op"] #c4dBaseObject z = infopoint["z"] #float
Parameters: | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
dict{
i
: int,
op
:
|
||||||||||||||||||||||||||||
Returns: |
The retrieved pixel information or None if no information could be retrieved. |
ViewportSelect.
GetNearestPoint
(
op, x, y[, maxrad=MAXLONGl][, onlyselected=False][, ignorelist=None][, ignorecnt=0]
)
¶
Retrieves nearest point information at the pixel position ( x , y ).
Parameters: |
|
||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
dict{
i
: int,
op
:
|
||||||||||||||||||||||||||||||||||||
Returns: |
The retrieved pixel information or None if no information could be retrieved. |
ViewportSelect.
GetNearestPolygon
(
op, x, y[, maxrad=MAXLONGl][, onlyselected=False][, ignorelist=None][, ignorecnt=0]
)
¶
Retrieves nearest polygon information at the pixel position ( x , y ).
Parameters: |
|
||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
dict{
i
: int,
op
:
|
||||||||||||||||||||||||||||||||||||
Returns: |
The retrieved pixel information or None if no information could be retrieved. |
ViewportSelect.
GetNearestEdge
(
op, x, y[, maxrad=MAXLONGl][, onlyselected=False][, ignorelist=None][, ignorecnt=0]
)
¶
Retrieves nearest edge information at the pixel position ( x , y ).
Parameters: |
|
||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
dict{
i
: int,
op
:
|
||||||||||||||||||||||||||||||||||||
Returns: |
The retrieved pixel information or None if no information could be retrieved. |
ViewportSelect.
DrawPolygon
(
p
,
i
,
op
[
,
onlyvisible=-1
]
)
¶
Draws a polygon into the internal pixel structure, so that pixels inside the polygon will be associated with i and op in the viewport pixel retrieved.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if successfull, otherwise False . |
ViewportSelect.
DrawHandle
(
p
,
i
,
op
[
,
onlyvisible=-1
]
)
¶
Draws a handle into the internal pixel structure, so that pixels inside the handle will be associated with i and op in the viewport pixel retrieved.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if successfull, otherwise False . |
ViewportSelect.
ShowHotspot
(
bw
,
x
,
y
)
¶
Draws an XOR circle to the view
bw
at the pixel position (
x
,
y
). The radius is set by
SetBrushRadius()
.
Parameters: |
|
---|
ViewportSelect.
SetBrushRadius
(
r
)
¶
Sets the radius for
ShowHotspot()
.
Parameters: | r ( float ) – The new radius in pixels. |
---|
ViewportSelect.
ClearPixelInfo
(
x
,
y
,
mask
)
¶
Deletes the pixel information at ( x , y ) according to mask.
This is used for example in the live edge selection with “tolerant” deactivated to find out how many pixels of a certain edge was selected. If an edge is determined under the cursor, the pixel counter is decremented and the edge information is deleted afterwards.
Parameters: |
|
---|
ViewportSelect.
GetCameraCoordinates
(
x
,
y
,
z
)
¶
Converts the pixel position ( x , y , z ) to camera coordinates.
Parameters: |
|
---|---|
Return type: | |
Returns: |
The calculated camera coordinate. |
ViewportSelect.
PickObject
(
bd
,
doc
,
x
,
y
,
rad
,
flags
)
¶
Pick objects.
Parameters: |
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
list[
|
||||||||||||||||
Returns: |
Object list or None on failure. |
Enter search terms or a module, class or function name.