8
$\begingroup$

I have a 3DConnexion SpaceNavigator. It works very well for moving the viewport. Is there a way for it to place an object in the scene?

Is this something that can be accomplished via an addon? I am new to Blender, I'm delighted that the NDOF works out of the box, but I expect to be able to place objects using it. Would be much more intuitive than using a mouse.

So far I have setup a ViewOperator template and I can see that moving the 3D mouse yields a NDOF_MOTION event

def modal(self, context, event):
        v3d = context.space_data
        rv3d = v3d.region_3d

        if event.type == 'NDOF_MOTION':
            print(event)

blender console when moving the 3d mouse: <bpy_struct, Event at 0x000001B72D13B5F8>

I can see how I might write a script to move an object given the motion event. The problem is I can not find any way to get data from the event. I am expecting some translation/rotation vectors but those properties don't seem to exist on the Event object.

I believe the c implementation to move the viewport is here: ndof_orbit_zoom_invoke() in https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/space_view3d/view3d_edit.c

const wmNDOFMotionData *ndof = event->customdata;

There is no customdata on the event when it gets to my python script.

Which makes sense because there is no mention of any relevant data in rna_def_event() here: https://developer.blender.org/diffusion/B/browse/master/source/blender/makesrna/intern/rna_wm.c

$\endgroup$
  • $\begingroup$ Did you ever figure this out? We are very interested in using the 3D mouse to move models in the scene. $\endgroup$ – Madcowswe Mar 12 '18 at 2:03
  • 2
    $\begingroup$ @Madcowswe No, unfortunately. This caused me to lose interest in Blender and I've since moved on. $\endgroup$ – meta-meta Mar 16 '18 at 22:05
  • 1
    $\begingroup$ Stack Exchange isn't the only source of information! You can always drop by on IRC (FreeNode, channel #blender), join mailing lists, or chat at Blender.Chat. $\endgroup$ – dr. Sybren Mar 18 '18 at 9:08
  • $\begingroup$ @Madcowswe have you asked around on IRC? $\endgroup$ – meta-meta Mar 22 '18 at 15:23
2
$\begingroup$

Indeed, presently, there is no ndof_motion field in the python Event struct.

I checked in with Blender's Python API module owner @ideasman42 on the #blendercoders IRC channel, and he gave the thumbs up to expose this data with an added field. So I will try my hand at adding that. Assuming that all works out, it should then be possible to make your proposed addon.

$\endgroup$
  • $\begingroup$ What's the status of this? Did you get it to work? How can I access it in python? $\endgroup$ – Jam Risser Nov 27 '18 at 15:45
  • $\begingroup$ @JamRisser Sorry I ran out of time for this project, so I don't think I will be able to do it any time soon. It didn't look very complicated to do this though, so I'd recommend doing it if you have the time. $\endgroup$ – Madcowswe Dec 1 '18 at 7:10
  • $\begingroup$ Could you give me a jump start by sharing your work with me? $\endgroup$ – Jam Risser Dec 1 '18 at 7:12
  • $\begingroup$ @JamRisser I never got to writing any code, but I remember that between the rna_def_event() in developer.blender.org/diffusion/B/browse/master/source/blender/… and the python event struct, I think that's the main path to get the data out by adding to those. There may be more to it, but then I would ask @ideasman42 on the #blendercoders IRC channel. $\endgroup$ – Madcowswe Dec 5 '18 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.