@zipit Thanks for looking at this.
(1) ok - I haven't consulted version documentations before R21, so I don't know how the snap settings used to work in prehistoric times. I'm going to ignore these constants.
(2) hmm, this explanation is hard to understand without looking at the underlying code, and I don't quite see the connection to the explanation in the docs either. The BaseDocument is already another parameter in the function call for SetSnapSettings, so it's clear that this container is a valid target for the settings. We also have the "Tool Specific" flag that allows us to set snap settings per tool, so these would have their own snap settings container - however, the parameter snapmode defines a snapmode and not a tool.
(I would be less surprised if snapmode was a tool ID, like a call SetSnapSettings(doc,bc,c4d.ID_MODELING_MOVE)
which I could identify as "set these snap settings as local parameters when the Move tool is active, so this is used when "Tool Specific" is active. But ID_MODELING_MOVE
is not a snapmode! -- I even tried that in spite of the documentation, but it doesn't do anything.)
From a practical standpoint, if I execute the following script in R23.1:
import c4d
from c4d import gui, utils, modules
from c4d.modules import snap
def main():
bc = c4d.BaseContainer()
bc[c4d.SNAP_SETTINGS_ENABLED] = True
bc[c4d.SNAP_SETTINGS_RADIUS] = 15
snap.SetSnapSettings(doc, bc, c4d.SNAPMODE_POINT)
c4d.EventAdd()
if __name__=='__main__':
main()
then the Vertex checkbox will be checked, and all the other parameters will be ignored (enabled and radius). I see no way that the GUI (can't look at the underlying system, of course) would use these settings in any form.
Maybe that parameter is used internally for very specific purposes, but from a user's perspective, the explanation given in the docs for the parameter snapmode is plain wrong and suggests a behavior that doesn't happen.
(3) The simplest of all settings (R23.1):
bc = c4d.BaseContainer()
bc[c4d.SNAP_SETTINGS_ENABLED] = True
bc[c4d.SNAP_SETTINGS_TOOL] = True
snap.SetSnapSettings(doc, bc)
The "Enable Snapping" checkbox gets checked; the "Tool Specific" checkbox does not. The same happens if I explicitly set the parameter NOTOK
. All other snapmodes, like SNAPMODE_POINT
, completely ignore the BaseContainer anyway, as mentioned in point (2).
Meanwhile (after your reply) I tested whether calling c4d.SpecialEventAdd(440000118)
would make a difference, but it doesn't.
Using EnableSnap
doesn't work either, I didn't expect it to but just for completeness' sake:
snap.EnableSnap(True, doc, c4d.SNAP_SETTINGS_TOOL)
c4d.SpecialEventAdd(440000118)
c4d.EventAdd()
I have not yet tried to modify the document's GetSettingsInstance() container directly, but all other tests simply don't acknowledge the SNAP_SETTINGS_TOOL
.
(4) The snap core, as documented in the c4d.modules.snap
documentation, covers four functional areas: snap, quantize, mesh check, and workplane. Three of them are mentioned in the class docs: snap, quantize, and workplane. Mesh check is ignored.
Granted, mesh check does not have any special unique functions in this class, but it uses SetSnapSettings
to set its parameters:
import c4d
from c4d import gui, utils, modules
from c4d.modules import snap
def main():
bc = c4d.BaseContainer()
bc[c4d.MESH_CHECK_ENABLED] = True
bc[c4d.MESH_CHECK_POINT] = True
bc[c4d.MESH_CHECK_EDGEPOINT_THRESHOLD] = utils.DegToRad(90.0)
bc[c4d.MESH_CHECK_EDGEPOINT] = True
snap.SetSnapSettings(doc, bc)
c4d.EventAdd()
if __name__=='__main__':
main()
so I would expect the constants to be listed there. The quantize constants are!
In fact, I remember the topic from some forum a few years ago: Before you (Maxon) started to list the constants from header files automatically, the mesh check constants and their relationship to the snap core weren't listed in the docs at all. Since the R23 docs, you can at least find the constants, and logically derive how they may be set practically. Nevertheless, I would expect them to be listed under SetSnapSettings
like all others that belong to the snap core.
Speaking of constants, since the R23 it is also possible to set the snapmode checkboxes through SetSnapSettings:
bc[c4d.SNAPMODE_POINT] = True
(which hard crashes C4D in R21, btw) instead of using EnableSnap
. This has also not made its way into the docs (or maybe that wasn't intended to work?).
(5) Okay, I will use that call in addition. But I don't see what that function does there... According to the Customize Command window, 440000118 belongs to "Snap Radius Slider" with the description "Icon Palette GUI to control the screen space radius of snapping". Does this constant have a different meaning when I use it in SpecialEventAdd()
? What is C4D doing internally?
Also, while checking this, I tried to add the Snap Radius Slider to a toolbar that I added to the Attribute Manager:
As you can see, this Snap Radius does not follow the Snap Radius in the Attribute Manager, and vice versa. Is that not the same setting? Is that a bug?