Monday, June 27, 2011

Curves, Regular Expressions, and Blender Data Pages


This was a pretty busy week that saw a lot of victories and interesting developments on small projects and experiments. Here are some of the highlights of what happened.

String It
Last week saw the release of String It. String It is a Blender add on that generates curves that run through the center of selected objects. Right now, it just supports bezier curves though future revisions could support other spline types. Also, it might one day include support for automated hook modifiers to bound the the objects to the curves that run through them.

Regular Expressions Challenge
Repetitive work involving removal of Amazon anchor tags inspired a scripting project to automate those kinds of tasks. A practice challenge with regular expressions on an old copy of one of my PHP files was called for. The project ran into some problems. For example, what does one do if there are two sets of anchor tags on the same line being evaluated? An oversimplified expression might match both sets along with any text between them. It's interesting enough to merit further investigation.

Blender Data Pages
One of last week's projects confirmed that it is possible to have a server script invoke Blender in a way that lets the script print blend data on a web page. The project only required a PHP page, a blend file, and a few lines of Python. While it was easy to do, security concerns prevent me from making a full project for production. Still, the idea of something called "Blender Data Pages" does have a nice ring to it.

Generator for Uncle Squirrely
Usage of the any() function in Uncle Squirrely's database update script made the code cleaner. However, that meant evaluations on whether or not a game belongs in the database had to go into lists. Since every evaluation in the list has to be evaluated, that caused an efficiency hit. Sacrificing performance for code aesthetics was not a good trade off.

Lazy evaluation courtesy a generator function is the best of both worlds. Basically, all I needed to do was put all my evaluations in it's own function. If you put yield statements between evaluations, what you get is a function that can be iterated on the same as you would with a range function. It was easy to learn, easy to implement, and lead to lazy code that looked great. All projects should be that easy.

Other Little Things
In the near future, Blender PythonTutorials will be an add-on focused site. Moving the add-on scripts link to the top is one step toward that goal.

Last, but not least, I have a special lambda utility I like using for searching module properties.  The problem is I found myself rewriting it everytime I needed it. Finally getting around to putting it in my PYTHON_PATH reduced that typing to an short import statement. It also made the utility available both in and out of Blender related Python projects. It should have been done sooner.

As you can see, it was a pretty busy week. I learned a lot, put good stuff out there for users, and got inspired to explore other ideas. These are the things that make software development the worthwhile endeavor that it is.


Sunday, June 12, 2011

The Teacher is a Maker Now


The week's theme was on setbacks and moving forward in spite of them. Let's review what happened.

Broken Microphone
My microphone no longer records intelligible audio.  This killed the voice part of recording for the GUI and Panel Basics video tutorial.  Lack of money for new equipment forced a change of strategy.  Annotations acted as a substitute for audio.  Well-timed notes and speech bubbles made the video shorter. While these got the job done, I'm not sure more video tutorials with this limitation are worth it.  Because of the limited value of making new tutorials at all, I think I should call this latest one my last.  It's time to focus my efforts where they'll do the most good.

Losing Amazon Ads
There are no more Amazon ads on my site because I live in Connecticut.  My governor passed an affiliate sales tax law.  Amazon is now supposed to levy my state's sales tax if users arrive there via my site.  They didn't like it so they closed my account along with every other Amazon associate living in Connecticut.

This makes for an interesting problem.  To find a replacement affiliate program, I'd need something that dealt in books and computer hardware.  Also, they would have to be widely known and trusted.  Thirdly, they'd have to tolerate my state's affiliate tax.  That's a pretty tall order.  It's likely easier to figure out a business plan that doesn't need affiliate programs.

Moving Forward on Python Developments
The setbacks got me thinking more about writing code.  A better version of my animated mesh mangler now sits in the script section of my site.  I submitted my pyramid generator script to the Blender tracker for consideration in the next Blender release.  I've also started playing around with curves in the Blender API.  It'll be interesting to see how this all turns out.

What This Week Drives Home
The good thing about losing Amazon and my microphone is how it pushed me change priorities.  The transition from tutorial writing to development is complete.  For better or for worse, the teacher is a maker now.  Maybe the change was overdue.

