text:
Custom NodeTree and NodeCustomGroup and bpy.ops.node.tree_path_parent()
I've done a fair amount of custom PyNode tree scripting for Sverchok, but one thing remains a bit nebulous and i'm hoping someone can shed some light.
The Material node trees have this Group feature which turns the background green and enables an operator on the header to call bpy.ops.node.tree_path_parent() to go to the parent node tree.

The poll / execute code for bpy.ops.node.tree_path_parent() is (...full code link)
@classmethod
def poll(cls, context):
    space = context.space_data
    # needs active node editor and a tree
    return (space.type == 'NODE_EDITOR' and len(space.path) > 1)

def execute(self, context):
    space = context.space_data
    space.path.pop()
    return {'FINISHED'}

For a NodeGroup of ShaderNodeTree space.path becomes a collection of 2 paths.
<bpy_collection[2], SpaceNodeEditorPath>
--- <bpy_struct, ShaderNodeTree("Shader Nodetree")>
--- <bpy_struct, ShaderNodeTree("NodeGroup")>

My simple attempt at declaring a NodeCustomGroup has some superficial success.
My question is how / where can I set the space.path so there's something to .pop(), -- somewhere in the init of the custom node?
excerpt full code here:
class SvGroupNodeExp(bpy.types.NodeCustomGroup, SverchCustomTreeNode):
    bl_idname = 'SvGroupNodeExp'
    bl_label = 'Group Exp'
    bl_icon = 'OUTLINER_OB_EMPTY'

    group_name = StringProperty()

    def init(self, context):

        self.node_tree = bpy.data.node_groups.new('nooobgroup', 'SverchCustomTreeType')
        self.group_name = self.node_tree.name
        # self.node_tree.parent = self
        # space = context.space_data
        nodes = self.node_tree.nodes

        inputnode = nodes.new('SvGroupInputsNode')
        outputnode = nodes.new('SvGroupOutputsNode')
        inputnode.location = (-300, 0)
        outputnode.location = (300, 0)

Wouldn't you do that in bpy.ops.node.group_edit()?

maybe i'm not reading this right, but perhaps group_edit() is limited to standard node trees? -- i've implemented an operator to switch active node tree, and am tempted to also implement a back_to_parent operator..

None of the standard group operators work in custom node trees, we need to implement our own create/edit/ungroup operators. That would be the place to add/pop to space.path. Not sure we can use the existing menu entries but we can use the same shortcuts to run the custom operators.

Thanks @sambler this confirms my suspicion.. pitty it's not so elegant to replace an operator in the node tree header..

see object_nodes ../group_nodes.py by PyNodes' creator for a Python implementation of group_nodes

I'm not sure how useful this is to people (see a sverchok branch which implements this). I'll provide this as answer to my question, because that's what it does -- whether or not this allows for a functional custom node_tree group implementation is still up in the air.

It seems the way to get the node.tree_path_parent to poll True is to repopulate the context.space_data.path with the parent tree at index 0 and the new group node (a tree under the hood) at index 1.
def group_make(self, new_group_name):
    self.node_tree = bpy.data.node_groups.new(new_group_name, 'SverchCustomTreeType')
    self.group_name = self.node_tree.name

    nodes = self.node_tree.nodes
    inputnode = nodes.new('SvGroupInputsNode')
    outputnode = nodes.new('SvGroupOutputsNode')
    inputnode.location = (-300, 0)
    outputnode.location = (300, 0)
    return self.node_tree

class SvGroupEdit(bpy.types.Operator):
    bl_idname = "node.sv_group_edit"
    bl_label = "edits an sv group"

    group_name = StringProperty()

    def execute(self, context):
        node = context.node
        ng = bpy.data.node_groups

        group_node = ng.get(self.group_name)
        if not group_node:
            group_node = group_make(node, new_group_name=self.group_name)

        bpy.ops.node.sv_switch_layout(layout_name=self.group_name)
        # context.space_data.node_tree = ng[self.group_name]  # does the same

        # by switching, space_data is now different
        parent_tree_name = node.id_data.name
        path = context.space_data.path
        path.clear()
        path.append(ng[parent_tree_name]) # below the green opacity layer
        path.append(ng[self.group_name])  # top level

        return {"FINISHED"}

However, when hitting the back button (tree_path_parent) the active node_tree isn't set. Why? I suspect it's due to using .clear() instead of .pop() and some loss of information. This means we need to roll our own version of tree_path_parent, to switch the node_tree and then set the context.space_data.node_tree to the desired parent tree.
Something like:
class SvTreePathParent(bpy.types.Operator):
    '''Go to parent node tree'''
    bl_idname = "node.sv_tree_path_parent"
    bl_label = "Parent Sv Node Tree"
    bl_options = {'REGISTER', 'UNDO'}

    @classmethod
    def poll(cls, context):
        space = context.space_data
        return space.type == 'NODE_EDITOR' and len(space.path) > 1

    def execute(self, context):
        space = context.space_data
        space.path.pop()
        context.space_data.node_tree = space.path[0].node_tree
        return {'FINISHED'}

Bottom left in the screenshot i prepended the operator button for node.sv_tree_path_parent.

have there been any improvements to the Custom Node Group since this was posted?

authors: Кирилл Карпов


text:
Bad looking motion blur with cycles motion blur and vector blur
I currently have a simple scene in blender consisting of a particle emitter with thin rectangular prisms as particles.  They have a pretty fast speed, and it's causing some terrible looking artifacts in the final renders.
I've tried this with standard vector blur with compositing nodes in blender:

And I've tried this with the basic motion blur option available in Cycles:

This looks really great as a still image, but as soon as I actually go in and press the "animate" button instead of still render, it starts to fall apart.

And in my current revision, the Motion blur setting makes frames horribly messy and doesn't seem to know where the object is going.  Blurs are curved instead of linear like in the still image.

I've never had a problem like this before where the animation view looked different than the still image view.  What's going on, and how can I fix it?
Here's a link to my blend file.
EDIT: Fixed by nik10110
Here's a gif:

This might be a bug...

Any idea on how to get around it?  I'm trying to avoid sampled motion blur, but I have a feeling I'm going to need to use it.

Your particles seem to be rotating a tad in-between the frames (bug in particles?)
The solution is to turn on rotation for the particle system, and leave the values at 0.

As for having different results between render and animate, try baking the particle system.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Workaround for 'Inherit Rotation' in armature?
I'm trying to export a bone animation. I've followed a lot of the suggestions found in this helpful tutorial, with success. Near the top, they suggest that I avoid unchecking the 'Inherit Rotation' box on any bones, as it will not export properly. They also suggest the following vague workaround:

There's a tricky workaround for this, which is creating a helper bone
  which the bone that you don't want to rotate will copy its rotation.

Can someone explain this workaround in more detail for me? If you're familiar with the armature created by the Rigify add-on, I'd like the bone called 'spine' to not rotate with the bone called 'hips', but I would still like 'spine' to follow 'hip's position. How can I achieve this without unchecking Inherit Rotation?
Update: I've included the .blend file here. The bone that has 'inherit rotation' unchecked is the 'spine' bone. I'd like to be able to use the workaround on that bone. When I load this model into Assimp, his whole upper body rocks right and left (as if the spine bone was inheriting the rotation of the hips bone).

I can't tell you how to solve your problem but I think I can tell you about the helper bone.
Long time ago I implemented a bvh importer for another software (not blender), to get it working with the rotations given in the bvh file I had to add an helper bone for each existing bone.
A zero length bone (no influence to the mesh) placed at the origin of the original bone, and obviously the original bone must be parented with the helper (original child, helper parent), all the rotations are applied to the helper only.

I looked at your file, there was a warning triangle in Motion Paths, need to re-calculate or re-calibrate the motion paths to make it walk more smoother.
I think the idea is that you have to re-do it when you change positions of the bones or if you add in something new.

The Active data frame that looks like a frame of the bones. There was a triangle in Motion Paths Around Frame or In Range. I re calculated the motion mesh and it walks more normal after update of paths . I am using blender version 2.71

I don't understand. Does the warning with motion paths have to do with the inherit rotation workaround? If not, this should have been a comment on my question, not an answer.

http://img705.imageshack.us/img705/176/arma.gif

Add in a help bone or move your rig so no over lap occur. Some times help bone will help. When exporting, make sure you have mesh or rig of actions in 0 state topology before exporting. Yes , do not uncheck the inherit of rotation since you wanna keep your rotations, bends etc instead of inheriting them from the location where you are going to use your baked animation file. Parent inherits should be from the blender when exporting. http://www.wildfiregames.com/forum/index.php?showtopic=17842&p=278688

When you re-calculate or re-calibrate your motion mesh it will make your baked animation own 0 state toplogy before exporting it out.So when you open it in a new location your mesh does exactly the same as in blender when you test run it.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
DirectX exporter: does the currently-selected action make a difference?
Working in Blender 2.70, I've created a simple model (a box with a few loop cuts) with a simple armature (2 bones). I attached the mesh to the armature and created two animations (actions) and called them 'ArmatureAction' and 'walk'. With the 'ArmatureAction' active and the mesh and armature selected, I export the model.
Here are my export settings:

When I open up the .x file, I see two AnimationSets: both called 'ArmatureAction'. However, if I export with the 'walk' action active, I get two AnimationSets: 'ArmatureAction' followed by 'walk'. Edit: In this case, the ArmatureAction animationset is made up of 865 lines whereas the walk animationset is only 289 lines. The walk animation has fewer keyframes, but I thought that it exported every frame, regardless of whether it's a keyframe. In that case, the discrepancy might indicate an issue.
Does the currently selected action make a difference when exporting the file? I'm using Assimp to load these files into another piece of software and I'm having trouble getting the 'walk' animation to show up at all.

Short answer: Yes, it does matter.
Long answer: Yes, but not that much. Also, my file was broken for a different reason. The reason the walk action wasn't showing up in the exported file was that it was tied to the Cube mesh as well as a fake user. If the walk action had only one user (a fake one), then the "Attach Unused Actions to First Armature" option would have properly created this animation in the .x file and attached it to the Armature.
In my file, the walk action was not unused because it was tied to the mesh. The exporter created an animation for it and attached it to the mesh, not the Armature. This action took up fewer lines in the .x file because there were no keyframes on the mesh itself, so the exporter didn't export any.
The moral of the story:

