Ray Mairlot - Freelance 3D Artist
  • Gallery
  • Blog
  • Store
  • Contact
  • About

Making Macro Maker: A Maker's Memoir

14/3/2018

Comments

 
A while ago I was doing a series of repetitive actions in Blender - not an uncommon occurrence - and as usual, I began to think of a Python script that I could write to do this task for me...

But I write a lot of scripts. And the add-ons I write are often project specific and therefore limited in use. Plus, this task was about manipulating object's and their data and applying modifiers and joining objects and moving them and setting their origins and removing doubles and and...and that sounded like a terrible amount of effort.

I thought to myself that it would be so much simpler if I could simply take the actions I was already doing - which were pretty straightforward when done through the UI - and just record them. Other software has this functionality: Word and a few of the other Office products have 'Macros' while Adobe's offering is 'Actions'. Both produce the same results: record a sequence of tasks, save it and then play those actions back any time on the selected content.

I looked into whether Blender had any similar functionality. I knew it didn't really have anything like that built-in. Common advice is to pull down the Info Editor window, copy the actions that are listed there and paste them into the Text Editor and run them. This does technically work, but this workflow is itself repetitive.

There's even an add-on that comes with Blender called 'Macros Recorder', which does automatically record a series steps to a text file and inserts it into a script ready to be run. But that add-on doesn't have the nicest of UIs and at best I would describe it as 'cryptic', even though, once worked out, it is quite simple to use. Nevertheless, when comparing these options* with Word's macros or Photoshop's actions, they fall somewhat short, which tempted me to make my own add-on.

*I've just found another add-on, here, which also offers slightly more features, but still relies on the copy-from-the-info-editor workflow.

Now, you may be thinking "But weren't you complaining earlier that you right a lot of add-ons?" and the answer is "Yes", or at least "Yes, but..." I do write a lot of add-ons and I have, in the past, sometimes got caught up in writing an add-on as a bit of a distraction instead of just getting on with whatever task the add-on is meant to be helping with, but, if the add-on is helpful to many projects instead of just one and if I can see that maybe this add-on would be popular and useful enough to potentially sell, then I give in and allow myself to have a bit of a play with some code.
The result of this playing is Macro Maker, the add-on I wrote:

Image of the UI showing a macro before it's saved

Not exactly the most exciting screenshot, I'll give you that, but it gets across the basic idea. So far the add-on has the following functionality:

  • Record 'Macro Steps' (where each step is an action you take) 'live', i.e. each 'step' is shown as you make it:
Animation showing a macro being recorded
  • The ability to delete steps if you make a mistake.
  • The option of editing options. In the GIF above I edit the 'Angle' of the rotation.
  • Saving macros to an external file so they're accessible to any blend file you open.
  • Manage and delete saved macros from a separate panel.
  • And, most importantly, the ability to click a button to replay the macro. You can also set the macro to run on each selected object individually. You could, for example, have a macro with the Cursor to Selection command as one of its steps. By default, the cursor would go to the centre of the selection of objects, but you might want the cursor to go to each individual object instead.

One important thing to note is that it's only possible to detect 'actions' i.e. Blender's operators - basically anything that's a button or a tool from a menu. It can't automatically detect property changes. So you could add an Array modifier, but you couldn't set its Count property. I've got around this by providing an entry in the right-click context menu for properties called 'Add Property to macro':

Picture

This adds the property to the macro. I can understand that might seem a bit fiddly, but I don't think there's a way around it.

Here's the most up-to-date screenshot of the UI, showing a few recorded macros:
Image of the UI in Blender of the 'Macro Maker' add-on

