On 29/09/2015 at 00:11, xxxxxxxx wrote:
Using Customize Commands you can drag the Snap Radius slider to your interface and set the radius there.
How to do this (read and write) using Python?
-Pim
On 29/09/2015 at 00:11, xxxxxxxx wrote:
Using Customize Commands you can drag the Snap Radius slider to your interface and set the radius there.
How to do this (read and write) using Python?
-Pim
On 29/09/2015 at 00:56, xxxxxxxx wrote:
My guess is that it is saved somewhere in the document or world preferences..
I would also be interested in how we can create such a palette icon widget?
On 29/09/2015 at 04:49, xxxxxxxx wrote:
Hi,
you can read the snap radius quite easily. Just get the settings via GetSnapSettings(). In the returned BaseContainer it's c4d.SNAP_SETTINGS_RADIUS. Like so:
bcSnap = c4d.modules.snap.GetSnapSettings(doc)
print bcSnap.GetFloat(c4d.SNAP_SETTINGS_RADIUS)
There's also SetSnapSettings(). But for some reason I can't get it to work in Python. Either I'm too stupid or there's a bug. As I'm alone this week, I'd like to postpone the research. We'll see, if I find the time.
One thing, that the docs do not mention (I'll add it there), you need to fire a special event after setting a new radius, so the snap system recognizes the new value.
This is what works in C++ (here used in a CommandData plugin, needs to include "c4d_snapdata.h") :
BaseContainer bc = SnapSettings(doc); // get current settings
bc.SetFloat(SNAP_SETTINGS_RADIUS, 42.0);
SnapSettings(doc, bc); // set the changed settings
SpecialEventAdd(440000118); // ID_SNAPRADIUS is missing in SDK
@Niklas: Please open a new thread for new topics. In short it is done via a small dialog.
On 29/09/2015 at 05:42, xxxxxxxx wrote:
Thanks.
Could you also update the manual with this information.
In the link you mention, I do not see SNAP_SETTINGS_RADIUS.
-Pim
On 29/09/2015 at 05:46, xxxxxxxx wrote:
Sure, thanks for the hint.
As soon as we have solved the SetSnapSettings() issue, we'll update the Python docs on this topic.
On 30/09/2015 at 02:11, xxxxxxxx wrote:
Hi Andreas,
Sorry, for me it is not working.
I can read, but not write the snap radius.
Here the code converted to Python.
import c4d
from c4d import gui
#Welcome to the world of Python
def main() :
bc = c4d.modules.snap.GetSnapSettings(doc) #get current settings
print bc.GetFloat(c4d.SNAP_SETTINGS_RADIUS)
bc.SetFloat(c4d.SNAP_SETTINGS_RADIUS, 25.0)
c4d.modules.snap.SetSnapSettings(doc, bc) #set the changed settings
c4d.SpecialEventAdd(440000118) #ID_SNAPRADIUS is missing in SDK
c4d.EventAdd()
if __name__=='__main__':
main()
-Pim
On 30/09/2015 at 02:13, xxxxxxxx wrote:
Hi Pim,
did you read my post? That's what I wrote, I couldn't get it to work in Python, either. That's the reason I posted C++ code to the Python forum. We need to investigate... sorry
On 30/09/2015 at 05:48, xxxxxxxx wrote:
Sorry, I guess I did not fully understand until I tried it myself.
Now I see what you mean.
"There's also SetSnapSettings(). But for some reason I can't get it to work in Python".
SetSnapSettings is a python command, which you do not use in your c++ code.
So, c++ is working, but python is not working?
-Pim