Make sure your actions all have fake users
Make sure your actions don't have any extraneous users


text:
How to fill a hole in face?
I have this bit of wall here:

As you can see, it is a window frame and I want the hole between the wall and the frame to be filled. I have searched it on youtube and so on but all I can find is tutorials for creating circular holes...
Thanks for help!

There is no one set way to do this. It depends on what you are going for, what you are modeling or any special cases you are adhering to, etc.
In your case here, since you have basically two flat surfaces, you can add supporting edge loops to the outer mesh and join the matching edges together by selecting the edgeloops and manually filling each one with F, the images differ a bit but I think you get the point. (Also, your flat outer mesh does not seem to need so many loops at the moment, you can remove some.)

In the example above you can also bridge the two edge loops by using Ctrl + E > Bridge Edge Loops after selecting the outer and inner edges to connect. This only works when the amount of edges are equal in both loops, but it will give a nice and cleaner result.
Or you can just select an edgeloop and use Alt+F to fill the gaps. (I added an edgeloop to the middle of the frame in the image below before filling and aligned it accordingly with the other mesh so it stayed flat.) You can do the same or use one of the existing ones depending on what you are going for.

Thank you! That really helped me. I used the first suggestion you had. I also tried the one with the edgeloop-thing but I didn't got it to work. The window-frame did not become selected when I used edgeloop-select, just one side. Why is that?

@theva use Shift to select several times. After you use Alt and select the first edge loop or a part of it, hold Shift and do the same for the other(s) or you can select the edges or vertices one at a time.

When the split numbers match, you can use edit > edges > bridge two edge loops. First image in this answere could have been done with the bridge tool.

@RóbertLászlóPáli I know, I just wanted to make it explicitly applicable to OP's use case while showing that some of the geometry could be removed. Feel free to create an additional (more specific) answer.

@iKlsR "I just wanted to make it explicitly applicable ..." That is why I did not create another answer, just thought it is worth mentioning. :) Oh, and I was pretty sure that you knew about it.

@RóbertLászlóPáli, "Any time you feel you can make the post better, and are inclined to do so. Editing is encouraged!"

Note, With 2.68 - selecting both loops and running the bridge tools works too, similar to fill with the advantage that you get quads and have some extra options (note, fixed a bug relating to this r58167)

There is a very powerful and useful addon in blender called "Looptools" which can do this. To see a quick demo, you can refer to this video.
To know how to activate it, watch the video from the beginning .

Can you add a small excerpt in the future on what exactly to do in OPs case. Link only answers aren't recommended as if the link goes, so does the answer.


text:
Theme option for changing relation line for constraints?
I found the current color for constraint relation line is hard to see a little bit.
I've tried to change the "wire"color in the Theme setting panel, but it seems not work for the relation lines.

Thanks for your guide.

possible duplicate of Can I change the default color for Relationship Lines?

Unfortunately, to me, it seems not working for CONSTRAINTS lines. I don't see anything available for it.  :-(

I see your point. It puzzled me a lot, too.
Currently I found that the only way to change the relationship lines for constraints are nothing but the "Grid", not the "Wire".
But, This is really not good for distinguishing the constraint lines from the background, including grid, by doing this. It seems that they are mixed together.
I also hope it may draw dev's attention to improve this. As I said, it's really not good to tweak two different thing by one single option.

Change constraint line colour
This can be set in the File | User Preference… | Themes. It uses a mix of Interface | Axis Colors | Z Axis and 3D View | Theme 3D View | Grid.

Hmm... I think you are half right. As Leon Cheung said, the "Grid" also affect its color partcially. So I bet it is a tweak mixed by Grid and Z Axis? I'm still wondering why it behaves like this...probably kinda bug?

Right you are, updated to include that.

Better late than never!
I was able to change this here:
Themes > User Interface > Axis & Gizmos > Z

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Is there any way to measure angle between edges/faces, or change the angle so that the mesh changes according to the angle we input?
These features are available in some CAD software packages. I haven't come across these features in Blender. Are they available as built-in features or add-ons?
I want to be able to build a model, return later on and edit an Edge or a Face such that it makes a certain angle with some reference.

Can anybody answer this one? I am really stuck here. https://blender.stackexchange.com/questions/312055/how-to-add-similar-slant-vertices-with-same-angle

As well as the ruler and protractor option that was added in blender 2.67, you can also display edge length and angles while you are editing.
In 2.80+ you can find the length and angle options in the viewport overlay options menu.

For v2.7x, you can turn on these options under the Mesh Display panel of the properties region - N

For Blender 2.8 you now find this in Edit Mode under Viewport Overlays: https://i.sstatic.net/LsGJp.jpg (@sambler could you maybe add this as an update to your answer?)

Well, while there might be scripts helping with that, there are at least workarounds:
you can rotate with numerical input, in this example hitting R,-30,RETURN. You can switch on Edge Info >> Face Angle to see what you are doing. And you can rotate around the 3D cursor so you can decide where your center of rotation is (.,, switches back).
An even newer solution would be to select the center vertex last with a shift-RMB and then switch to 'Active Element' as pivot point ALT.). Then you don't even need the 3D cursor for that.
If you need reusable functionality, you can consider using hooks or even armatures to control parts of the mesh from outside.

You can't enter an angle directly to define your edge angle. What you can do though is measuring the angle between two edges with the ruler tool.
Just enable the tool in the toolbar (T) in the edit mode and add 2 measurement points: On the first vertex of the first edge and on the last vertex of the second edge by hitting (Ctrl)+(LMB) and dragging your ruler. Snap them to the vertices by holding (Ctrl). Finally, drag the middle point of the ruler line and drag it to the connection of the two edges (snap it again with (Ctrl)). The angle will be immediately shown.
You can find the documentation here:
http://wiki.blender.org/index.php/Doc:2.6/Manual/3D_interaction/Sketching/Ruler_and_Protractor

Mesh Align Plus (my addon) was designed to do this. Here's how you measure angles (via GIF, text steps below):

Select/Grab 2 points
Select/Grab another 2 points
Hit "Angle of Lines"

You can get to that panel in the 3D View > Tools Panel (T). Selection order is important (first selected is the "Start" of the line. Also, the points can be anything (mesh verts, 3D cursor, average vert position etc.).
Here's another GIF that shows how you can go back later, and match an angle to a measured reference (it's too big to direct link from imgur apparently):
Matching a measured angle (GIF)
Read more at the Wiki, under Measure and Calculate Stuff.

How do I install that into Blender?

@Niloufar, go https://github.com/egtwobits/mesh-align-plus/releases and download the .py file (for v0.4 currently) in the downloads section, then stick it in your Blender Foundation\Blender\2.79\scripts\addons folder.


text:
Is it possible to decrease the face count dramatically so I can continue working without crashing?
I have an issue for the amount of faces I have, I have made a decent looking character with blender (just the head) so far. However, I finally get to the step where I need to add textures and I mark my seams and unwrap, my whole computer freezes and blender crashes. I have ~393, 000 faces.
I would really like to keep my work so far, instead of redoing it for the 4th time, is there any way I could keep my beautiful work of detail and awesomeness but decrease my faces.. but still keep my work, and have it still look good when I render it in Blender Render?
This is how it happened, I have a little issue with hitting the subdivide button alot, not the one in multi-resolution but the other one. And that's because I love detail.
Here is an image of the issue..

