Pie Menu Editor 1.18.7

I’m trying to limit a count on blender’s built in step select operator which is normally triggered with CTRL+Shift+‘Numpad +’ or …‘Numpad -’ shortcut. This is non modal and doesn’t have parameters. So, it’s either increasing the selection or decreasing the selection depending on the key combo used. The problem with this is that you can decrement until there are zero elements selected. There’s a property in my pme setup I created that’s initialized on invoke called “steps” that is incremented up or down using a mouse wheel On Update using this command string:

bpy.ops.mesh.select_prev_item() if steps < 0 else bpy.ops.mesh.select_next_item(); steps = 0

The problem is that, just like when using the shortcuts, I can increment low enough that there is no longer anything selected, at which point I can no longer increment or decrement. Is there any way around this that anyone can think of? Maybe some way to keep a running count of my overall movement±? Right now, ‘steps’ goes back to zero after the update.

Hi, @dpdp
Try to add two more slots:
On Invoke:

import bmesh; bm = bmesh.from_edit_mesh(C.object.data)

On Update:

bpy.ops.ed.undo() if len(bm.select_history) == 0 else None

These 2 slots should undo Select Prev Element command if there is no selection. Didn’t test the code though. Let me know if it doesn’t work.

2 Likes

Hi,
Im trying to make a modal operator which should change the bevel angle in the bevel modifier.
Basically press a hotkey and then control the bevel angle in 10 degree steps(10°,20°,30°) with mouse wheel.
My question is it possible to do with modal operator? I was trying to following the video on youtube where you show the subdivision modal operator, however im noob in coding, so its hard to replicate because bevel modifier is already exist on the mesh.
PS: I figured out how to do this! :). So no need to answer this question.

And the second question. Is it possible to execute scripts based on , if edge is selected or not.
If one edge is selected in edit mode > execute script 1
If two edges are selected in edit mode >execute script 2
If nothing is selected in edit mode > execute script 3?

Hi @Woolfy13,
Try something like this in Command tab:

import bmesh; bm =  bmesh.from_edit_mesh(C.object.data); num_sel_edges = len([e for e in bm.edges if e.select]); execute_script("scripts/script1.py") if num_sel_edges == 1 else execute_script("scripts/script2.py") if num_sel_edges == 2 else execute_script("scripts/script3.py")
2 Likes

Thank you very much for the help! But i think, i did not described the question good enough. I was meaning the execution of the scripts( macro operators) based on if edge is selected or not.
It’s kind of similar what you have already “Mesh select modes” where you can assign to every mode(edge,vert,face,object) different macros.

Let me try to explain. What i’m trying to do is to replicate the more smarter edge tool from silo/nvil where you don’t need preselect edges to merge them. You just need to hover over an edge with the mouse and execute merge via hotkey.

To avoid the preselection i use your macro operator which is amazing to run multiple actions at once. It has two “items” (select and merge)

I have here an example: edge_merge_without_preselection.json (548 Bytes)
and a video that shows the speed of it:

Now to my problem. The tool is not “smart” enough.
Sometimes i want preselect couple edges and merge them together instead of merge only whats under the mouse. For this i need this if-else behavior which runs different macros based on selected or not.
If one or more edges selected> then only merge
If no edge selected> select whats under the mouse+merge
Is it somehow possible to get something like this with existing operators? And if not can you create one if-else operator that can control multiple macro operators by using one hotkey? What do you think?

It’s not only this merge macro that can profit from this but a lot of tools, like connect, extrude and much more, everywhere you need preselect components.
Thank you in advance.

2 Likes

great idea, I did not know one could do something like this before.

It’s a huge time saver. If manipulation geometry works without this extra clicks, it feels better and over the long modelling session it saves you thousands extra clicks. The tools needs to get more smarter with less clicks as possible.

Add a Stack Key with D hotkey, Mesh keymap and this code (Command tab):

import bmesh; bm = bmesh.from_edit_mesh(C.object.data); num_sel_edges = len([e for e in bm.edges if e.select]); open_menu("108 D Edge") if num_sel_edges == 0 else bpy.ops.mesh.merge(type='COLLAPSE')

