bpy.types.Macro usage?

Interested in using macros for blender? Well I was, so I ended up making an addon to give blender some capacity for macros.

Usage, once installed, is from a panel under scene properties.

Step one is to create a panel to hold one or more ‘macros’. Name doesn’t matter but is editable. It is what the panel will have for a label.

Macros can be created and edited manually or constructed from valid clipboard* data. Also, name is editable but not important. It is what the button will have for a label.
*windows only for clipboard usage

Manual method:
Create a macro (after you have first created a panel).
Now you add operators to the macro, with the ‘add operator’ button.
‘EDIT ME’, it will say, if you still need to edit it.
Where ‘mesh’ is selected by default, below it you will see a menu with selected value of ‘NONE’. When you change that, that is editing. Once you pick, you can fine tune parameters by typing in the box.

Copy-and-paste method:

step one: create a panel.

step two: click the ‘create from clipboard’ button. If you have correct data in your clipboard, then it will become the contents of new macro.

How to get some correct data into clipboard? Do some things and see at the top of screen where reports are displayed. Right click one or more lines to select, then ctrl+c to copy. You can paste this into a macro.

Don’t think they actually work yet.

Ahh. Thanks.

Crap, I just started to search about how to record macros in Blender :smiley:
It’s because I’ve seen this http://blendersushi.blogspot.com/2011/09/tracing-particle-tutorial.html
great tutorial and thought:
"I could make to use it to apply a simple object for different paths (hair strand -> curve) and animate it as particles on curves using Follow Path constraint. Of course it’s unbearable to set many objects to different curves manually.
MB Python is good but it scares me by [tab] and [space] differences and some other things. Also I’m not a coder in soul so it’s hard for me to create some good program while doing it fast.
Sorry, maybe you aren’t into this stuff, Uncle Entity but I decided to comment it to you and here because of the theme.

I haven’t figured out how to record macros yet, but I ended up making something that lets you construct one, turn it into a button, put it somewhere in the ui or put to textblock,

It’s still a bit of a mess but it gets it done:
the_facility.zip (5.67 KB)
(extract to the addons folder. the name to enable is ‘the facility’)

a few kludges have been necessary or at least helpful, such as an operator for switching to specific edit mode [vert|edge|face]. you can sometimes need to be editing the text of an op call (a textbox is provided per op (in the macro) and would need to know the names of the enums ( ie default for mesh.merge is ‘CENTER’ but perhaps you wish ‘COLLAPSE’. if you do not know the options, there isn’t yet a interface per op, but there is at least a menu of them category per module

the usage is found in the ‘panels’ panel with a plus sign on its header.
the plus is for add panel, then add macro, then add operator, test with run this, when done testing, choose where to put and click registrant. if edit, then to see changes, you need to uncheck and recheck registrant. also, if you save macros with your user prefs, then after reload, if registrant is on, uncheck and recheck.
the_facility needs to be addon and your kludges go in startup, so that addon sees kludges.

in a hurry so here are the contents of my startup folder for example:
startup.zip (5.83 KB)
(place contained mesh_modes_as_ops.py in your scripts/startup for three ops that show up under ‘modes’, OFTEN necessary to make certain mesh operators work as expected)

where is the ‘panels’ panel to be found??? Can not see anywhere the + sign???

got something visible under Properties Scene …

I spent some time this morning fixing the ui. here is a better version:

macro_facility.zip (5.75 KB)

Sorry I was in a hurry yesterday and forgot to explain where it was. It is supposed to be in PROPERTIES > scene but it seems to float around.

The part I still haven’t figured out is how to build an interface for operator properties. I’m currently using the _bpy.ops.as_string function to generate a string which can be eval’d. (Not an optimal solution!) Any changes to an op currently require typing to edit to string which gets evaluated.

Hey dustractor,

had a quick look at this. Tried to add a simple macro with

bpy.ops.object.mode_set(mode="EDIT", toggle=False)

No joy with the material slot op … it pops it into edit mode ok.
I get an empty panel in the area selected.

Hitting the register checkbox throws an error because it doesn’t like the op name “faculty.macro.001” because of the extra period. Simple fix to replace the second . with an underscore or something is needed. There’s something in the back of my head that it doesn’t like anything but lowercase chars and underscores in registered op names. Maybe having one macro operator and run the operator list dependant on the macro name passed to the op as a prop. I’m assuming you are building an operator for each macro, hence the error… once again haven’t really picked thru the code.

Nice UI … going to have a good look at how you did some of it.

Have you considered running a modal operator to record macros? If you use bpy.app.debug = True you get the op with all the chosen props output to the console. Must be some way of trapping these. I imagine that is the concept being developed for macros.

I’ll be watching this! I guess you disabled the copy from clipboard options, can’t see that.