I would really like to add hair without the lag too~ :(

You could try the Decimate modifier, but disable it for rendering.

How do I disable it for rendering? (Im a noob)

Press the button that looks like a camera in the modifier. You could also disable the subsurf in the viewport by pressing the button that looks like an eye

Next time you use the multiresolution modifier, wait to apply it. There is a preview slider that allows you to show less details in the viewport, but show more in sculpt mode/render.

Try disabling the subsurf modifier in the viewport by pressing the button that looks like an eye:
Another option is to use a Decimate modifier only in the viewport. (deselect the button that looks like a camera to disable for rendering)

My viewport for some reason doesn't have subsurf on there .

@NikkiPark Have you applied the modifier?

Another option is to set the "Display Type" to "wire" (in the "Object" tab)
Might not be exactly what you want, especially if you're texturing, but thought it would be good to mention it here... I've realized, looking back, that my work would have often been WAY easier if I had remembered the "wire" option, or, even better, the "box" option, on some of my projects... just thought I'd mention that.

One of the better ways to do this in general is to use the Simplify option available under the Scene tab in the Properties window. You can use this to drastically reduce the amount of geometry that is processed in the viewport from one place instead of manually changing each object's modifiers etc.
So, if you have several objects with Subsurf modifers, you can just tick it and set the level to 0, it is fairly intuitive. You can also see from the Child Particles slider that it can be handy when dealing with hair as well.

Thank you but would it keep my detail and shape the same?

@NikkiPark It doesn't affect your mesh in any way. It only allows you to reduce the polycount of your entire scene from one place. It does basically the same thing as hiding the subsurf modifier in your case here, just better. The settings also persist when rendering so you can get quicker test renders as well. Once you need your original geometry back, set the values back to normal or turn it off. Try it and see.

The thing is it did not have any affect when I just tried. Do I select the object and do it or do I need to have no objects selected?

@NikkiPark you need to have a subsurf modifier on an object for it to take effect, you don't need to select anything as it affects the entire scene. Try doing it with an object (or even better several objects) that has that modifier and then set the Subdivision: value in the Simplify panel to 0 to see how it works.

Sadly, It froze again when I tried to Unwrap it. It was a bit faster however a lag was still seen.

@NikkiPark if your geometry count is already really high, it is hardly of any use. as I said, it is like a control panel for your entire scene. I wouldn't really recommend the Decimate modifier either. My only recommendation is to try and keep your model polycount reasonable, having it so high doesn't always mean it will be smooth or polished and it is next to impossible to add details later or texture, rig, animate etc. At this point, you might want to consider retopologizing your mesh. Also, you should wait before applying modifiers.

Is there a good site you could recommend for retopologizing it?

@NikkiPark you can browse through the retopology tag on blendercookie.com

You may want to consider retopology. Once a high poly mesh has been created it is common to use it as a guide to creating a low poly mesh that is easier to work with.

Thank you.I would consider but I only know how to mold with sculpt mode.

This blendercookie tutorial explains retopology and the tools to use.


text:
Creating game models for android
I've been exploring game development for a while now. I have created a small prototype but the models that I downloaded from the internet were too heavy for its small computational power. I have discovered how I could avoid the use of shaders by baking textures and shadows in blender. But I'm still not proficient in optimizing downloaded models for the internet. Basically many models on the internet contain too much detail on the surface but if I will just use textures, I don't require so much detail.

Can someone help me in to understand how I should convert downloaded models, remove extra detail and make it optimized for my use.
My goal is to not have so much detail, I want to show models only from a distance and from only one view. What other optimizations can I employ in this case? Reasoning suggests that we are just using one view I should be able to somehow remove other useless details? How should I do that.
This problem seems very common for android/iPhone developers, which makes me believe that there should be an automated solution to do this and create some low poly, low detail, baked textured models. Is there??

I don't have much experience in this field so I'm using my intuition to guess what could be done. Please point me in the right direction so that I can learn the topic better.

Some tips here - How do I make a model resemble one with low poly count?

Often, when you make a model for a computer game, you start out by making a high poly model. Then, from this, you make a lowpoly model that is going to be used inside the game. This is almost always a manual process and it is called retopology. After that you can bake both diffuse texture, ambient occlusion and normals from the highpoly to the lowpoly texture. You will find many many tutorials on this.
In your case, you already have the highpoly model. So do a lowpoly version and start baking.
There are numerous ways to create the lowpoly version.

Create the lowpoly mesh from scratch, extrude new vertices and snap them to the faces of the highpoly version. Fill with faces.
Create a grid of new vertices, and use the shrinkwrap modified to make them fit the highpoly model.
CGCookie have a plugin for this, Retopoflow (previous contours-retopology): https://cgcookiemarkets.com/all-products/retopoflow/
BSurfaces allows you to paint with strokes to create the lowpoly model.
The decimate modifier can automaticly reduce the complexity of a highpoly model. But almost always it must be manually corrected with one of the other methods.
more...

A quick youtube search found this (looks ok):
http://www.youtube.com/watch?v=eaqYqkjimD8
Blender cookie have many tutorials on this subject, but not all are free:
http://cgcookie.com/blender/page/2/?s=retopology&s_type=tutorials
A super fast tutorial on making a highpoly model super lowpoly:
Step 1. Make your lowpoly model match the outline of the highpoly. Like this:

Step 2. Simple UV-unwrap of the lowpoly (go into edit mode, select all faces and hit U). Mark appropriate edges as seams with Ctrl-E to cut it up. Assign a new image to it.

Step 3. Bake normals to the lowpoly texture like this. Select highpoly, also select lowpoly (select the lowpoly last). Set settings like in the screenshot and hit bake. Save the image as the normal map.

Step 4. Change Bake mode to AO and hit bake again. Save out image.

Final result when combining these two maps into one material in blender. Of course, this will require a shader with a normal texture, but I am pretty certain that JME has it.

This mini-tutorial is very short but it should make you search for more help (or ask questions) on more specific topics (like: how to UV-unwrap a model).
As for your other question. I don't know of any technique to make this more automated.
The dolphin submarine is of my making.

Great this really helped. Could you also guide me regarding point no 2. Can I somehow exploit the fact that I will use only one view of my models. Should I use planes and apply baked textures on one sides.
Secondly do you know what bottlenecks prevent automating the  conversion of 3d models to planes with simple textures. The idea is to generate a lot of low poly models (whose only one side is texture baked and applied to planes) with the use of a script.. This can save a lot of development time, etc

If you are patient, I will make an example an update this answer this evening, when I get home. I will make a really simple flat mesh only showing the outline and then bake to it.

That would be awesome.. Thanks for much needed help

That was excellent but if I wont use lightening.j3md, I would use only unshaded texture in jME which doesn't have any option for applying normal maps. How will that affect my final results. To my best understanding, I must use Full render bake for baking AO and shadows..

Exactly, make a full render instead of (or maybe together with) AO. Skip the normal bake. As you see, there are many bake modes, exepriment and find out what works for you. If your models are going to rotate, it may be best to use AO+texture (and crank up the contrast in an image editor). Also, try checking the normalized checkbox when baking AO.

Hi how exactly did you create the low poly model that matched the outline the high poly one??

I guess you need som basic blender modeling knowledge. Try this: http://cgcookie.com/blender/cgc-courses/blender-basics-introduction-for-beginners/ Lesson 3 covers modeling.

I have seen those videos. Is there any automated process to generate such outline except manual snapping???

If you really have a restricted set of viewing angles for the models you might want to use a sprite-sheet instead of full 3d models. A sprite-sheet consists of pre-rendered views of your models from any viewing angle permitted by the game.
This can reduce computation by requiring only that you use a lookup table to cross reference the model orientation with the position of the pixels on the sheet. It's a technique still used by large mobile-oriented game companies.
There is a Blender plugin called Spritify aimed at doing exactly this.

Thats what I was looking for for this particular query. But does the lookup table thing implemented(some API) in game engines like jMonkey or do I have to do it manually??

I'm not familiar with jMonkey. Yes there is some work involved with Spritify, but if you find yourself using this method repeatedly you will write a script to take care of any labour intensive parts in your workflow.

Hi, I have installed this plugin but how should I use this plugin??

@simar, there is a support thread at blenderartists.org by the plugin author, I suggest you read it and then if you still have problems ask questions there.


text:
Scripted NodeFrame does not attach children until nodeview is updated
This snippet can be run from Text Editor to get an idea of what I mean.
import bpy

nt = bpy.data.materials['Material'].node_tree
nodes = nt.nodes

a = nodes.new('ShaderNodeBsdfDiffuse')
a.location = 0, 0

b = nodes.new('ShaderNodeBsdfDiffuse')
b.location = 200, 0

f = nodes.new('NodeFrame')
f.location = -200, 0

a.parent = f
b.parent = f

That produces this initially.

only when i move the mouse inside the nodeview does the Frame update its visual representation.

I would love some suggestions. The code/Operator that we execute in Sverchok has the NodeView context and an edit_tree if that helps.

Have you tried to update your scene or tag your area

If the operator is executed within the right context, it will update automatically (without any issues), even without tagging the area to redraw: https://gist.github.com/p2or/b92d0859c68ac78673a2d0bedb2af09f Is your actual goal, running that from the text editor or another area?

@p2or i think your snippet works because you are calling bpy.ops.node.add_node(bl_idname), my  script builds an entire nodetree using nodes.new(bl_idname), which doesn't have the same scene update behaviour.

Updated the gist using new(). Does that work for you? @zeffii

Ahh, now I get it. Updated the gist again. I think in this case adding context.area.tag_redraw() (as @J.Bakker suggested) does the trick @zeffii

weird. that doesn't snap the frame either. (until i move the cursor over the frame... which is the behaviour I started out with) . haha.. sorry I must be thick or something :)

You are right, that doesn't help updating the UI neither. For now I can't find a better way than adding bpy.ops.node.select_all() at the end... (updated again) @zeffii


text:
2D 'POST_VIEW' drawing with gpu.types.GPUShader(vertex_shader, fragment_shader)
I can use gpu.shader.from_builtin("2D_UNIFORM_COLOR") to draw a square to a view (the nodeview), and give it a single color, but I want to use a custom shader. Does anyone have an example of POST_VIEW drawing in 2D using vertex_shader and fragment_shader with gpu.types.GPUShader:
vertex_shader = """
    in vec2 pos;

    void main()
    {
        gl_Position = vec4(pos.x, pos.y, 0.0, 1.0);
    }
"""

fragment_shader = """
    void main()
    {
        gl_FragColor = vec4(1.0, 0.8, 0.8, 1.0);
    }
"""
x = 0
y = 0
w = 150
h = 60
background_coords =  [(x, y), (x + w, y), (w + x, y - h), (x, y - h)]
background_indices = [(0, 1, 2), (0, 2, 3)]

shader = gpu.types.GPUShader(vertex_shader, fragment_shader)
# shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
batch = batch_for_shader(shader, 'TRIS', {"pos": background_coords}, indices=background_indices)

shader.bind()
batch.draw(shader)

..which is just about the most basic shader I can come up with.

things i learnt:

to get the basic vertex shader working I needed to remove the call to shader.bind() .
if your shader gives a message

shader.uniform_float("whatever", ....) not found

it appears to be talking about the constant not being used in the shader, so comment out any shader.uniform_*s that you aren't using.

Unlike 3dview, NodeView does not have:
matrix = context.region_data.perspective_matrix

so in the callback one option is to use gpu.matrix.get_projection_matrix(), it looks something like:
def advanced_grid_xy(context, args):

    geom, config = args
    coords, indices = geom.coords, geom.indices

    matrix = gpu.matrix.get_projection_matrix()
    shader = gpu.types.GPUShader(config.grid.vertex_shader, config.grid.fragment_shader)
    batch = batch_for_shader(shader, 'TRIS', {"pos": coords}, indices=indices)

    shader.bind()
    shader.uniform_float("viewProjectionMatrix", matrix)
    ...
    batch.draw(shader)

that works with this vertex_shader
vertex_shader = '''
    in vec2 pos;
    uniform mat4 viewProjectionMatrix;

    void main()
    {
        gl_Position = viewProjectionMatrix * vec4(pos.x, pos.y, 0.0f, 1.0f);
    }

'''

nice.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How to detect if Blender is currently rendering
I would like to hide certain parts of the UI automatically as soon as the user hits the Render Animation button.
I'm looking for something similar to bpy.context.screen.is_animation_playing  but specifically for Blender's render state. is_animation_playing does not evaluate to true if the scene is being rendered.
To detect if Blender is rendering we can set a Python property by attaching functions to the event handlers of render_init, render_cancel and render_complete. I have tested these, they work.
_state = {"is_rendering": False}

@persistent
def set_render_state_true(scene):
    _state['is_rendering'] = True

@persistent
def set_render_state_false(scene):
    _state['is_rendering'] = False

...

bpy.app.handlers.render_init.append(set_render_state_true)
bpy.app.handlers.render_cancel.append(set_render_state_false)
bpy.app.handlers.render_complete.append(set_render_state_false)

...

if _state['is_rendering']:
    layout.label(text="This panel is disabled while rendering")

I'm wondering if there's a less bloaty way to detect this. A single property lookup would be great.


text:
How to get the final volume & area of all selected objects (ignoring some faces)?
The 3D print toolbox currently only outputs the volume/area of all faces.
How can I get the volume of selected mesh objects, ignoring certain faces?

Asking on behalf of a user who mailed me.

This can be done using the Python API to get the mesh with modifiers applied, then applying the transform matrix.
The following script applies to all selected objects, showing a popup with the final volume. Not that it does not use units or scene scale.
See is_face_volume for the method of checking if a face should be included in volume calculations.
import bpy
from bpy import context

# Quick way to test with/without hidden faces
USE_FILTER_FACES = True

def report_info(title="", message=""):
    # show in console
    print(title, message)
    # show in popup
    def draw_cb(self, context):
        self.layout.label(text=message)
    context.window_manager.popup_menu(draw_func=draw_cb, title=title, icon='INFO')

def is_face_skip(f):
    """Ignore faces that pass this test!"""
    return f.hide is False
    # You may want to filter based on material.
    # return f.material_index == 0

def bmesh_from_object_final(ob):
    import bmesh
    matrix = ob.matrix_world
    me = ob.to_mesh()
    me.transform(matrix)
    bm = bmesh.new()
    bm.from_mesh(me)
    if USE_FILTER_FACES:
        faces_remove = [f for f in bm.faces if not is_face_skip(f)]
        for f in faces_remove:
            bm.faces.remove(f)
    return (bm, matrix.is_negative)

def volume_and_area_from_object(ob):
    bm, is_negative = bmesh_from_object_final(ob)
    volume = bm.calc_volume(signed=True)
    area = sum(f.calc_area() for f in bm.faces)
    bm.free()
    if is_negative:
        volume = -volume
    return volume, area

def main():
    volume = 0.0
    area = 0.0
    object_count = 0
    for ob in context.selected_objects:
        if ob.type != 'MESH':
            continue
        volume_single, area_single = volume_and_area_from_object(ob)
        volume += volume_single
        area += area_single
        object_count += 1
    volume = abs(volume)

    report_info(
        title="From %d object(s)" % object_count,
        message="Volume: %.4f, Area: %.4f" % (volume, area),
    )

if __name__ == "__main__":
    main()

The Object.to_mesh method only takes in the preserve_all_data_layers and depsgraph parameters on Blender 2.8 with the 3D Printing Toolkit addon installed. Am I missing something still?

Updated for Blender 2.93


text:
Blender's progress reports are flooding the terminal, how to disable?
Import OBJ uses the progress_report module, which prints out a lot of information into the console, how can this be silenced when called from a script?

Asking on behalf of a developer who emailed me :)