Sunday, June 5, 2011

Thoughts on Python, Marketing, and the Future


I have a confession to make.  I'm a better programmer than I am a business guy.  However, much of the focus last week was on marketing, design, and the business angle of Blender Python Tutorials.  Here is some of what happened and the conclusions I came to.


Marketing and Design
Advertising is a key component to marketing with Blender Python Tutorials.  Failure of past ads to generate revenue lead to changing to an approach based on text ads instead of graphical ones. More layout improvements with respect to ads may also improve the situation. Time will tell how effective this will be. However, even if it fails, the site design is still improved over what it was.

Knowing one's audience is also an important part of marketing strategy.  Time with the Blender Artists forum helps me better understand the concerns of other script developers. My posts include a tag line that links to my site which helps drive traffic. However, I only post when I have an answer to give or something real to share. Otherwise, I lurk quietly and listen.

The Business Plan Is Wrong
My business plan focused on training on a specific case of software-embedded Python. The idea was to make ad money on tutorials and the occasional example script. It failed.  Some research as to why was in order.

Here's what I noticed. Python is embedded in a lot of software projects. Blender, Inkscape, GEdit, Houdini, and Gimp are a few that come to mind. Those projects reaped the benefit of hundreds of extensions and plugins. These improvements may not have happened to this magnitude had the developers not made the decision to embed Python into their code bases.

However, a few Google searches on tutorials for Houdini Python, Inkscape Python, and so on produced some interesting results. Results ranged from single blog posts to master classes. What I did not find were successful businesses based solely on script training for a specific application.

There is a reason for that. Once you know a programming language, any good developer will pick up what they need as the need arises. This isn't to say tutorials are a waste of time. However, most learning comes from looking at examples and API references, asking questions, and writing your own code.

The Future of Blender Python Tutorials
My time spent working on Blender Python Tutorials was worth it. The site is a good resource and I'm a better programmer for having done it. It's also my way to give back to the Blender community that made such an excellent 3D package free for me to use.

However, there is only so much further my tutorial site can go. There is still more Youtube work to be done. Aside from that, the focus will shift more to developing software that's useful and solves real problems. Come to think of it, there might be a business plan in that.

Monday, May 30, 2011

Animation, Legacy Code, and Javascript Challenges


Intro
Getting turned down for a job stinks because rejection stinks. Then again, fertilizer also stinks but it helps things grow. In that sense, rejection is a character builder. Besides, if better web developers than me weren't getting hired to work at some of these companies, there would be no CSS or Javascript examples to "view source" on. Patience may be a virtue but it sure is nice having projects to make that virtue attainable. So let's talk projects.

Animangler
The Mesh Mangler script roughs up 3D meshes by moving the vertices in random directions to one extreme or another. Animangler is basically the same script but with an animaion focus. By creating shape keys and mangling those, it makes it easy to animate weird floating blobs that morph in interesting ways. It's a pretty simple script thanks to the hard work that Blender developers do to make these APIs available for people like me to play with.

Legacy Blend
Getting boring chores out of the way is liberating once done. That's the best way to describe the process of updating tutorial files and making blend files for the old Blender 2.49 tutorials. Occasionally, people do still make inquiries in the Blender Artist forums about that API which makes it worth keeping those old tutorials around awhile longer.

A Cleaner Uncle Squirrely Front End
The Uncle Squirrely project would be better if it's front end code was free of server side PHP logic. It's a very doable task given the right mix of Ajax, JQuery, and JSON. However, it's also a challenging project that pushes my own limits. This limit pushing is a good thing for me as a developer.

The Coming Week
The coming week's challenges will be a continuation of Javascript research, getting hands on with practical Internet marketing and more Python work. Since I'm still in the running for a Django position at a startup, it works out to be one of those good investments that I'd have ended up doing anyways. Will talk later. Cheers all!

Wednesday, May 25, 2011

C#, MySQL, and Inteview Fun


This was a crazy week. Two job interviews and tech projects kept me going quite a bit. Here's the story.

Reacquainting with .NET.
Since one of the jobs was for C# and ASP.NET, a refresh was in order. The first C# program took half an hour and covered features taught in an Intro to programming course. The ease of refresh was thanks to the fact that Python and Java has many of the same features C# has.