However - and this is a rather large 'however' - I'm not going to do any more work on it, at least not for the minute. It works pretty well, I'm able to use it for some tasks, but it still needs a lot of work. For example, I can't:

  • Use tools that are combinations of two other tools, e.g. inserting an edge loop actually runs two different operators. Firstly, it inserts a loop - the first operator - then secondly it starts the edge slide tool. Side note: confusingly, Blender refers to these types of operators as...macros.
  • Detect which context the macro was recorded in. Was it recorded in Edit Mode? Then you shouldn't be able to run it in Object Mode etc.
  • What if the operators requires certain conditions to be met and they aren't? E.g., you can't join two objects if only one is selected. How do I pass those error messages on to the user?
  • A pretty major one: you can't yet edit existing macros. There are some I've recorded which I would really like to extend - the only option at the minute is to re-record them in their entirety.
  • I've also never really tested it on anything but the 3D View, so it's pretty focused around objects at the minute, despite the fact it should work in every area of Blender, which also means detecting which area a macro expects to be run in to avoid running something in the 3D View which was intended for the VSE.
  • Properties on the object can be recorded, but I can't yet record properties on an object's materials or modifiers.

There are also a few technical things that need to be changed, but I think for the most part it would just take time. As for why I'm not continuing to work on it, the answer is 2.8. Blender is undergoing heavy development. Heavy enough that the very specific Python APIs I'm using might not even exist when 2.8 is finished (I'm already having to prepare for the fact that my existing add-ons, including the one I sell will have to be updated, as some critical parts of the API are changing), so I'm going to wait until 2.8 is out before I work on it again.

There is also a slightly different problem which makes me slightly wary of further development. From talking to a few people on Twitter about the add-on, I'm slightly worried people haven't thought about how macros actually work (in any software, not just my add-on) and they may have difficulty in adapting their current way of thinking when trying to use the add-on.

Let's say I want to record a macro that takes the selected vertices in Edit Mode, adds them to a new Vertex Group, adds a new Mask modifier and assigns that newly created Vertex Group to the modifier. The steps would look something like this (having already selected the vertices):

  1. Add a new Vertex Group.
  2. Click 'Assign' under the Vertex Group.
  3. Add a new Mask modifier.
  4. Choose the new Vertex Group on the Mask modifier.

This looks pretty straightforward, but there are actually a few problems with this that would stop the macro working under some (maybe most) circumstances. The macro would work fine up until step '4': "Choose the new Vertex Group". It sounds simple, but how would the macro know which modifier to add the Vertex Group to? I don't yet have this part of property recording working yet, but when trying to choose the Vertex Group, it would likely look for a Mask modifier with the same name as when the macro was recorded. So what happens when the macro is run a second time or if there's already a Mask modifier? The new modifier would have '.001' appended to the end of its name and the macro, not being able to find a mask modifier with the correct name, would fail.

The important thing to realise is that when dealing with lists, the add-on will likely look for something to have the same name each time, whether that's a modifier in a list of modifiers or a Vertex Group in a list of vertex groups. Potentially, this could be fixed by having an option when recording a property to always look for the property on the last item in the list. I'll only know if this is an option once I resume development. Even then I have a feeling that wouldn't solve all the problems.
So, to conclude, I'll start working on Macro Maker again when 2.8 is released and I'll see if the APIs I need are still intact. There's also the problem that the toolbar as it exists now, where the add-on is placed, doesn't exist in 2.8, but I've heard that the developers are going to make sure the new UI supports 'UI heavy' add-ons by updating the UIs of the add-ons that are distributed with Blender, so hopefully there will be a solution for add-ons that require constantly visible columns for their layouts.

In the wake of ceasing to work on this add-on, I've been working on a personal Lego project, which I'll probably talk about in the next post, but judging by my past release schedule for blog posts, that won't be for another 6 months.


Ray.
Comments

Moving Render Layers and Travelling in Time

1/4/2017

Comments

 
Over the past few months I found the need to create two more add-ons for Blender 3D: 'Timecode' and the aptly, but rather unexcitingly named 'Move Render Layers'.

Timecode


'Timecode' is a small add-on that adds the ability to navigate the timeline by inserting a timecode into the Timeline Editor's header (in the form of HH:MM:SS:FF):
Picture
As part of the add-on there is also a small label that appears above the current keyframe/selected-object label, showing the current timecode:
Picture
Note: One thing I still have to do is get the Timecode label to shift over when the 3D View Toolshelf is open. Currently, the label will be covered when the toolshelf is open.

You can get Timecode, here.

Move Render Layers


I've always been slightly annoyed that unlike the majority of the other lists in Blender, the render layer list cannot be re-ordered, and so eventually, after nurturing that annoyance, it bore fruit in the form of two little arrows:
Picture
Yes, this is perhaps the epitome of the 'First World Problems' meme, but you just wait 'till you're working on a complex project with one shadow render layer at the top of the list and one at the bottom, both of them destined to remain separate, then we'll see who's laughing.

It will be me.

"Ha, ha, ha ha, ha," I will say, actually saying the words instead of laughing. And you will say "How did you get in my house?" and I'll say "That's not important." Then, I'll reach down (because you'll have already fallen to your knees in despair), cup your cheek with my hand, softly brush away your tears with my thumb and say "No, I was just joking, that was my fake laugh. You can still use my add-on". And you'll get up, feeling slightly bashful that you got so upset, wiping away the remainder of your tears (because I did a bad job of wiping them away and really just smeared them) and I'll give you a little reassuring touch on the shoulder to say "It's ok." We'll make eye contact, break into smiles and walk off into the sunset. And it will be weird, not least because it wasn't even close to sunset when I first appeared and you didn't really even want to leave your house, but you accept this is a new future where all kinds of things are possible, like moving render layers up and down.

Alternatively, if you would prefer not to enact that little tête-à-tête you can download the add-on, now, from here.


Ray.

Comments

Node Pong: A Silly Little Idea

4/2/2017

Comments

 
A few months ago I had a silly idea, and as with all my silly ideas I spent far too much time on it. I knew it was silly. I knew because whenever I thought about it I sniggered to myself. I also knew that if I worked on it that the pay-off would be relatively small (compared to the work it would require), but I couldn't resist.

I can't remember what made me think of the idea, maybe it was that I had been working with Modal Operators in Blender - tools that allow continuous execution and interaction from the user instead of the more common single-run tools. A modal operator allows you to listen for certain events, run code continuously and update the interface while it's running. These three ingredients are also necessary for something else. Games.

I wondered if it would be possible to build a game utilising parts of Blender's interface. So that's what I set about doing.

To quote from the project's eventual 'Readme' on Github:
With the Blender Game engine probably being phased out in the not too distant future, an alternative game making experience is needed in Blender. Once again (but really for the first time), I come to the rescue and present an unoriginal, yet mind-altering game of agility, wits and literally unending fun, all based in Blender's Node Editor...

...Node Pong:

Picture

The game is available on Github here, along with instructions on how to run it yourself.

I released it, awaiting the imminent deluge of favourites, retweets and messages such as "You're so clever!" and "You're amazing!". Some people ask me how I stay so modest. Unfortunately I can't explain, it's just one of my many, many natural talents.

However, that didn't happen (the social media frenzy, not the modesty. I am always modest).

I posted it on Twitter, got a few favourites, waited a little while and then quietly came to the conclusion that perhaps it wasn't as funny as I had first thought and was suddenly self-conscious of the amount of time I had misguidedly sunk into this project.

You see, yes, I may get silly ideas, but these small projects, while enjoyable for me, are essentially done to get my name out there a bit more. If I'm not getting any monetary value from a project I at least hope to get some promotional value from it.

While I had hoped Node Pong would be popular, I had also experienced a slight numbness to it as the project neared its end. Now, yes, I would later conclude that at least part of that numbness was my leg falling asleep, but it was also the novelty of the original idea wearing off. It had become normal to me and it suddenly seemed quite reasonable that maybe it seemed normal to other people too, leading to it's mediocre reception.

And then, some 4 hours later...I got a trickle of favourites and retweets.

And then I got more.

And soon the trickle became a river and the river a flood, but the nice type of flood, not the killing type of flood. Potamology aside, soon the most well known members of the Blender community were commenting on, favouriting and re-sharing my silly little idea. It turns out it was funny and maybe a little clever too (more modesty, it is in fact very clever). Several weeks later it now stands as the most popular and far-reaching thing I have done.

I'm sure there's some valuable lesson to be learnt here about building things for yourself instead of requiring the validation of other people or to continue with projects even when you become numb to them, but I haven't really got time to make those points.

I have other silly ideas to pursue.


Ray.

Comments

Batch Render Tools (and The Wonderful World of Hummous)

15/7/2016

Comments

 
During the freelance work that I've been working on for the last couple of months I had to do a lot of long renders of animations. When I'm doing a really long render I tend to use the command line to do a 'background' render so that Blender's UI doesn't have to be visible (which apparently saves a bit of memory), and as with most things recently, that caused me to write an another add-on...

The Manual Way


Before I get onto the add-on I'll take you through the manual rendering process I used to do. To do a 'background' render (more commonly referred to as a 'command line' render) you open up a Command Prompt (or something similar for non-Windows users), navigate to the Blender installation directory and use something like this:

    
To break things down, that's:
  • 'blender' to run Blender.
  • '-b' (which stands for 'background') to make blender run without the UI
  • The path to the blend file
  • '-a' to tell blender that you want to render an animation

If I want to render multiple files then I would create a Windows Batch file with the following commands (I've simplified the paths just so they would fit on the page nicely):

    
  • 'CALL' which opens a program, followed by the path to blender executable to specify blender is the program I want to open
  • '-s' and then a frame number, specifying the frame to start rendering from
  • '-e' and then a frame number, this time pointing to where blender will render to
  • '-a' as before, to specify that we're rendering an animation

I would then just double click the Batch file, which would automatically open a command prompt and start rendering.

To navigate to Blender's folder and open a command prompt or to create a batch file with the updated filepaths and parameters each time I wanted to render became a bit time-consuming - I wasn't even doing that many renders at that point - so I decided it might be worthwhile (and fun) to create an add-on with a UI to handle this for me. 

Out of the primordial code came:

Batch Render Tools


Features:
  • Can render multiple files
  • Option to hibernate after rendering
  • Ability to re-order batch render jobs
  • Can generate batch jobs by specifying a directory of blend files
  • Launches a Command Prompt window as a separate process to carry out the rendering, so blender can be closed once rendering has begun.
 
Picture

It's available to download from Github, here. One caveat is that at the minute it's still Windows only.

The 'readme' over on Github is quite extensive (and if I say so myself, quite excellently formatted) so head over there if you want to know how to use every little feature, and given the amount of time it took to create that 'readme', I really suggest you do.

'Batch Render Tools' also has a small secondary panel which serves as a shortcut for opening a Command Prompt in the Blender installation directory, which I also find quite useful:

Picture


Virtual Machines


Having got a bit of feedback regarding the fact the add-on is only compatible with Windows, I decided to try and invest a little more time into getting it working on other OSs by way of 'virtual machines' - a way of installing another OS and run it like you would a program, instead of having to install it on another partition. This task is what's known as a 'time sink'. That is to say, it swallowed up the time I threw at it and I got very little in return.

Linux wasn't too bad, I installed Ubuntu in VirtualBox without too many issues, got it running and very quickly found the code needed to make the add-on compatible on the OS. Hurrah. Hurrahing aside though - for one can only Hurrah so much before people start to stare -  that left me with OS X.

There would be no 'hurrahing' now. The time of 'hurrahing' had well and truly passed, which made me wish I'd made a bigger deal of that first 'hurrah'. I'd have cherished it if I'd realised that the lack of 'hurrahing would be so notable later on, in the post-hurrah, OS X era*. I was battling with a 'Hackintosh' - it's name entirely appropriate given the endless problems and workarounds needed just to get it running - and after several hours I was no closer to finding the correct Python code to replicate the functionality the other OSs had so readily offered me.

*I've said 'hurrah' too many times now. It doesn't really look like a word and I can't tell if I'm spelling it right, nor what it really means. Was 'hurrah' ever a word? Should 'hurrahs' be pronounced like 'hummous'. Is 'hummous' a word or is it 'hummus'? Do they mean the same thing? Have I just described time in terms of pre and post-chickpea-based dip? We'll literally never know, but at least I've distracted myself from talking about the god-awful virtual machines.


Eventually I gave up, but since then, because of the amount of time that has passed between sharing the add-on and this blog post being published, I have had someone contact me regarding the issue and offer a solution, so when I get a minute (read 'hours' and 'motivation') I'll attempt to adjust the add-on to also work for Linux and OS X.

If you can, avoid virtual machines. I would say "avoid them like the plague", but thinking about it, I'd rather take my chances with 'the plague'.


Ray.

P.S. I will concede that perhaps having only 5 sentences on 'hummous' is hardly a "Wonderful World of Hummous" as the title suggests, but ultimately I prize appealing alliteration over accuracy.
Comments

How to Make Things That No One Needs

12/7/2016

Comments

 
I've been working on a freelance project for the past couple of months, hence the radio silence. That work is finished for the minute, so I decided to use this week to finish up a few small projects before settling back in to regular work. One of those small projects was good, the other...

How to make something that no one needs:


  1. Identify a problem.
  2. Make something that fixes the problem.
  3. Realise you were wrong when you first identified the problem. There is no problem. The only problem is You.
  4. Delete all evidence that you ever tried to solve the problem.
  5. Write a blog post about it, nullifying point '4'.

While this is an excellent recipe for mild embarrassment and moderate time-wasting, if you really want to excel at 'Making things no one needs™' you will also need to post your solution to social media, first, lamenting the original problem and then again when you have 'solved' the problem. Writing a blog post about the ordeal is optional, but somewhat cathartic.

Said problem was that there didn't seem to be a way to select all the keyframes for a given channel in the Graph Editor in Blender:

I must be missing something. Is there really no way to select all keyframes for the selected channel(s) in the Graph Editor? #b3d

— Ray Mairlot (@Madog1209) June 29, 2016

But poor naive Past-Ray was missing something, but it would be a few weeks later until he found this out:

@Madog1209 i thought double click on a channel already did that, no?

— Andy Goralczyk (@artificial3d) July 12, 2016

Of course, by that stage I had already completed the script, promoted it on Twitter and given myself a good ol' pat on the back for being so clever. Suffice to say, the script has now been relegated to a new folder called 'Obsolete Scripts'.

You have now got to the end of 'Making things no one needs™' and should be able to make things that no one needs all by yourself. Feel free to refer to this handy guide if you ever feel like you're in danger of making something useful.

A cup half full


It's a shame really, Blender used to be known for it's hidden features and tools that were only accessible by an obscure shortcut and I had been glad at the thought that those days were over, often frowning upon those outside the Blender community who still thought this was the case. "But everything is accessible through a menu!" I would mentally shout at them. Apparently not.

Maybe I should be looking at this slightly differently. Maybe it's because hidden features are so uncommon that brought about this whole event. Had I been used to features not being in menus I might have dug a little deeper into the user preferences and hot-keys to find it. Not being able to find it in an obvious place, to me, was a sign that it couldn't exist. Perhaps, just by chance, I have come across one of the few remaining hidden features. Here's hoping.

As for the second, slightly more successful script, 'Batch Render Tools', whose usefulness flies in the face of this guide, I think that deserves a blog post of its own as it requires a bit more of an explanation.


Ray.
Comments

Scene Nodes and Unity

4/3/2016

Comments

 
I haven't posted here much, but I'm hoping to do a weekly post of what work I've been doing each week. Seeing as I haven't done a blog post for a while, I'll cover a few things I've been working on in the previous months. Does that sound fun? I don't know, but you've already loaded the page now, so you may as well read a bit more.


Scene Nodes:


An interesting little experiment in Blender I did a few weeks ago is something I'm calling 'Scene Nodes'. Blender used to have something called the 'Oops Schematic View' in the Outliner, which allowed you to view your 3D scene in a visual, node based way, showing the relationships between your assets. This feature never made it into the revamped Blender 2.5 so I thought I would have a go at recreating it with Python. Partly, that was because I just thought it would be fun (it was 50% fun, 30% googling, 15% deciding what colour each node should be and 5% crying) but also because I thought that if it proved to be popular I might develop another add-on to sell on the Blender Market.

Picture
Working out what colour nodes should be took longer than it should have done.

The result above shows all the different objects and materials in my scene and also the relationship between them. 'Cube.001' (orange) is the child of 'Camera.001' (grey)  and also a parent to 4 objects (orange) and a lamp (yellow). I got it working so that not only could you press a button to generate this node setup, but that duplicating nodes would duplicate the actual object, deleting a node would delete an object and changing the connections between objects would change the real object's parenting.
 
 
Before you go rifling through you wallet to find money to throw at the screen* (because you obviously love the sound of it, not because you're misguidedly attempting to throw loose change into my eyes), while it was quite fun to do, I'm not entirely sure that there's enough interest in it for me to make it an add-on. My last add-on wasn't really cost effective, considering the development time vs monetary return. I'm not ruling out making it an add-on, but I don't think it's a 'high-priority' project.

*and people say I'm a fantasist.**
**If anyone of importance is reading this, I'm lying, no one has ever called me a fantasist. It was just a joke, which we (I) here at www.RayMairlot.co.uk deeply regret.



Experiments with Unity:


I've also been making a game with a friend, not in Unity as the title might suggest, but in Flash. Flash might get criticised a lot, but for making a cross-platform game it really makes a lot of sense (to me). However, I'm well aware that several sites are moving away from flash, at least for video delivery, so I thought I would make some investigations into other game engines, just in case the day comes that Flash content is no longer run by web browsers.


I decided that I would try out Unity as it has a free version and I got to grips with one of the tutorials. I wasn't best pleased to find my simple tutorial scene of a ball rolling over a plane, collecting yellow diamonds, came to an eye-watering 170MB. God help me if I try something complex*. Maybe I can cut that size down somehow, but at least it does cross-platform publishing pretty easily.

*Dear God, I know you're busy, but please help me squash these megabytes. If you help me (for free) I'll tell everyone it was you that helped me and I think that will be great exposure for you. Thanks, Ray.



I had originally thought that if I wanted to learn Unity it would be better if I already had a working game in Flash, so that when trying to re-create it in Unity I wouldn't have to be worrying if the logic of the game was correct, only the conversion of AS3 to C# (one of Unity's coding languages). I made a little Tetris game in Flash, but having seen the large file size Unity creates I was put off from actually trying to convert it. I realised that Flash is still the better option for me, but that Unity was a viable alternative if I really needed it.


Picture
Tetris: Surprisingly tricky to make.

That's not to say making the Tetris game was a waste of time; it helped me a lot with realising how to implement OOP concepts properly, which I can put to good use in the game I'm making in Flash.


All in all, quite a few experimental projects, but now I'm back to my main one, which I may start to reveal soon. Or not, know one knows. If people say they know, they're lying.


Unless that people is me.


Ray.

Comments
<<Previous

    RSS Feed

    Categories

    All
    Animation
    Blender
    Compositing
    Flash
    Geometry Nodes
    Heartbreaker
    Hmhb
    Image
    Macro Maker
    Nodes
    Programming
    Python
    Rollercoaster
    Tutorial
    Unity
    Vfx
    Video


All images and videos copyright © Ray Mairlot, 2022.
None of the content on this site is to be used without my permission.
Powered by Create your own unique website with customizable templates.
  • Gallery
  • Blog
  • Store
  • Contact
  • About