To quiet the output you can override progress_report's print function, after this is done, any use of the progress module won't print to the terminal.
The following examples show how you can disable printing on startup using the command line argument --python-expr, the same code can be run from your own scripts too.
2.7x stable:
blender --python-expr "import progress_report; setattr(progress_report, 'print', lambda *_, **__: None)"

Master and 2.8x
blender --python-expr "from bpy_extras.wm_utils import progress_report; setattr(progress_report, 'print', lambda *_, **__: None)"

Note, this is known as a monkey-patch and is generally considered bad practice in Python, longer term we should probably have a way to manage progress output for import/export scripts.


text:
How to run an external command, showing its progress without locking Blender? (Escape to cancel for eg)
Currently if you run an external process from Python the command and locks  Blender until it finishes, eg:subprocess.check_output(["sleep", "2"]).
Whats the best way to wrap an external call in way that the user can see whats happening, and can escape from if its taking too long?

Note, am investigating a good way to do this, asking Q since this seems generally useful.

External processes can be run while collecting their output using non-blocking file reading.
This example uses a mix-in class (works the same way as Import/ExportHelper) which you can subclass to create your own operator that runs a command.
Each line printed by the external application shows in the header,
and pressing escape kills the process.

Notes:

For reliable updates, the process your calling may need to explicitly flush the standard output (sys.stdout.flush() in Python).
This only works with a recent build & upcoming 2.77 (a minor change was needed commit).
Unfortunately, non-blocking reading from a processes requires some black magic with ctypes.Though it may be supported in Python3.6).
In practice you may want to have a cleanup operation when canceling. (if the process works on temp files for example).

Example script:
"""
To test this operator, run the script, then open operator search (space-bar)
to execute: External Command Example
"""

import subprocess
import os

# ----------------------------------------------------------------------------
# Portable non-blocking pipe.
#
# This is really black magic on ms-windows!

if os.name == "nt":
    def pipe_non_blocking_set(fd):
        # Constant could define globally but avoid polluting the name-space
        # see: https://stackoverflow.com/a/35052424/432509
        import msvcrt

        from ctypes import windll, byref, wintypes, WinError, POINTER
        from ctypes.wintypes import HANDLE, DWORD, BOOL

        LPDWORD = POINTER(DWORD)

        PIPE_NOWAIT = wintypes.DWORD(0x00000001)

        def pipe_no_wait(pipefd):
            SetNamedPipeHandleState = windll.kernel32.SetNamedPipeHandleState
            SetNamedPipeHandleState.argtypes = [HANDLE, LPDWORD, LPDWORD, LPDWORD]
            SetNamedPipeHandleState.restype = BOOL

            h = msvcrt.get_osfhandle(pipefd)

            res = windll.kernel32.SetNamedPipeHandleState(h, byref(PIPE_NOWAIT), None, None)
            if res == 0:
                print(WinError())
                return False
            return True

        return pipe_no_wait(fd)

    def pipe_non_blocking_is_error_blocking(ex):
        if not isinstance(ex, PortableBlockingIOError):
            return False
        from ctypes import GetLastError
        ERROR_NO_DATA = 232

        return (GetLastError() == ERROR_NO_DATA)

    PortableBlockingIOError = OSError
else:
    def pipe_non_blocking_set(fd):
        import fcntl
        fl = fcntl.fcntl(fd, fcntl.F_GETFL)
        fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
        return True

    # only to keep compatibility with nt version
    def pipe_non_blocking_is_error_blocking(ex):
        if not isinstance(ex, PortableBlockingIOError):
            return False
        return True

    PortableBlockingIOError = BlockingIOError

# end magic!
# ----------------------------------------------------------------------------

class SubprocessHelper:
    """
    Mix-in class for operators to run commands in a non-blocking way.

    This uses a modal operator to manage an external process.

    This class defines:

        process: The running process object.

    Subclass must define:

        command: Sequence of arguments to pass to subprocess.Popen
    """

    @staticmethod
    def _non_blocking_readlines(f, chunk=64):
        """
        Iterate over lines, yielding b'' when nothings left
        or when new data is not yet available.
        """

        fd = f.fileno()
        pipe_non_blocking_set(fd)

        blocks = []

        while True:
            try:
                data = os.read(fd, chunk)
                if not data:
                    # case were reading finishes with no trailing newline
                    yield b''.join(blocks)
                    blocks.clear()
            except PortableBlockingIOError as ex:
                if not pipe_non_blocking_is_error_blocking(ex):
                    raise ex

                yield b''
                continue

            while True:
                n = data.find(b'\n')
                if n == -1:
                    break

                yield b''.join(blocks) + data[:n + 1]
                data = data[n + 1:]
                blocks.clear()
            blocks.append(data)

    def _report_output(self):
        stdout_line_iter, stderr_line_iter = self._buffer_iter
        for line_iter, report_type in (
                (stdout_line_iter, {'INFO'}),
                (stderr_line_iter, {'WARNING'})
                ):
            while True:
                line = next(line_iter).rstrip()  # rstrip all, to include \r on windows
                if not line:
                    break
                self.report(report_type, line.decode(encoding='utf-8', errors='surrogateescape'))

    def _wm_enter(self, context):
        wm = context.window_manager
        window = context.window

        self._timer = wm.event_timer_add(0.1, context.window)
        context.window.cursor_set('WAIT')

    def _wm_exit(self, context):
        wm = context.window_manager
        window = context.window

        wm.event_timer_remove(self._timer)
        window.cursor_set('DEFAULT')

    def modal(self, context, event):
        wm = context.window_manager
        p = self._process

        if event.type == 'ESC':
            self.cancel(context)
            self.report({'INFO'}, "Operation aborted by user.")
            return {'CANCELLED'}

        elif event.type == 'TIMER':
            if p.poll() is not None:
                self._report_output()
                self._wm_exit(context)
                return {'FINISHED'}

            self._report_output()

        return {'PASS_THROUGH'}

    def execute(self, context):
        import subprocess
        try:
            p = subprocess.Popen(
                    self.command,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE,
                    )
        except FileNotFoundError as ex:
            # Command not found
            self.report({'ERROR'}, str(ex))
            return {'CANCELLED'}

        self._process = p
        self._buffer_iter = (
                iter(self._non_blocking_readlines(p.stdout)),
                iter(self._non_blocking_readlines(p.stderr)),
                )

        wm = context.window_manager
        wm.modal_handler_add(self)

        self._wm_enter(context)

        return {'RUNNING_MODAL'}

    def cancel(self, context):
        self._wm_exit(context)
        self._process.kill()

# ------------------------------------------------------------------------
# End generic code, now to show an example operator using SubprocessHelper

import bpy
from bpy.types import (
        Operator,
        )

class MyCommandOperator(Operator, SubprocessHelper):
    bl_idname = "wm.my_command"
    bl_label = "External Command Example"

    command = (
        # Run Blender's Python, but could be any other command.
        bpy.app.binary_path_python,
        # pass in a script to execute
        "-c", """
import sys
import time

# Some dummy status reports
status_report = ('Hello World', 'Blender is working!', '... almost done', 'Task Complete!')

for word in status_report:
    # Will show in the info area.
    print(word)
    # flush to ensure we get the output immediately.
    sys.stdout.flush()
    # wait a second.
    time.sleep(1.0)
"""
        )

def register():
    bpy.utils.register_class(MyCommandOperator)