Don’t forget to unset D hotkey for 108 D Edge macro.

Or import this file


If you prefer poll methods use this code:
No selected edges:

import bmesh; bm = bmesh.from_edit_mesh(C.object.data); num_sel_edges = len([e for e in bm.edges if e.select]); return num_sel_edges == 0

1+ selected edges:

import bmesh; bm = bmesh.from_edit_mesh(C.object.data); num_sel_edges = len([e for e in bm.edges if e.select]); return num_sel_edges > 0
4 Likes

Yes that is amazing! It works, thank you very much!
I very like the pool method.

And another question.
can i add somehow the separation( edge,face,vertex) to the pool method code in addition:

return C.scene.tool_settings.mesh_select_mode[1]
+(addition)
import bmesh; bm = bmesh.from_edit_mesh(C.object.data); num_sel_edges = len([e for e in bm.edges if e.select]); return num_sel_edges == 0

so the tool get activated only in edge mode? because now the tool get activated also in vertex and face mode.

Yes, use and keyword for +(addition):

import bmesh; bm = bmesh.from_edit_mesh(C.object.data); num_sel_edges = len([e for e in bm.edges if e.select]); return C.scene.tool_settings.mesh_select_mode[1] and num_sel_edges == 0
2 Likes

Yes that’s exactly what i needed!
Now i was able to create a bunch of tools with using this feature! Best Thanks!

4 Likes

I saw some people asked about this a loooong time ago, but is it possible to steal/get a popup menu of the Outliner in Blender 2.8+ ?

image

I found out how to do it with a StackKey. Not sure if that;s the best way to do it or not, but it works.
Now I need to see if I can customize the filter somehow in the settings.



image

Edit: I got this from using PME Debug when turning off things in the filter… maybe I can put that into the command area…

bpy.context.space_data.use_filter_collection = False
bpy.context.space_data.use_filter_object_content = False
bpy.context.space_data.use_filter_children = False
bpy.context.space_data.use_filter_object_light = False
bpy.context.space_data.use_filter_object_camera = False
bpy.context.space_data.use_filter_object_empty = False
bpy.context.space_data.filter_text = “”

.

Edit: Maybe this is because of using stackkey, but if I popup the menu it’s fine, but then if I click outside the popup window into the main blender UI, blender then crashes…

You can execute code for the new area using cmd property:

bpy.ops.pme.popup_area(area='OUTLINER', cmd='C.space_data.use_filter_collection = False; C.space_data.use_filter_object_content = False; C.space_data.use_filter_children = False; C.space_data.use_filter_object_light = False; C.space_data.use_filter_object_camera = False; C.space_data.use_filter_object_empty = False; C.space_data.filter_text = ""')

Yes, will try to fix in the next version (a couple of days)

4 Likes

Awesome, thank you!

I actually figured out some code just now, to let me popup the Outliner/customize it, then even resize/position it and set it always be On-Top. :slight_smile:

But your code is still very useful and appreciated :slight_smile: Thank you.

I am slowly migrating from good ’ old 2.79 to 2.8+, and run into a small problem.

take extrude edge for instance, first I select and edge, click right mouse button to open pop up menu, choose extrude edge, without press/hold anything, I can move around mouse to position the extruded edge, only when I click left mouse button, the operation is done.

now if I copy the extrude command to PME and assign mouse button 4, I have to hold the MB4 to move the extruded edge around.

I was hoping to click hotkey MB4 (without holding), move mouse around, and then click LMB to finish the operation, is there a magic setting to grant me the wish?

Please post the command here.
Or try this instead:

bpy.ops.mesh.extrude_edges_move()
1 Like

it is the same command you provided. version blender2.82a
if I use the command in a macro operator, right after I click the shotcut key and let go, the new edge stays almost at the same spot. if I use it in a pie menu item, after I click the shotcut key and let go. the new edge would follow the mouse cursor till I LMB click to confirm it and it behaves the same as I did with the default blender pop up menu.
if you could test it out with macro operator compare to pie menu, you would tell the difference, but it is no big deal, I will get used to the hold and release part.

Works fine for me.

blender_2020-03-18_19-58-14