Follow me to the Inheritance diagramm.
New in version R14.034.
This is the snap module to access the snap settings, quantizing options, workplane etc.
(You can find the following script in the examples folder)
"""
Snapping Module Example
Example:
c4d.modules.snap
This example shows how to use the snap module functions.
"""
import c4d
from c4d.modules import snap
def main():
# Check snap state
res = snap.IsSnapEnabled(doc)
if not res:
# Enable snap if not activated
snap.EnableSnap(True, doc)
print "Snap Enabled:", snap.IsSnapEnabled(doc)
# Get snap settings
bc = snap.GetSnapSettings(doc)
# Change snap settings
# Set 3D snapping mode
bc[c4d.SNAP_SETTINGS_MODE] = c4d.SNAP_SETTINGS_MODE_3D
snap.SetSnapSettings(doc, bc)
# Check quantizing state
if not bc[c4d.QUANTIZE_ENABLED]:
# Enable quantizing if not activated
c4d.CallCommand(c4d.QUANTIZE_ENABLED)
c4d.EventAdd()
print "Quantize Enabled:", snap.IsQuantizeEnabled(doc)
# Set quantize scale step
snap.SetQuantizeStep(doc, None, c4d.QUANTIZE_SCALE, 0.5)
print "Quantize Scale Step:", snap.GetQuantizeStep(doc, None, c4d.QUANTIZE_SCALE)
# Print workplane object and matrix
print "Workplane Object:", snap.GetWorkplaneObject(doc)
print "Workplane Matrix:", snap.GetWorkplaneMatrix(doc, None)
# Check if workplane is locked
if not snap.IsWorkplaneLock(doc):
# Lock workplane
snap.SetWorkplaneLock(doc.GetActiveBaseDraw(), True)
print "Workplane Locked:", snap.IsWorkplaneLock(doc)
if __name__=='__main__':
main()
Check if snap is enabled for the document doc or for a specific snapmode.
Parameters: |
|
||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | bool |
||||||||||||||||||||||||||||||||||
Returns: | True if snap is enabled, otherwise False. |
Set the snap enabled status for the document doc or a particular snapmode.
Parameters: |
|
---|
Get the snap settings for the document doc or a specific snapmode.
Parameters: |
|
||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | |||||||||||||||||||||||||||||||||||
Returns: | A copy of the settings in a BaseContainer form. See dmodeling.h for more information on the returned container. |
Set the snap settings for the document doc or a specific snapmode.
Parameters: |
|
---|
Check if quantizing is enabled for the document doc.
Parameters: | doc (BaseDocument) – The document to test for. |
---|---|
Return type: | bool |
Returns: | True if quantizing is enabled, otherwise False. |
Get the quantize step values from QUANTIZE_MOVE, QUANTIZE_SCALE etc.
Parameters: |
|
---|
Set the quantize step values for QUANTIZE_MOVE, QUANTIZE_SCALE etc.
Parameters: |
|
---|
Retrieve the workplane object for document doc.
Parameters: | doc (BaseDocument) – The document. |
---|---|
Return type: | BaseObject |
Returns: | The workplane object. |
Get the workplane locked status for document doc.
Parameters: | doc (BaseDocument) – The document. |
---|---|
Return type: | bool |
Returns: | True if the workplane is locked. |
Set the workplane locked status.
Parameters: |
|
---|
Get the workplane matrix.
Parameters: |
|
---|---|
Return type: | |
Returns: | The workplane matrix. |