def unregister():
    bpy.utils.unregister_class(MyCommandOperator)

if __name__ == "__main__":
    register()

    # bpy.ops.wm.my_command('INVOKE_DEFAULT')

Update, this now works on windows.


text:
Absolute path of files in Blender (with Python)
Functions such as os.path.exists(image.filepath) fail when Blender uses relative paths, This seems to be because Blender uses // prefix for relative paths, unlike the more conventional ./.
How can standard Python filesystem functions be used correctly on Blender paths?

The // prefix is Blender specific to denote relative paths used within Blender,
To use Python's filesystem functions you'll have to first expand this using:

bpy.path.abspath, to replace os.path.abspath
bpy.path.relpath, to replace os.path.relpath

eg:
filepath_full = bpy.path.abspath(image.filepath, library=image.library)

Unlike ./, which simply expands the current-working-directory (os.getcwd()), Blender supports library-linked files. This means the directory of the current data-block could be a different path then the currently open Blend file.
If you are operating data which the script created, You can skip passing the library argument.
filepath_full = bpy.path.abspath(image.filepath)

Note that this isn't specific to images, it works for movie-clip, sounds, sequencer and text blocks too.

I'm dealing with a different situation, where I just used a StringProperty with the directory setting on to pick out a destination directory. I had one person insisting that there was no need to force an absolute path. Then, tonight, testing my script, it crashed because I had not changed the setting in the file requestor to Absolute Path. This was literally the last bug to stomp out at 2 AM. Thank you - you gave me the answer and it was easy to just wrap bpy.path.abspath() around my StringProperty to always get the full path. Again, thanks!

This may be off topic, but if you encounter the following situation, this may help you.
I was automating the creation of blender files which

Took an existing file,
Replaced some textures, moved stuff around, changed sizes of some objects etc.,
SAVED THE BLENDER FILE TO ANOTHER FOLDER.

I couldn't figure out why in the saved file, all textures had relative paths assigned to them, even though in all possible settings in Blender I set relative paths to False, like the setting User Preferences / File / Save & Load / Relative Paths to [ ] (unchecked) and using bpy.context.user_preferences.filepaths.use_relative_paths = False.
All textures still had their paths in the form '//.../.../...' which was not what I wanted AND those paths were relative TO THE LOCATION OF THE ORIGINAL BLENDER FILE and not relative to the newly saved one.
Then it dawned to me, but this is not documented anywhere, that the problem is not where I had expected it, but rather when the new file is being saved. I used the method bpy.ops.wm.save_as_mainfile() and this method, as it turned out, was the reason. It has an optional argument relative_remap WHICH DEFAULTS TO True and means that THE MOMENT you save your new file, all paths get converted to relative (and relative to the location of the currently open file, not to the location where your new file is being saved to). Hope this saves you some time, it took me hours to figure out.
So, you need
bpy.ops.wm.save_as_mainfile(filepath = YourNewFilePath, relative_remap = False)

Cant upvote this enough.

Ditto - this answer saved me.

Nice, so if you want to toggle the checker box in blender 4.x from Preferences >Save & Load > Blender files > Relative Paths just use  bpy.context.preferences.filepaths.use_relative_paths = True (or False depending what you want). With blender 3.x bpy.context.user_preferences.filepaths.use_relative_paths = True will do the trick


text:
Rendering with NN Interpolation
I have a high resolution texture with only seven colors that I apply to a makehuman model and I want in my rendered result also just those seven colors (plus a black background).
So far I have tried to to deactivate MIP Map and Interpolation, and different filters with small filter sizes in the Image Sampling panel. However, the result is as depicted in the following image:

Further, I tried to deactivate the Anti-Aliasing in the Render options, but still I do not get the desired result:

You see that the color fades, especially on color borders. The rendered image is rather small (160x120), but also if I increase the dimension, the problem remains.

Are you using BI or cycles?

In the current setup: BI.

Deactivating AA and MipMap + Interpolation is the right thing to do. The filters are used with interpolation. The bigger the filter size the smoother the result becomes. But since you don't want any smoothness you should deactivate interpolation. That way you can forget about filters.
Nevertheless Blender seems to sample textures internally with some interpolation.
As a workaround you could use an image manipulation program like GIMP or Photoshop and reduce the colors there. In GIMP you can do it like this: Image > Mode > Indexed.
To automate this task for multiple images you can use BIMP. It is GIMP plugin which is probably already installed. You can find it in File > Batch Image Manipulation...
You can use the filter called "gimp-image-convert-indexed"

Is there no way to deactivate this sampling? The GIMP solution is a bit cumbersome, especially if have a lot of images that I have to postprocess in this way.

Maybe add a note about the Filter Size option as well?

Do you mean the Filter Size option in the Image Sampling panel? There I have tried the smallest value, the largest value and this in combination with every filter - no luck. Also if I check the Minimum Filter Size the result is still not like I want it.

I'm thinking a shadeless material would also help.

I updated my answer for multiple image batch processing.

You could try and make a node setup which quantizes the colors automatically, e.g:

Cycles
You could do this in cycles by using a mix shader to mix diffuse shaders based on your textures:

Set up a material that uses black and white textures as to define which color of diffuse should be used where:

Set the number of samples to 1 in Render settings > Sampling:

Enable the Diffuse color pass in Render layers > Passes:

Use the Diffuse color pass as the output:

As you can see, only the colors specified in the diffuse nodes are used.

I tried your approach and it does definitely restrict the colors in the output picture. Unfortunately I am somehow restricted in the colors. Further, and more problematic, at the borders I still get some other colors.

@Masala You could try using an external batch image processor such as Image magick to do this.

My current solution is to have n textures, render n times and then make a batch postprocessing with an external programm. The problem with this solution is, that the rendering process takes now of course n times longer. Is there a way to render an image with different textures in the compositor?

@Masala I'm not sure what you mean.. Isn't that square one?

Currently, I have a small Python script and one texture for one color. In the script I apply the i-th texture of n and then render the model in a loop (therefore, n renders). The question is, if it is possible to render the model just once, but apply different textures in the compositor, and have n different file output nodes.

@Masala AFAIK, no.

@Masala I thought of a way to do this in cycles, not sure if that will help. It is possible to make a "posterize" node setup in the compositor, but I haven't been successful yet.


text:
Mass replace fonts
I just experienced a nightmarish Blender episode in which I needed to render an  animation with a super tight deadline.
Because of the schedule, I started rendering on several different computers, of which some were Linux machines and others had Windows.
Turns out the fonts I were using did not load up correctly on the Linux machines. It also seems like the "pack external files" doesn't work with fonts anymore? I could make it work by choosing each text layer and assigning the font to it by hand. Because of the large amount of text layers this became a tedious task.
So here's my question:
Is there no way of mass-assigning the font type to text layers? I was hoping it would work in a similar way like materials and other things work in Blender, so that I could select all the text layers and have them all update their font simultaneously.

If packing fonts did work in previous versions, then I suggest you report a bug. (See this question and this video for more info on filing a bug report)
Currently, Ctrl+L to link Fonts does actually work:

However, if for some reason you want more control over font assignment (perhaps to conditionally assigned based on the name or the existing font), a Python script can be made to automate this too - copy the below text into Blender's internal text editor, then with all the text objects selected and the one you want to copy from as the active object (last selected one), click Run Script
import bpy
if bpy.context.active_object.type == 'FONT':
    font = bpy.context.active_object.data.font

    for obj in bpy.context.selected_objects:
        if obj.type == 'FONT':
            obj.data.font = font
        else:
            print(obj.name + " is not a text object")
else:
    print ("Active object is not a text object")

You could do this in Python to make sure you touch all objects in the blend. (not just objects in the active scene).
import bpy

font = bpy.data.fonts.load("//myfont.ttf")

for obj in bpy.data.objects:
    if obj.type == 'FONT':
        print(obj)
        obj.data.font = font

Note the "//" prefix, this means the font will be referenced relative to the current blend file. so it will load on different systems.

If you prefer with gui, this free add on will help works on a lot of font Blender objects, mass font editor


text:
Where can I find the dimensions of an object?
In earlier Blender versions, the "Transform Properties" panel showed the object dimensions (i.e., bounding box: width, height, depth).  Now, it just shows location, rotation, and scale.

Press N to bring up the Properties Panel of the 3D View, the Dimensions are listed below Scale in the Transform panel (bottom right):

Thanks, I had been looking at the object "Transform" panel instead.

In Blender 4.0, hitting "N" shows some tabs to the right (editor in Layout mode).  To show the object dimensions, one has to click in "Item" tab.  But this is not often enough as the corresponding pane is collapsed by default, requiring additional gestures: a) park the mouse pointer near the right border until the mouse curser becomes a left-right arrow; b) press and drag it to expand the panes.  This is a bit hard to find.

While CoDEmanX's answer is still correct for Blender 2.8, you have to have the Modeling view mode (bar at the top) selected and be in object mode for the dimensions to appear in the transform panel.
User serdar.sanri added this information here, however this question pops up first in the google search, so it might help to find this comment here, too.
As of Blender 3.0, Modelling view is no longer required.

In Blender 4.0, hitting "N" shows some tabs to the right (editor in Layout mode).  To show the object dimensions, one has to click in "Item" tab.  But this is not often enough as the corresponding pane is collapsed by default, requiring additional gestures: a) park the mouse pointer near the right border until the mouse curser becomes a left-right arrow; b) press and drag it to expand the panes.  This is a bit hard to find.

I'm in (Blender 4.2) "object mode" I have the "item" tag selected, the sidebar expands/collapses when I press "N", but ATM dimensions are not displayed: Location Rotation Scale only. How to display the dimensions??


text:
Toggle wireframe mode with hotkey
How do I toggle in and out of wireframe mode with my keyboard? Is there a hotkey for this?
I'm a beginner (obviously). I thought I could find this in the "view" menu, but it either doesn't exist or I have horrendous eyesight. Thanks!

In any mode, if you want to switch between wireframe and solid use Z.
You can also use Alt+Z for toggling x-ray.
Alternatively, you can use the viewport header.
Take a look at the manual.

Also to note that "SHIFT+Z", to switch between rendered and solid, only works since Blender 2.69 (AFAIK)

