A script to place cursor on objects' surface (and some other functionality)

Cool :slight_smile: Thanks! Could you please point me to the corresponding part of API documentation?

Edit: Hmm, seems like there is no API documentation on that. A hidden feature?

Thats a very interesting feature undergoing on here :smiley:
Did you consider enhancing 3dCursor functionality by eg: full snap modes, origin definition, magnet ??

The addon already supports snapping (see the wiki).
As for origin definition and magnetā€¦ please explain in more detail %)


       # turn off undo
        undo = bpy.context.user_preferences.edit.use_global_undo
        bpy.context.user_preferences.edit.use_global_undo = False

        # restore pre operator undo state
        bpy.context.user_preferences.edit.use_global_undo = undo



Ah, you meant global undo :slight_smile: That wouldnā€™t solve the problem, thoughā€¦ Even with Global Undo turned off, editmode switching is still recorded in Mesh Undo history (and as that, erases the history beyond this point). Even more, turning Global Undo on/off is recorded in blendā€™s undo history tooā€¦

Having an option to actually freeze undo history for the duration of some operations would be nice ^^

For example:

with bpy.utils.freeze_undo_history():
    # ... do some sneaky operations
# At this point, undo history is the same it was before freeze_undo_history().
# Even more, the __exit__ method could actually revert any changes
# (that may be undesirable, however).

Have to explain honestly -I meant CAD style object snap (ā€¦ooooppzz for the word CAD hereā€¦):
Snap (both in object in edit mode respectively) to

  1. 2D(regular): endpoint, midpoint(or s.c. divisor- every 'nā€™th segment of a given distance), tangent, node(Edit), center intersection
    , extension, perpendicularā€¦
  2. 3D: Vertex, Midpoint on edge, center of face, perpendicular

Origin definition: w/above manipulation so one could move and operate origin (local/world 0,0,0) easily, define it by 3 points(x,y,z on an object eg.) by object, by view, save&restore an ucs(User Coordinate System).

Magnet: i meant defineable ā€˜gravitationā€™ to such abovementioned point within eg. range of circle Blenderā€™s cursor - so one could easily snap to a point w/no miss.
So is this-in shortā€¦-)

Hmm, CAD spannings and magnetā€¦ Seminumericalā€™s cursor addon (Cursor Control) deals with some of them, and our addons seem to be generally compatible. To be honest, Iā€™d like to see CAD tools in Blender too, but I have too little experience in this area to try to tackle such broad topic.

As for user coordinate systems, I have an idea how to implement this hacky-way (using e.g. empties to store different systems; when user switches to such UCS, origin will be set to ā€œcursorā€, cursor will be sticked to the empty, and a custom transform orientation will be aligned with the empty). Maybe Iā€™d even add that before 2012 :stuck_out_tongue:

some examples that illustrate my ideas:
(first one-see command line for UCS manipulation options, second-preset snaps, third-on-the-fly(modal) snaps)

http://img545.imageshack.us/img545/9193/screenshot4wa.th.jpg
http://img804.imageshack.us/img804/2218/screenshot3l.th.jpg
http://img198.imageshack.us/img198/9585/screenshot2au.th.jpg

Hi. Iā€™m using this add on since I find it really nice. Unfortunately it works without any problem when I activate it in the preferences, but when I close Blender and reopen it, I keep getting Traceback errors:

Traceback (most recent call last):
File ā€œD:\Blender\Blender 2.60\2.60\scripts\addons\space_view3d_enhanced_3d_cursor.pyā€, line 4881, in modal
km = wm.keyconfigs.active.keymaps[ā€˜Windowā€™]
KeyError: ā€˜bpy_prop_collection[key]: key ā€œWindowā€ not foundā€™

location:<unknown location>:-1

Any idea about whatā€™s causing it?

Hmmā€¦ What version/build of Blender are you using? Currently the addon uses an ugly hack to properly register keymaps on startup, but it works fine for the builds I haveā€¦ Iā€™ll try to see if there is a better way to do it after 2.61 is out.

no object modeā€¦??

Errā€¦ bluecd, what do you mean by ā€œno object modeā€¦?ā€ :confused: Was that supposed to be a bug report? :eyebrowlift2:

Wooouubbzzzzā€¦, i took another Enhanced Cursor switched on. Your addonā€¦I CANT ACTIVATE IN ADDON menu !!!

Hmm, Iā€™ve downloaded latest build from graphicall, seems to work just fineā€¦ Again, what version/build are you using?

already OK.sorry -i am just trying to get the idea how it worksā€¦(with ALT selects whole row)

I use this build: http://graphicall.org/444
I tried on a previous one as well (2 days ago I think) and I had exactly the same error. Iā€™m using maya presets and thatā€™s pretty much it, nothing else fancy.

Aha! The problem was with Maya keymap presets. Thanks for the report :slight_smile: I fixed the issue, latest version of addon should work properly.

Thanks for the very quick fix, Iā€™m really enjoying this cursor :slight_smile: Actually moving vertices / edges / faces should be as easy as this!

I have to admit you made a huge work - thank you a lot !!
Yet let me some constructive critique: the functionality of the script ,although extent seems a bit complicatedā€¦
How eg. could i grab a cube snapping it firstly w/holding MB(i got reversed L&R) and thenā€¦again trying to snap to a target-here (still dragging the object by snapped point) you cant activate 3d snap tripod againā€¦,got to be like that?

  1. Does not seem to snap to curves ??
  2. I would suggest to add some option toggle switch:
  • either you move Blenders circular red-white cursor alone OR
  • you move the cursor AND the Blenders X,Y,Z tripod [Origin]. What do we need additional tripod for?
    What makes the axes alignment ? (for a cube they dont align the ortho edgesā€¦?)
  1. Midpoints of an Edge/Center of a Face possible to snap also ?

Excuse my messing in Your results but I felt so comfortable You made sucha smart approach to the Problem of Snapping that i would like to suggest max. functionality features You can probably achieveā€¦)

Errā€¦ bluecd, I donā€™t really understand what youā€™re trying to say %) I guess by ā€œtripodā€ you mean 3D manipulatorā€¦? Maybe you can provide an explanation with screenshots of what you want to achieve?

  1. My cursor script currently snaps only to surfaces/polygons, or to edges/vertices that belong to surfaces. Recently I came up with an idea that may allow to snap to stand-alone edges and vertices too, but this is perhaps a long-term task.
  2. You can set pivot to Cursor ā€“ this will make 3D manipulator move with cursor. As for ā€œadditional tripodā€ and ā€œWhat makes the axes alignmentā€, I failed to understand your idea %)
  3. To snap cursor to midpoints, hold Shift while in appropriate snapping mode (this should be explained in the wiki).

As for suggestions, I have little free time right now, but Iā€™ll try to take them into account when I start working on CAD-like functionality.