ASP.NET required setting up an XSP development server and writing some quick “code behind”. It was like writing VB form code but with C#. That much was easy. Figuring out how to deploy was harder. Getting C# talking to MySQL was hardest of all.  Finishing that one can wait.

End of the MySQL Stored Procedure Experiment
Speaking of MySQL, the stored procedure experiment came to a successful conclusion. I buried both SQL code and logic that was in PHP in the database. While burying a single query in a stored procedure offers no performance gains, there are other benefits for the Uncle Squirrelly project. The PHP code is cleaner and the overall application is more secure. Despite these gains, However, I still have no intentions of merging that git branch. If it ever went back in production, MySQL permissions for stored procedures could become an issue.

Better CSS Menus
Studying the source of other web sites brought to my attention a better way of handling menus in Blender Python Tutorials. Combining unordered lists and CSS makes for a nicer menu setup with consistent control of margins and padding. Another site had a CSS text rollover effect that also got implemented.


So that was my week. It was job interviews and tech work and I had fun. I look forward to more interesting things in the coming week.

Saturday, April 30, 2011

Site Design, Video Tutorials, and Mesh Mangling


I got a lot done this week.

On Site Redesign
First off, I redesigned the site. I replaced the table layout with div tags and CSS positioning. I also put in graphics, rounded borders, and a few other changes to the overall site look. It looks a lot better.

On My First Video Tutorial Screencast
I posted a Hello World video tutorial to youtube and the web site. It wasn't easy. Being on Ubuntu meant figuring out XvidCap, Sound Recorder, Audacity, and Avidemux to get the job done. The final result isn't perfect because of the stick mic I used. Thankfully, Youtube made getting it online and on the site the easiest part.

On Mesh Mangling and Creativity
I made a simple mesh mangler tool. It moves around parts of a 3D object randomly and has a slider to control how badly you want it to be messed up. It's a good way to make things look beat up and broken. It can be used for crinkling paper or rumpling up cloth for example.

My motivation for the mesh mangler is I wanted to move beyond tutorials and just make stuff. So I figured I'd do a small project just for fun. Example scripts is where I want to take Blender Python Tutorials down the road. Tutorials are generally a good way to start off but I think experimentation, curiosity, and learning from others is a better way to learn in the long run.

Saturday, April 16, 2011

Making Decorators and Taking Advice

Decorators for Web Service Data Collection
There are a lot of funny things that can happen when pulling web service data for the Uncle Squirrely project.  Connections failures, page mismatches, or general web service errors can hit without warning.  These can cause my database update scripts to crash and burn. 


Because of the apparent randomness of the errors, the best response is to make reattempts.  This requires a "re-attempt" loop.  The problem is that wrapping these loops around existing logic and exception handling can be messy.

This is one area where Python decorators shine.  With a decorator, I can wrap the entire web service method into a separate object that takes care of the reattempt business for me.  That way, I can give random connection failure a second or third chance to recover without having to clutter up the code.  The RecoverWSExceptions class I wrote was extremely useful in keeping this all clean for me.

Blender Python Tutorials Advice

I asked the Blender Artists community what I could do to make Blender Python Tutorials better.  Their advice was to add blend files and screencasts.  Adding blend files was easy.  It was just a matter of creating the files, adding code, and modifying things to ensure they would work with the new Blender 2.57 release.  Piece of cake.

Screencasting, on the other hand, is hard.  The Ubuntu tools I found were pretty quirky.  The good news is I was able to work through a lot of the technical hurdles for using tools like Audacity and XVidCap.  I guess it's one of those things that are inevitable when you start getting more serious about 3D.  At some point, you're going to have to wear that a/v engineer hat.

And then there's the part I play the performing artist and step up to the microphone.  Doing a good verbal performance is hard.  I've cranked out 3 attempts at the "Hello World" tutorial and I'm not satisfied with any of them so far.  It made me respect performers great and small who put themselves out there doing that for a living.

 So that's about it for now.  It definitely was an interesting week and hope to get new stuff out this week.  Cheers.