Updated manual link: https://docs.blender.org/manual/en/dev/editors/3dview/properties/shading.html

How do I show both wireframe and solid at the same time?

@AaronFranke sadly you cannot do that directly in the viewport. But you still can show the wire one object while you're in solide mode:
Properties pannel --> Object properties --> Display --> tick 'Wire'

I was looking for a way to toggle the Object Properties > Viewport Display > (Show) Wireframe checkbox (as seen in a video).
Didn't find the answer here, but I figured out (in Blender 3.2.2): right-click on the property name > Add Shortcut. Later we can Change Shortcut or Remove Shortcut.
The main issue is to find a key not already used by default by Blender… the video used ';' but it is already used in 3.2 for Transform Pivot Point. I chose '<'.

First select the concerned objects and Press 4 to go to wireframe mode. Press 5 to get out of it.

If you mean 4 on main keyboard, it will move selected object to 4th 3D layer. If you mean Numpad 4 then it will rotate the view around Z axis in the viewport. I don't have an idea where is wireframe mode related here

The Z key toggles between Wireframe and Solid view in the viewport window. Shift-Z toggles between Render view and Wireframe view.


text:
What is the best workflow for texture painting?
I am a little bit confused about the best workflow for texture painting in blender.
Blender internal has nice ways to do that. Is it possible to paint a color texture in blender internal, use another texture for bump maps etc., work with different uv maps, and then to transfer it to cycles? (perhaps with baking in blender internal first?).
What is your proposal? I actual don't know the best workflow.

It really depends on a lot of things, what you're texturing, how much more work you have to do on it, etc, but the workflow I generally find useful is as follows:

Finish all the modeling
Unwrap the mesh
Use the texture painting features in Blender to paint really basic colors onto the model (this gives you a "map" of sorts, which makes the next step easier)
Export the UVs as an image that you can overlay on the basic diffuse map you just made
Export that basic diffuse map to an image that you can paint on in GIMP or PS.
In GIMP or PS, adjust the UV layout image such that you can lay it over your diffuse map so that you have a more precise understanding of what goes where.
Paint on the diffuse layer, but under the layer with the UV layout on it.
Use that diffuse map to generate bump and spec maps. Usually, I completely desaturate the diffuse map and adjust that until it makes sense as a bump map, and then do the same thing until it makes sense as a spec map, but it's really common that your diffuse map will not be useful that way, in which case:
Repeat steps 6 & 7 to paint spec and bump maps.
Import those into Blender.
???
profit

Note: it's really easy to port images from BI to Cycles, if you understand how they work. The diffuse image will "noodle" into the color input of a diffuse shader, and the bump will "noodle" into the displacement input of the final material output node (though you might want to us some ramps and other stuff to fine-tune it).
The spec one will be the hardest to figure out, because you could do it a couple of different ways, and they will give different results.
You should always (except for specific situations) use a diffuse shader and a glossy shader. The spec map can either drive the COLOR of the spec shader (grayscale), or the GLOSSINESS of the glossy shader, or the FAC value of a mix shader that mixes between a glossy shader and your diffuse shader. Each of these will give different results, so you should experiment and see which looks better.
Bonus: A color image should never go in the color input of a glossy shader. Except for a few rare exceptions, like certain metals, the spec map will be totally grayscale. Even with metals, you probably won't use an image, you'll just set a single color.

THANK YOU !! I could not, for the life of me, figure out how to make it format as a numbered list without just doing it myself... Much better now, thanks.

Np. Here is the documentation for formatting

You may also want to use Blender to paint directly on the model around the seams to touch them up so they are consistent.

Thanks, that's what I intended to communicate with #3 ;-)


text:
How does the GPL apply to code in Blender files? (e.g. Drivers)
It's known that any Python script running inside Blender must be GPLv2+ compatible ***, See the GPL FAQ, but what about driver expressions? Does this mean all my Blend files have to be GPL as well?
What are the implications for having Python code inside a .blend file?
*** if it is to be redistributed

Can you link to where the GPL requirement for scripts is?

@David: http://www.gnu.org/licenses/gpl-faq.html#IfInterpreterIsGPL

Short answer: Yes, the GPL applies to drivers too.
Just as the GPL applies to addons, it applies to drivers (any scripts running inside of Blender). However this doesn't automatically everything you do in that blend file is suddenly GPL.
Consider:

In many cases drivers on their own don't constitute an original work, Obviously you can't copyright 1 + 1, rot / pi or other simple expressions.Exactly what is original enough to be copyrighted isn't totally clear and depends on local laws.
In the case where the client/customer has the blend file, they can see the driver expressions anyway, and use them, however drivers are rarely useful on their own, typically they are only valuable because of their use within a rig and data they reference (the rig, objects etc).
In many cases, the deliverable content from a project isn't a blend file, The finished work may be image / video / exported-model, therefor there is no need to distribute the blend file, a driver can be treated as in house software.

So the main case this prohibits are:

If you made a rig and wanted to charge licensing fee's for using the drivers.While this remains possible, you would have to use a GPL compatible license for the drivers.
If you give a blend file to someone, you could not prohibit them from reusing or sharing a driver-expression in that blend file.

In practice, the drivers in a blend file are plain-text anyway, and not all that useful on their own.

But might mixing the scripts with the .blend file data, also make the blend file GPL?
It's worth looking into this more, however Wordpress lets images in a theme be exempt from the GPL. (Where the theme may contain code & data, this is a precedent where the data is exempt while the code isn't).
http://wordpress.org/news/2009/07/themes-are-gpl-too/

Obligatory - I am not a lawyer disclaimer, however this is how the GPL applies as I understand it @ideasman42

Just as the GPL applies to addons, it applies to drivers (any scripts running inside of Blender).

I disagree.
You are taking the statement too literally imho.
Imho, one thing is the container (Blender) and one thing is the content(the blender file, so to say).
The GPL applies to every script/source you add to the container, not the content.
For the content, what applies is the license related to it, be it texture, model, drivers, and so on, you agreed with Blender Foundation when using Blender.
This is very similar to what game engines do - having your animation code written in a script in Unity it does not mean your game becomes Unity property or its license applies it (otherwise, probably no one is going to use it...) what applies is the license for the content you agreed to when using Unity.
Of course I'm no lawyer so I can be wrong... ;-)

The thing is once you use Python in Blender there is no clear differentiation between addon/driver/exporter.. etc - it's all just Python code. You could make a driver that makes an interface to blender if you really wanted... or implemented a 3D application through the driver. This is why we can't treat drivers as special cases.

I don't see drivers as special case - I set a clear definition between content and container. So, I don't see just python code; I see python code separated by use cases. One use case for the container(Blender) one for the content(the blender file, to be clear). This seems to be supported by the will of B.F. to let the user own the content. If this is not clear, it means there's s.t. wrong about policies, s.t. B.F. should strive to clear, in its own interest and for the interest of the users...

This way, you can have s.t. like: a) use a driver for creating an interface to Blender (extending Blender, so GPL), and b) use a driver for managing animation (blender file, user ownership), and so on... it really depends on use case...

re: "I set a clear definition between content and container" - you may, but this doesn't mean a license does.


text:
Different image textures for one material (Cycles)
With Blender Internal (2.79 and older), you can add a UV layer, assign images to each face, Then enable the materials Face Textures option.
Is there some way to to have a single material and multiple images assigned to different faces with Cycles?
I'm asking this because I'm writing an importer for a format that stores textures and materials as 2 separate values per face, if this is not possible I'll have to split up the material per texture, so I can workaround it if its unsupported.
Update 1): As has been suggested you can blend between shaders,
this works OK for switching between 2 images, however I can't see a good way to do this with 10+ images (probably its possible with a large node setup and mapping nodes, but this becomes quite cumbersome).
Update 2): I've accepted one of the answers, however using blending like this is quite hard to control and not simple to just assign arbitrary images per face (as part of an importer), so I'll likely have to split up the materials per-texture.

I had the same problem and found UDIM.
Check this tutorial: Blender tutorial - Multi-tile UV sorcery from Jason Clarke

The standard way of allowing multiple images to be applied to a mesh in a single material is to use the mix value between two shaders.
This would either need an extra image per texture to act as a mask or you could use the alpha channel of the texture if it had one.
Below, the top image is a red square (aligned to a single face of the uv's) with an alpha channel and below it a solid blue texture, being mixed using the alpha channel of the red texture as the factor (fac).

Which results in:

So you can assign a texture per face, but to my knowledge it either requires another image to act as a mask or an alpha channel to work.
Unless you can generate such a mask per face, in your script, or all images always have alpha channels marking their borders, this probably isn't going to be a viable solution.
Updated Answer:
Similar to the other answer, this method can also be simply extended by simply adding another mix shader for every extra image texture you wish to add. This allows as many textures as necessary to be used within the limits of the cycles texture limit. As per Greg's comments below, I have replaced the mix shader with mix rgb to be more efficient.

Note: In the image above I only use 4 textures to save time. So I use the blue texture (covers the whole uv area) as the base colour. The base colour should be the first image in the node tree for this method to work.

Using so many diffuse shaders is inefficient - for each shader node it has to calculate the shading on that surface. Instead, simply use the Mix RGB node to mix the colours before plugging it into the final single diffuse shader.
http://i.imgur.com/iMyPaOC.png

@GregZaal Thanks Greg, hadn't thought about the efficiency of this, updated the answer as per your suggestions.

You could assign a Vertex Color layer for each texture. Then use the Attribute and RGBMix nodes:

To cut down on layers you could use a channel per texture:

Separating colours from a single layer can be done too but it's a little more complicated:

Damn that's good.

Can this work if you want to have 3+ materials?

I couldn't be sure about the use of that node group, but I've used as many as 12 different colours for texture assignments before. The idea is just to isolate that colour using math nodes, colour ramps, Separate RGB and HSV nodes (which we now have thanks to Thomas ;) ) and using that as a mask/fac for the mix node.
It's not much fun.
A future possibility to allow something like this is implementing something like Object Indexes for each face.

The attribute link is broken.


text:
Rigging convention for limb joint dominant axis?
Typically with bones you would use a dominant access for bending a limb (knee, elbow, finger etc).
When the roll is set you can choose to use the X or Z axis, (Y axis runs along the bones length).
Even though I realize you can use different rotation methods (Quaternion, Axis-Angle etc... which can be less restrictive compared to Euler rotation), its still convenient to have the manipulator aligned so an axis runs along the bones dominant axis for bending.
Is there a convention for rigging here? or does everyone choose differently?

In my rigs, the dominant rotation axis is always X.
It's consistent with Rigify's convention, and less a hassle when using X-Axis Mirror for faster alignment. Could be confusing, though, because visually it's always the Z axis that looks mirrored. So I'd just pay attention to the Z axis when orienting the bones.

For translation bones (like sliders) I use the Z axis, also because of the way X-Axis Mirror aligns symmetrical bone rolls. That is, if the animators use Gimbal transform orientation, they could focus on using the red (X axis) part of the rotation widget, and blue (Z axis) part of translation widget.


text:
How to make a dynamically expanding menu in Blender?
Say we want to navigate a tree structure without knowing all the data ahead of time, is it possible to do this in Blender?
For example, a menu which dynamically loaded a directory hierarchy from the filesystem (without having to scan the filesystem and generate a menu type for every directory ahead of time first).

I think this question is really unclear and think you should edit it to make it more clear.

Added example .

Why is it necessarily a menu, instead of, for instance, a separated popup panel called from a menu?

I can't gotcha what do you want :(

@yhoyo make a menu of the file system where a  subfolder expands as  another menu. The templates menu in text editor is an example of this, to one level. If you put a new file in blender_path/2.79/scripts/templates  it is added automatically to the menu.  As it is now, If you add a new folder into the templates folder, the files of the subfolder are added to the menu, but in the bottom level (along with the folder).   The concept is to make the  "New Folder" item,  (and any folder) a menu so the menu > submenu> subsubmenu > item choice is:  folder/subfolder/subsubfolder/file.

@batFINGER, I think this could be more simple if layout.menu was returning a menu object (so that a property value can be set on the corresponding class instance). Do you know why it is not the case (returns None)?

@lemon agreed.being able to pass properties in UI like you can to an operator would be bloody handy.  On my linux build (the last time I spent too much time on this) I could register  new menu classes (for subfolders)  from the __init__ method, and set the  filepath class property.   Hopefully being able to pass props to menu, or have some ref to the parent menu, to submenu more effectively,  is coming in 2.8.  8^) @yhoyo   Here is a randomly expanding menu example

@batFINGER, so what about a patch at C level? Is it possible? (failed to locate the code for that so far, but if ideasman42 is asking, should consider this is not possible ?)

You may refer to the link below:
https://blender.stackexchange.com/questions/110064/how-to-make-a-dynamically-expanding-menu-in-blender

This can be done using by making use of the context pointer, mapping each row to some data which the menu can access, looking up the chain of open menus.
e.g.
import bpy
import os

# Set these to dir and ID that make sense.
PATH_SEARCH = "~"
CONTEXT_ID = "my_menu_id"

# This operator is just an example, it only reports the `filpath` given to it.
class PathExampleOperator(bpy.types.Operator):
    bl_idname = "path.example"
    bl_label = "Path Example"
    filepath: bpy.props.StringProperty()

    def execute(self, context):
        self.report({'INFO'}, "File: %r" % self.filepath)
        return {'FINISHED'}

class PathMenu(bpy.types.Menu):
    bl_label = "Directory Menu"
    bl_idname = "FILE_MT_dynamic_path_menu"

    _parents = {}

    @staticmethod
    def _calc_path(layout):
        result = []
        while layout:
            layout, payload = PathMenu._parents.get(layout, (None, None))
            result.append(payload)
        result.reverse()
        return result

    def draw(self, context):
        layout = self.layout
        parent_id = getattr(context, CONTEXT_ID, None)

        if parent_id is None:
            # This is the root level menu, use the base path.
            parent_path = os.path.expanduser(PATH_SEARCH)
            # Avoid accumulating indefinitely.
            PathMenu._parents.clear()
        else:
            parent_path = os.path.join(*PathMenu._calc_path(parent_id))

        for filename in sorted(os.listdir(parent_path)):
            # Skip hidden.
            if filename.startswith("."):
                continue

            filepath = os.path.join(parent_path, filename)
            if os.path.isdir(filepath):
                row = layout.row()
                row.context_pointer_set(CONTEXT_ID, row)
                # The payload could be anything, it so happens
                # in this case that the `filepath` makes sense to use.
                payload = filepath
                PathMenu._parents[row] = (parent_id, payload)
                row.menu(PathMenu.bl_idname, text=filename)
            else:
                # Not a directory, show a file.
                props = layout.operator(PathExampleOperator.bl_idname, text=filename, icon='FILE')
                props.filepath = filepath

def draw_item(self, context):
    layout = self.layout
    layout.menu(PathMenu.bl_idname)

def register():
    bpy.utils.register_class(PathMenu)
    bpy.utils.register_class(PathExampleOperator)

    # lets add ourselves to the main header
    bpy.types.INFO_HT_header.append(draw_item)

def unregister():
    bpy.utils.unregister_class(PathMenu)
    bpy.utils.unregister_class(PathExampleOperator)

    bpy.types.INFO_HT_header.remove(draw_item)

if __name__ == "__main__":
    register()

    bpy.ops.wm.call_menu(name=PathMenu.bl_idname)

When you create a bpy.types.Menu object, it has a draw method (as can be seen here) which is called every time the menu is shown. Each submenu is it's own class, and every class needs to be registered before it can be displayed.
While the draw method would have been the ideal place to dynamically generate and register the submenus, attempting to call bpy.utils.register_class from inside the method will result in RuntimeError: register_class(...): can't run in readonly state 'TOPBAR_MT_custom_menu_<id>.
Unless I've missed something obvious here, I'd say the answer is a definitive "not possible". Blender just outright locks itself when displaying the menus.

That said, I came across here because I wanted to dynamically generate the menu classes. If it helps anyone wanting to do the same, here's the code I came up with.


text:
Is it possible to save CMYK renders from Blender?
Is it possible to render to a CMYK image format without any intermediate conversion steps?

Asked on behalf of this questioner:

https://lists.blender.org/pipermail/bf-committers/2016-April/047214.html
http://blenderartists.org/forum/showthread.php?100475-Blender-in-Print-CMYK(also related)

CMYK is a device-dependent color model. This means essentially that if we don't know the device where color will be reproduced, the values expressed in this model are meanlingless, as they aren't enough to provide any colour accuracy.
RGB is also a device-dependent color model.
In theory, both RGB and CMYK images should be always tagged with their corresponding colorspace definitions (usually in the shape of icc profiles) to tell our software's color management whether a colorspace conversion is needed to ensure the proper color rendition.
For practical reasons and to a certain extent because images for the web need to be small, it is commonly assumed that an RGB image without an embedded profile is in the sRGB colorspace.
However, there isn't such assumption for CMYK files: They have to be tagged properly, otherwise you can't know the device where they are supposed to be printed.
To make things even worse, the "device" in this case doesn't only mean the machine where the piece will be printed, but also the type of paper, inks, setup, etc. that will be used for printing.
This means that there's no such thing as "CMYK" if you don't specify "which CMYK", so producing a proper CMYK file from any software requires to know a few things about how the image will be printed.
Failing to anticipate those things will most likely cause you and your printer a lot of troubles and cost you a lot of money, so it's not something you want to take lightly.
In desktop publishing ICC Color Management takes care of these aspects as long as files are tagged properly with ICC profiles. But Blender, as most of the 3D and VFX programs, doesn't support ICC profiles.
So first problem: Blender can't deal with ICCs, so the conversion has to be done externally.
Apart from that, producing CMYK colors from an RGB original is a destructive and irreversible process where a part of the RGB gamut (the non-printable colors) are lost irremediably. For that reason, CMYK is not a very good model for editing if preserving quality and color accuracy is your goal. Converting to CMYK is something you want to do at the very end of your creative process, when everything else is done.
It may feel tempting to skip a step and move to CMYK as soon as possible, but it ends up being a terrible idea as your files will be only good for a single printed output, they will be heavier in size and they will need to be converted back to RGB for any non-printed output, with the huge drawback of having lost a big chunk of their color latitude.
So yes, it is sort of possible to save CMYK right away from Blender with a script like the one proposed here, but it's not really a good idea.
It's more sensible to save your renders in the maximum quality and color fidelity possible (RGB from blender with no further conversions) and adopt a good workflow where the separation to CMYK is done properly with the right tools and at the right moment.
Imagemagick (the tool used for the addon proposed in the other answer) has the facilities for converting to CMYK properly, but it's advisable to perform the conversion on an already saved high quality RGB file taking care of all the parameters required for printed output (size and resolution, colorspace conversion and embedding, file format, etc.)

I really feel like this is a non-answer.

If CMYK is device dependent just like RGB, then converting blindly to CMYK will be at least as good as blindly using RGB without knowing which monitor your image will be on. If we don't have to know which monitor is on the other end of the web, and that's more-or-less okay, then converting to CMYK will at least get us in the neighborhood of the right colors for printing, even if we don't know the printer and paper. Sure, there's a whole "print-making" science, but if the asker were interested in that level of precision, they would ask their coworkers... not us.

The real answer is "No, Blender doesn't know how to convert from RGB to CMYK. You'll have to use a different tool."

@Matt: No, you're wrong. A blind conversion from RGB to CMYK is nowhere near to what printed colours are going to be.
If you choose to ignore colour management completely you're going to produce garbage from your print output. It's not a matter of "level of precision", it's just getting a good print vs. getting useless crap.

Want a simple example? Let's say you don't care about colour spaces so you're going to take any sRGB* image and do a blind separation to an undefined CMYK.
Let's make the RGB image cyan. That's, in that colour model 100% blue and 100% green. 0,255,255 or #00FFFF
Let's say we do that "Blind" conversion, where we don't care about colorspaces, just take RGB cyan and make it CMYK cyan.
Go print that Cyan in ANY printer out there. See what you get. See what you wanted.
Again It's not matter of precision. Different models, different primaries. Ignore that and your printed output will suck.

@Matt the only reason you feel this is a non answer is because you absolutely don't understand colour nor print. Gez's answer is spoken both as a professional print expert with thousands of runs behind his words, as well as absolutely accurate advice. He is 100% correct.

No, you misunderstand. I get it that you have to pick a particular color space to convert to. I'm not talking about blindly converting to some random CMYK profile, I mean choosing a profile that's more-or-less reasonable. We can make some reasonable guesses about what's common and what's going to be closer that just printing sRGB. Is it going to be "good enough?" maybe not, but it might get us in the ball park.

The reason I feel like it's a non-answer is (as stated above) it's irrelevant because Blender can't do that anyway. You might find a script... You might write a script... it might work correctly... it might not work correctly... You should be using a different tool.

@Matt: People is asking about it. People is writing scripts because people ask.
How is this a non-answer if it helps people to prevent mistakes?
How is it explaining why it isn't supported and that it shouldn't be supported in Blender a non-answer? I fail to understand your reasoning.
And you're still wrong about the "ballpark" thing. You can't guess, and assumptions when printing is involved can be incredibly expensive if wrong.
You may think that SWOP is a reasonable profile because presses in America use SWOP, and still screw your prints big time if the device to print isn't SWOP.

Another example? Any HP large format printer. I prints CMYK, but it's not even close to SWOP. Send sRGB and you'll be fine, because the printer software knows how to convert from sRGB (known colourspace) to its own CMYK.

No, this feature isn't supported by Blender.
preface: as mentioned in @Gez answer, its likely you won't actually want to do some automated conversion from RGB to CMYK, however... there may be some situations where an automated conversion makes sense and can be tweaked to fit your needs, in that case, this answer may be useful to you.

Using an add-on and ImageMagick, this can be automated.
ImageMagick will need to be installed and the command convert will need to be in your path.
Save this file as render_cmyk.py and install it via Blenders's add-on preferences.
Once installed, the render output panel will have a checkbox to write out CMYK images along side the image format your rendering to.
When rendering an animation it will create a CMYK version of images written to disk.
If you need to use ICC profiles, these can be passed as arguments too,see ImageMagick's documentation.
bl_info = {
    "name": "Render CMYK",
    "version": (1, 0),
    "blender": (2, 77, 0),
    "location": "Render Properties -> Output",
    "description": "Converts an image to CMYK when saving out animation renders",
    "warning": "",
    "wiki_url": "",
    "category": "Render",
    }

# defines the format used to write to (tiff/psd/jpg... etc)
FORMAT_EXT = "tiff"

import bpy
from bpy.props import BoolProperty
from bl_ui.properties_render import RENDER_PT_output
from bpy.app.handlers import persistent

@persistent
def render_write_cmyk(scene):
    import os
    import subprocess

    if scene.use_render_cmyk:
        filepath_src = scene.render.frame_path()
        filepath_dst = os.path.splitext(filepath_src)[0] + "." + FORMAT_EXT
        if os.path.exists(filepath_src):
            cmd = (
                "convert",
                filepath_src,
                "-colorspace", "cmyk",
                filepath_dst,
                )
            print("Running:", " ".join(cmd))
            subprocess.check_call(cmd)
        else:
            print("File not found for conversion %r" % filepath_src)

def draw(self, context):
    layout = self.layout
    layout.prop(context.scene, "use_render_cmyk")

def register():
    bpy.types.Scene.use_render_cmyk = BoolProperty(name="Write CMYK")
    RENDER_PT_output.append(draw)
    bpy.app.handlers.render_write.append(render_write_cmyk)

def unregister():
    del bpy.types.Scene.use_render_cmyk
    RENDER_PT_output.remove(draw)
    bpy.app.handlers.render_write.remove(render_write_cmyk)

if __name__ == "__main__":
    register()

This excercise is pointless and I'm sure there's a better use for your time and efforts.
First of all: PSD is not a format suitable for printing, it's intended for editing in Photoshop.
So, if this file is intended to go to Photoshop anyway, why bothering? you can do the conversion in Photoshop. Heck, you can even do it with GIMP and the Separate+ plugin.
Nobody who knows a thing about printing would need this, and most certainly wouldn't have any troubles converting a proper RGB from Blender to CMYK using the appropriate tool for the task.
CMYK has no place in a program like Blender.

CMYK is device dependent, and unlike RGB where untagged is usually assumed to be sRGB, a CMYK file without a colorspace definition is meaningless (and potentially dangerous if it's sent to print).
Also, CMYK makes sense for process printing (offset presses, for instance) and it has little use in any printer that contains a driver taking care of the separations itself (any inkjet, laser, plotter, etc.) unless you really know what you're doing.
And even in that case, the way you prepare a file for print (marks, resolution, etc.) is out of the scope of Blender.

This add-on can be used with color profiles, so its not preventing you from using device dependent settings. And agree this is out of scope for Blender, thats why it can be done as an add-on. If someone wants to pass arguments for DPI, page size... etc. They can avoid having to handle this in an external program.

Made this write tiff images by default, can be modified easily.

"can be used wih color profiles" suggests that it is an option. It is not.
An untagged CMYK file is plain wrong. I insist that this application is way outside of the scope of Blender, but since you're going to keep working on it anyway, keep in mind that an ICC profile should be mandadory.
And for the matters, 300 dpi is the minimum recommended resolution for high quality photo printing in offset presses. That probably should be set too, although it will affect the size of the printed size. Again, a whole can of worms that doesn't belong to Blender at all.

Just to be clear: I do not agree with this solution because it contributes to bad practices as it helps people to get results that are most likely wrong. CMYK is a color model with a very specific purpose and it's intimately tied to ICCs.
The person who asked this feature clearly doesn't understand CMYK and ICCs (says he can't produce good separations with Photoshop, which uses the same rendering intents than imagemagick).
That person won't be able to produce a proper file for print anyway, but this script will enable him to use hacks instead of learning the basics.

@Gez, are you saying its impossible to get a usable CMYK file out of ImageMagick and Photoshop? If so, such a statement deserves some justification, can you link to more detailed references on this topic?

No, exactly the opposite: Both are perfectly capable of producing correct results. The reporter said that he wasn't able to produce a good separation with Photoshop*. I was pointing out that if that was the case, he won't be able to produce a good separation (according to his expectations) with Imagemagick either, as both PS and IM do basically the same.
*) This was what the reported said:
"For my business, I normally need to convert every project into CMYK for print and that is where the colors of the RGB jpg are really screwed up and I spend hours recoloring my entire Blender creation."

Let us continue this discussion in chat.

Moving forward... Printing ink on anything is old news...


text:
When should custom-properties be used instead of 'bpy.props'?
Python has two ways to define your own properties.

Via bpy.propsAccessible from data-editor, or via buttons defined in scripts:
# define the property
bpy.types.Scene.my_prop = bpy.props.BoolProperty()
# set the property
bpy.context.scene.my_prop = True

Via Python's __getitem__/__setitem__Accessible from custom-properties panel:
# no need to declare it.

# set the property
bpy.context.scene["my_prop"] = True

What should be considered when choosing which one to use?

Definition
bpy.props need to be defined.  eg scene.myprop is not available to scripts until it is defined via bpy.types.Scene.myprop = bpy.props.BoolProperty()
It is however saved, once set in a file, and the set value can be retrieved once defined again.
Type Casting
Properties defined using bpy.props are type cast, and expect a value of that type, or are converted
>>> C.scene.my_prop = 1
>>> C.scene.my_prop
True
>>> C.scene.my_prop = "XXXX"
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: bpy_struct: item.attr = val: Scene.my_prop expected True/False or 0/1, not str

Custom props
scene["my_prop"] = 1
scene["my_prop"] = "XXXX"

Scope
bpy.props are defined for all objects of that blender type, for your example scene.my_prop will be available to all scenes, whereas scene["myprop"] only for the scene instance it is defined on.  I choose custom props for more "one off" usage.
Update Method
An update callback method is available to bpy.props properties.  This is a very useful tool, that is not available to custom properties.  Similar to using an "on_change" event handler.
def jangle(self, context):
    print("update called on scene ", self.name)
    # do something based on the value of "my_prop"
    if self.my_prop:
        print("It's on")
    else:
        print("It's off")
    return None # always return None from an update.

bpy.types.Scene.my_prop = bpy.props.BoolProperty(update=jangle)

UI
both can be decorated in the UI, to some extent.  To add a name and description to each.
bpy.types.Scene.my_prop = bpy.props.BoolProperty(name="My Property",
                       description="This is my bpy.props boolean prop")

and for custom props
    rna = {"name": "My Property"
           "description": "This is my custom boolean prop",
           # can also store other data that can be set by script
           # and used as a driver var
           "anyolthing": 13
          }

    scene["my_prop"] = False
    if "_RNA_UI" not in scene.keys(): #  keys() returns a list of id props
        self["_RNA_UI"] = {}

    # define the UI propeties of "my_prop"
    self["_RNA_UI"]["my_prop"] = rna

note the rna_ui dictionary can have self defined property names, as long as the data type is int, float, bool, string.  They will not effect the UI, but are a handy way to store "hidden" data.  The rna dictionary is a handy way to update the min and max and description on a per property basis, to make descriptive and effective visual sliders for instance.
rna Access
Once a custom property is set, the property name will be a member of the, in this case, scene.keys() list, or as name/value pairs in scene.items()
All bpy.props properties  will be available via scene.bl_rna.properties.keys() but only in the scene.keys() list once initialized, ie given a value other than the default.

The simple difference is:

custom properties have to be defined by script first, then they are available to all the instances of the type of object they were defined for. Plenty of data types available (arrays, bools, ..)
ID property can be assigned to single instance of object. There are less data types available.

Both will be saved with the file. Also both will show in the UI, the custom prop will show as "API Defined":

When you open such file and don't define the custom property, it will be converted into ID property:

When you run bpy.types.Scene.prop = bpy.props.IntProperty() it will turn back into custom property.
There is a bug in 2.77a however. If you happen to define bpy.types.Scene.prop you are not able to create any ID properties for scenes - the default name for them is "prop". This was reported and fixed for further releases.
Last very important thing - as custom properties are heavily used to store values for rigs

Pose Libraries do not store custom prop data automatically, but they will store ID properties values. Custom prop can be keyframed or driven by driver the same way is ID property can though.