text:
Damped Steering>Seek via Python
I'm attempting to have a central turret object turn to point to a moving target. The turret is always in the center of the scene (un-moving). Using the Steering>Seek actuator is too fast and allows the turret to lock immediately to the target. I need to be able to have the turret slowly turn clockwise or counterclockwise (depending on which is shorter) at a set rotation speed until it eventually points to the target.
I found the getVectTo() Python function, which I can use to pull a local vector from the turret to the target. Unfortunately, I can't figure a way to use that vector to determine the shortest turning direction to reach the target; i.e. clockwise or counter-clockwise.
To clarify, the logic would look like this:
if shortestRotationAngleToTarget = Counterclockwise:
    rotateTurret(turretRotationStep)
else
    rotateTurret(-turretRotationStep)

EDIT:
I've done more digging and tried to implement some of the suggestions provided so far. I believe I need to be using the .angleSigned() method applied to the turret's currently facing angle, but can't figure out how to get it working. The following screen shot shows the testing scene I'm using to figure this out. I am attempting to get the output of +90.0 returned where the error occurs.
I've posted the Blend here: GetVectTo.blend

Thanks for any suggestions!

I downloaded your blend and imports mathutils Vector and math, angule_signed need a 2d vector while angle a 3d.
Output (obj -- target):

Output changing target position (target -- obj)

Note that 2d would give negative indicating where you should turn.
Script:
import bge
from mathutils import Vector
import math
# get the controller
controller = bge.logic.getCurrentController()

# get game object controller attached to
obj = controller.owner

# get the current scene
scene = bge.logic.getCurrentScene()

# get a list of the objects in the scene
objList = scene.objects

# get game object named "Box"
box = objList["Target"]

# Get current facing direction of turret
currently_facing2d = Vector((obj.getAxisVect([0.0, 1.0,0.0]).xy))
currently_facing3d = obj.getAxisVect([0.0, 1.0,0.0])
print("currently_facing2d: ", currently_facing2d)
print("currently_facing3d: ", currently_facing3d)

# get the vector to target
vectTo2d = Vector((obj.getVectTo(box)[1].xy))
vectTo3d = obj.getVectTo(box)[1]
print("vectTo: ", vectTo2d)
print("vectTo: ", vectTo3d)

# Compute angle between turret facing direction and target
angle_between_facing_and_target2d = currently_facing2d.angle_signed(vectTo2d, None)
angle_between_facing_and_target3d = currently_facing3d.angle(vectTo3d, None)
print("Angle Between 2D(radians): ", angle_between_facing_and_target2d)
print("Angle Between 2D(degrees): ", 180 * angle_between_facing_and_target2d / math.pi)
print("Angle Between 3D(radians): ", angle_between_facing_and_target3d)
print("Angle Between 3D(degrees): ", 180 * angle_between_facing_and_target3d / math.pi)

Implementing rotation
Script:
from bge import logic
from random import choice
from mathutils import Vector
import math
from time import time

def change_objective():
    try:
        logic.objective = choice([obj for obj in logic.getCurrentScene().objects if 'enemy' in obj.getPropertyNames()])
    except Exception as e:
        add_enemies()

def add_enemies():
    for obj in logic.spawn_list:
        logic.getCurrentScene().addObject('enemy',obj)

if not hasattr(logic, 'spawn_list'):
    logic.spawn_list = [obj for obj in logic.getCurrentScene().objects if 'spawn_point' in obj.getPropertyNames()]
    add_enemies()
    logic.objective = None
    logic.time = 0

try:
    obj = logic.getCurrentController().owner
    currently_facing2d = Vector((obj.getAxisVect([0.0, 1,0.0]).xy))
    vectTo2d = Vector((obj.getVectTo(logic.objective)[1].xy))
    angle_between_facing_and_target2d = currently_facing2d.angle_signed(vectTo2d, None)
    rotation_speed = 0.03
    rotation = 180 * obj.localOrientation.to_euler().z / math.pi
    angle_to_rotate = 180 * angle_between_facing_and_target2d / math.pi
    angle_distance = rotation - angle_to_rotate

    if not round(rotation,4) == round(angle_to_rotate,4):
        if angle_to_rotate > 0:
            obj.applyRotation([0,0, -rotation_speed],False)
        else:
            obj.applyRotation([0,0, rotation_speed],False)
    else:
        obj.applyRotation([0,0,0],False)
except Exception as e:
    print('error')

if logic.objective is None:
    change_objective()

if logic.getCurrentController().sensors['Ray'].hitObject and logic.getCurrentController().sensors['Ray'].hitObject is logic.objective:
    logic.getCurrentController().sensors['Ray'].hitObject.endObject()
    logic.objective = None

This is the solution I needed! Thank you for putting so much effort into your answer! Cheers!

The trick is to compare angles with the two vectors. While I don't have a full worked solution available, something like the following should set you on the right path:
ROT_SPEED = 0.1  # Radians per frame.

player = some_game_object_that_turns_to_face_enemy
enemy = some_other_game_object_or_point_in_3d_space

_, to_target, _ = player.getVectTo(enemy)  # Get direction to enemy in worldSpace
current_facing = player.getAxisVect([0, 1, 0])  # Y axis is "forwards"

to_target_2d = to_target.xy
current_facing_2d = current_facing.xy

angle_difference = current_facing_2d.angle_signed(to_target_2d)

# Clamp the rotation speed
rotation_speed = min(max(angle_difference, -ROT_SPEED), ROT_SPEED)

# Make object rotate
player.applyRotation([0, 0, rotation_speed])

This is for 2d - projected down from the top (ie it will only rotate around the Z axis. For 3D tracking, you need to use rotation matrices - but it's essentially the same process as above.
If it's a physics object, replace the applyRotation with setting the angular velocity (player.worldAngularVelocity = [0, 0, rotation_speed])

Use a Edit Object actuator > Track to instead of Steering actutator.
KX_TrackToActuator Change the time to meet your requeriments of rotation speed time = 0 = instant track to. Between 10 and 30 feels ok.
I made a demo:

Script:
from bge import logic
from random import choice

def change_objective():
    try:
        return choice([obj for obj in logic.getCurrentScene().objects if 'enemy' in obj.getPropertyNames()])
    except Exception as e:
        add_enemies()

def add_enemies():
    for obj in logic.spawn_list:
        logic.getCurrentScene().addObject('enemy',choice(logic.spawn_list))

if not hasattr(logic, 'spawn_list'):
    logic.spawn_list = [obj for obj in logic.getCurrentScene().objects if 'spawn_point' in obj.getPropertyNames()]
    add_enemies()

if logic.getCurrentController().actuators['track'].object is None:
    logic.getCurrentController().actuators['track'].object = change_objective()
    logic.getCurrentController().activate(logic.getCurrentController().actuators['track'])

if logic.getCurrentController().sensors['Ray'].hitObject:
    logic.getCurrentController().sensors['Ray'].hitObject.endObject()
    logic.getCurrentController().actuators['track'].object = None

Unfortunately, your solution doesn't meet the criteria that the turret turns at a set speed. Looking at your demo, the turret eases in/out of its rotation. Thanks for the idea, though.


text:
How to use an object as a mask?
I have a 4 point plane (quadratic) that I would like to use as a mask when rendering.I need this so the mask will be transformed correctly when I move the camera. This plane is covering the area I would like to mask.
I was thinking to maybe render a mask scene and feed that into the final scene as a mask. But since Blender now has masks, it would be easier if we could convert a mesh into a mask.
**EDIT
I'm using Blender 2.68a with Cycles.

Related: http://blender.stackexchange.com/q/3092/599

You could give it a Holdout material, this will make the object render as transparency.

@gandalf3 You should probably make this an answer ;)

The project is on ice so I haven't tried it yet. I don't know if it solved my problem.

Searching the manual I found the following manual entries: https://docs.blender.org/manual/en/2.92/compositing/types/converter/id_mask.html https://docs.blender.org/manual/en/2.92/render/layers/passes.html The explanation of ID Masks together with the list of passes and the information that you need to use cycles as renderer should bring you in a position where you are able to set everything up as explained.

You can do this using the Object ID and a ID mask node.
Select the object you want to use as a mask, and under the object tab in the properties set the Pass Index unequal 0 (I used 1, but if you have more then one mask give each one a different number)

Now, head over to the RenderLayers tab and check the Object ID pass

Re-render your image and head over to the node editor. There attach a ID Mask node to the IndexOB socket. Use the node's output as a factor for a mix node (See screenshot)

Here I used a test image, but you can use one from any source you want.

I see how you think :) I will try out your suggestion.

The interface is very different today, and I can't even find the render layers or id mask nodes? Is this still possible? I'm trying to cut some hair using a cube... https://blender.stackexchange.com/questions/209038/cut-hair-particles-using-boolean-modifier

source: Stack Exchange

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

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

sort: votes


text:
Parenting to an array end cap
I have an array with two different objects as the StartCap and EndCap. So far everything works fine.
Now, I want another object (let us call it ObjRight) to be offsetted from the EndCap object, so when I increase the Array Count, ObjRight will follow the EndCap as the array increase/decrease.
The easiest thing would be to just join the ObjRight with the EndCap but I need them to be separate objects where EndCap is ObjRight's parent.

You could use animation drivers

Solution without drivers:
What about using a curve to define the length of your array ? You could then hook the last control point of your curve to your ObjRight. The solution isn't perfect as you would have a space between the OjRight and the Endcap but with a proper set up you could mask the problem (moving the ObjRight with fix increments snap to the grid for example).
Solution with drivers:
This solution (probably the best) would be to drive the ObjRight location (or an empty that you can use as a parent for ObjRight) by the array count.
Hope it makes sens. Let me know if you need clarification.

Drivers make more sense to me, easier to control. Thank you for the tip. I will try and see if I can get it to work.

Yes of course :) If I can get it to work I will mark this as the right answer. I'm a little busy right now, bt when I get the time...

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


text:
RESOLVED = RNA_boolean_set: CURVE_OT_draw.wait_for_input not found
On my blender2.78 linux64B I have always this traceback on terminal and i can't solve it and remove:
"RNA_boolean_set: CURVE_OT_draw.wait_for_input not found."
Someone know to resolve the problem, please?
When I make a search on addons files, I find nothing!

You just need to File > load factory settings

I have found with a new re-saved config file. In this file, Blender keep some time a shortcut's error of old addons!!!!

Not so easy! It's in terminal even after reload default start file.

I have the solution, the addon in charge is: Freehand Curve Drawings(Edit mode curve drawing) by Ideasman42


text:
How do I get black to stay black?
My intent is to have a black letter on a bright white background.  I have played around with lighting, roughness, etc but I just can't get the clean colors I want - just these different shades of grey.  The image is below, as well as the shaders.
Thanks in advance for your help!
Here's the image.

Here's the shader for the black.

Here's the shader for the white.

Are you using Eevee or Cycles?

Eevee - is there a way to get it to render the colors accurately?  Cycles is really slow!

Looks like Bloom with a large radius? Is the color bleeding in from the light background? Try switching it off in the EEVEE render panel.

@RobinBetts turning Bloom off has very little effect.  Any other thoughts?

Switching off filmic in render=>color management seems to help.

Do you want reflections and shadows or plain black and white like a 2d drawing?

Use an Emission node and it won't be affected by the lights

I show black with the material settings as shown.. the effect must have an external origin? Nothing happening in the compositor? No mist? If no fix, share a sample .blend showing the effect at https://blend-exchange.giantcowfilms.com/

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


text:
Blender crashing on memory usage problems? Results of several tests
I need to produce images of a certain minimum size (1000kb) when written to disk as a jpg file.  for images that are not big enough, I am attempting to increase their size to the minimum by increasing the resolution of the picture.
In principal this works, but my script often crashes when attempting to write a bigger and higher resolution file to disk.  The line of code in question is this:
bpy.ops.render.render(use_viewport = True, write_still=True)

Here are the results of some tests that I have run:
(a) at 5000x3000 pixels resolution, blender never crashes when trying to create jpg files.  When completed, the jpg files are a wide range of sizes (350k - 3000k)
(b) at 9250x5250 pixels resolution, blender frequently crashes but not always.  The final output files meet the minimum size requirement (1000kb).
So the problem would appear to be too many pixels in the resolution rather than the final size of the output file.
I have noticed a big spike in RAM usage (4-5GB) while blender creates the higher resolution version of the render.  The spike is big enough to slow the entire computer down.
I don't know how to fix this.  I would appreciate any suggestions.  Thanks in advance!

Looks like you're running out of memory and the OOM killer terminates Blender. Is there a specific reason why it has to be jpeg and rendered with Blender? Perhaps this is a XY problem.


text:
Python camera.rotation_euler problem
I cannot figure out why the following line of code throws the error "AttributeError: 'NoneType' object has no attribute 'rotation_euler'"
bpy.context.scene.camera.rotation_euler =(0,0,0)

If the scene has no camera then scene.camera is None it can also be set to None  Having the value None is the error.

@batFINGER - the camera exists, and when I put the code at the beginning of the script it still throws the error.  So it's not being set to None at runtime.  Suggestions?

Is it assigned to the scene, ie check the scene properties panel or C.scene.camera in the console.  The error message implies it is not set. There can be a zillion cameras in the scene, only one (or none) at any point in timeline is the "scene camera"

As shown in answer below... To set scene.camera = scene.objects.get("Camera") will set it to camera named "Camera" if it exists, else None.

If the camera exist but this is NOT set; then you get the error

you must set the camera


text:
Python - writing console output to disk
Is there a way to write the console output to disk?  In other words, as the system writes to the console, it also writes to a text file?
I am hoping that there is a simple setting in blender rather than having to write a bunch of scripts to write messages to a file on my disk drive.
This is so I can figure out why my script is causing blender to shut down.

Start Blender with blender.exe > myfile.log

@rob Sounds great, would you like to add this as an answer?

If you simply want to review the output, you can start Blender from the shell/cmd. Simply opening it as >blender will write its output to that window, which doesn't close even if Blender crashes.

Thanks - I have no idea what blender.exe>myfile.log means, nor 'simply opening it as >blender'

You need to run the Blender executable from the command line.
In Windows this requires you to run a new Command Prompt and the execute blender.exe from the correct location.
In Linux/MAC the process is similar.
On my Windows machine, I go to the Start Bar and type in Command

in the new window I type the directory to where Blender was installed followed by the program I want to run, blender.exe
To capture all the output a redirection character > is used.
Finally I have a folder on my C: drive called "tmp" that I know I have access to write to. You will have to enter a folder and filename your Windows user can write to.

After running Blender the new file myfile.log has the following contents. This was after simply opening and closing blender. (type is a windows program that just dumps text files to the console)


text:
Blender 2.8 (Python) - convert text to mesh
I would greatly appreciate any tips and/or sample scripts on how (in Python / Blender 2.8) to convert a text object into a mesh object.

The laziest way to do it is to use the same operation that the Alt-c performs when done interactively : bpy.ops.object.convert(target="MESH") .  Unfortunately, this shares the problem of every function in bpy.ops.  You have to set up the interactive environment (what object is active/selected).  It would look something like this:
import bpy

def mission1(obj):
    scn = bpy.context.scene
    for o2 in scn.objects:
        o2.select = ( o2 == obj )
    scn.objects.active = obj

    bpy.ops.object.convert(target="MESH")

mission1(bpy.data.objects['Text.001'])

If there is a way to accomplish this without using bpy.ops, I was too lazy to dig it up.


text:
Blender 2.8 - texture does not appear on extruded circle
In Blender 2.8, working from a new file, I have created a mesh circle and extruded it into a cylinder.  I then attempt to apply a texture using settings that work on cubes and cylinders.  But in the case of the extruded circle, the texture does not appear (in Render mode).
My question:  what do I need to do to get the texture to appear on the extruded circle?

Would be helpful if you cropped your screenshot before posting

You need to UV Map the extruded cylinder. The reason why textures appear on a cylinder (and cube) created from the Add menu is because those are basic shapes that are used a lot, so they are already set up (which means UV mapped) for using textures, but since you extruded your cylinder from a circle, it doesn't have a UV map yet. I suggest looking up tutorials on the internet on how to learn to UV map models, because it is a very important thing to know.
UV mapping a cylinder is trivial, any basic tutorial will do.

Thanks - that was the insight I needed.  Would you have any suggestions as to my next question?  https://blender.stackexchange.com/questions/149322/python-2-8-transform-resize-uv-map-instead-of-object


text:
Picture - saving in high resolution versus low resolution
When I print the camera view to a jpg file, the file size is about 650k.  I would like to have a much higher resolution picture, with a file size of at least 3MB.
How do I do that?

What you are referencing "650k" and "3MB" is the file size, not the image resolution. While an increase in resolution likely increases the file size, it actually depends on the image format and its encoding/compression. A very high resolution image can be small in file size with a good compression algorithm.
When talking about image resolution this typically means the number of pixels stored in the images, which is commonly written as the number of pixel on the horizontal axis (X-axis) times the number of pixels on the vertical axis (Y-axis), e.g. 1920x1080. This resolution can be adjusted in the Output tab in Blender.

If for some reason you really need to create image files with a certain file size, then I'd suggest using a file format without compression which lets you estimate the resulting file size based on the resolution and the overhead from the header, trailer and additional metadata of the file format.

Well, the size of the file depends on the following factors (as per my knowledge):

Resolution of the image being rendered.
The amount of Samples being used during Rendering.

A higher number of samples doesn't mean that the file size will be larger. The number of samples is relevant for the path trace integrator to get a clean render result with (hopefully) little noise. The relation of samples to file size is likely somewhat inversely proportional, because noisy renders harder to compress than one with lots of even colors on surfaces.


text:
Python 2.8 - forcing the correct instance of the image/uv editor
BACKGROUND  I have code (below) that scales a texture on the Y-axis to eliminate distortion from unwrapping a very deep cylinder.
The code performs successfully on a standalone basis (as a test), but when I drop the code into a bigger app it throws an error because setting an area to IMAGE_EDITOR does not behave the same way as in the test.
Stand alone performance: the texture image appears correctly when I set an area to IMAGE_EDITOR; from there the code scales the UV map correctly by selecting all the uv vertices and scaling.
Within big app performance: a blank appears when I set an area to IMAGE_EDITOR.  The code throws an error because there are no uv vertices to select.  However, the image/uvmap exists and can be found when I switch the workspace from "layout" to "uv editing"
QUESTIONS ON HOW I CAN FIX THE CODE SO THAT IT WORKS IN THE BIG APP
(a) If the correct texture image/uvmap appears in IMAGE_EDITOR, can I assume the code will work as well when included in big app as in the test?
(b) How can I force IMAGE_EDITOR to perform in the big app the same way it performs as a standalone?
SCREENSHOTS AND CODE

On a standalone basis, the code successfully resizes the UV map and eliminates the texture distortion:

import bpy

bpy.ops.mesh.primitive_cylinder_add(vertices=32, radius=0.2, depth=30, enter_editmode=False, location=(0,0,0))
TextureFolder='G:\\Blender\\Textures\\'
TextureFilename='wildtextures-zinc-galvanized-metal-sheet.jpg'

def obj_material_texture_UVscale(objname,filename,Xscale,Yscale,Zscale):
    path=TextureFolder+filename
    materials = bpy.data.materials
    material = materials.get('mat')
    if not material:
        material = materials.new('mat')
    material.use_nodes = True
    if material.node_tree:
        material.node_tree.links.clear()
        material.node_tree.nodes.clear()
    nodes = material.node_tree.nodes
    links = material.node_tree.links
    output = nodes.new(type = 'ShaderNodeOutputMaterial' )
    diffuse = nodes.new(type = 'ShaderNodeBsdfDiffuse' )
    imgTex = bpy.data.images.load(path)
    node_texture = nodes.new(type='ShaderNodeTexImage')
    node_texture.image = imgTex
    node_texture.location = 0,200
    tex_coord = nodes.new(type = 'ShaderNodeTexCoord')#NEW
    links = material.node_tree.links
    link=links.new(tex_coord.outputs["UV"], node_texture.inputs["Vector"]) #NEW
    link = links.new(node_texture.outputs[0], nodes.get('Diffuse BSDF').inputs[0])
    link = links.new( diffuse.outputs['BSDF'], output.inputs['Surface'] )
    obj=bpy.data.objects[objname]
    obj.active_material=material
    bpy.ops.object.select_all(action='DESELECT')
    bpy.data.objects[objname].select_set(True)
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.select_all(action='SELECT')
    bpy.ops.uv.smart_project()

    original_area = bpy.context.area.type

    scene = bpy.context.scene
    for count, ob in enumerate(bpy.context.selected_objects):
        if ob.type == 'MESH':
            #scene.objects.active = ob
            bpy.context.view_layer.objects.active=ob
            #+ switch to the image editor to perform transforms etc
            bpy.context.area.type = 'IMAGE_EDITOR'
            bpy.ops.object.mode_set(mode='EDIT', toggle=False)

            bpy.ops.mesh.reveal()
            bpy.ops.mesh.select_all(action='SELECT')
            #+ select the uvs
            bpy.ops.uv.select_all(action='SELECT')

            bpy.ops.transform.translate(value=(0, 0, 0), constraint_axis=(True, False, False))
            bpy.ops.transform.resize(value=(Xscale,Yscale,Zscale))

            #+ return to the original mode where the script was run
            bpy.context.area.type = original_area
            bpy.ops.object.mode_set(mode='OBJECT', toggle=False)

obj_material_texture_UVscale('Cylinder',TextureFilename,1,30,1)

You do not need to mess around with the UI or change the layout at all if all you want to do is update a piece of data within an object.
You can dig down into any variable's type interactively in the scripting console without even having to look up the documentation. Autocomplete via ctrl-space, or calling dir(obj) and type(foo) describes just about anything.
So all you need to do is dig down to find where the UV coordinates are stored, and multiply them directly.
Here's how that would look for your script.
import bpy

bpy.ops.mesh.primitive_cylinder_add(vertices=32, radius=0.2, depth=30, enter_editmode=False, location=(0,0,0))
TextureFolder = 'G:\\Blender\\Textures\\'
TextureFilename = 'wildtextures-zinc-galvanized-metal-sheet.jpg'

def obj_material_texture_UVscale(objname, filename, Xscale, Yscale, Zscale):
    path = TextureFolder+filename
    materials = bpy.data.materials
    material = materials.get('mat')
    if not material:
        material = materials.new('mat')
    material.use_nodes = True
    if material.node_tree:
        material.node_tree.links.clear()
        material.node_tree.nodes.clear()
    nodes = material.node_tree.nodes
    links = material.node_tree.links
    output = nodes.new(type = 'ShaderNodeOutputMaterial' )
    diffuse = nodes.new(type = 'ShaderNodeBsdfDiffuse' )
    imgTex = bpy.data.images.load(path)
    node_texture = nodes.new(type='ShaderNodeTexImage')
    node_texture.image = imgTex
    node_texture.location = 0,200
    tex_coord = nodes.new(type = 'ShaderNodeTexCoord')#NEW
    links = material.node_tree.links
    link = links.new(tex_coord.outputs["UV"], node_texture.inputs["Vector"]) #NEW
    link = links.new(node_texture.outputs[0], nodes.get('Diffuse BSDF').inputs[0])
    link = links.new( diffuse.outputs['BSDF'], output.inputs['Surface'] )
    obj = bpy.data.objects[objname]
    obj.active_material = material
    bpy.ops.object.select_all(action='DESELECT')
    bpy.data.objects[objname].select_set(True)
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.select_all(action='SELECT')
    bpy.ops.uv.smart_project()
    bpy.ops.object.mode_set(mode='OBJECT')

    # Just directly scale the UVs!
    cyluvs = obj.data.uv_layers[0].data
    for cuv in cyluvs: # each is a bpy.types.MeshUVLoop
        cuv.uv[0] *= Xscale
        cuv.uv[1] *= Yscale

# len(o.data.uv_layers['UVMap'].data) -> 192
# Each of these is a bpy.types.MeshUVLoop
# which has .uv, .select, .select_edge, .pin_uv.
# item.uv is a Vector. We can just scale its Y 30 times!

obj_material_texture_UVscale('Cylinder',TextureFilename,1,30,1)

that works really well.  I can't thank you enough after me going down rabbit holes for 10+ hours.


text:
Python 2.8 - image as plane problem
The line of code worked in the past, but has stopped working now that I have had to replace the computer on which the code was originally written and tested. The error message is:
Calling operator "bpy.ops.import_image.to_plane" error, could not be found
The line of code is:

    bpy.ops.import_image.to_plane(files=[{"name":BackgroundFilename, "name":BackgroundFilename}], directory=BackgroundFolder)

The variables 'BackgroundFilename' and 'BackgroundFolder' are correct.  The file to which these variables refer exists and opens normally outside of python.
Checking the file properties, it is not blocked and everything seems normal.
Any suggestions would be appreciated.  Thanks in advance.

Enable the addon
Go to the user preferences and enable the addon "Import Images as Planes" to make the operator registered and available to scripts.

Related
Can an add-on be automatically installed and enabled?


text:
Python 2.8 - camera positioning for dynamically resized objects
My code dynamically creates scenes and saves a picture of each scene it creates.  The main subject matter changes in size from scene to scene in such a way that - absent dynamic zooming with each scene - sometimes the subject is too small and sometimes it is too big in relation to the what the camera sees.
Is there an efficient algorithm or procedure for dynamically zooming?  Or should I come up with a algebraic/trigonometric solution?
If it's algebra/trig, my calculations for the correct zoom would depend on the 3D geometry of the camera itself (aspect and depth of the focal point inside the camera).  Is that info available?

One can move the camera or change the focal length of the lens.  Each method has the effect of making objects in the view larger or smaller.  If your goal is to capture the entire object within the view, you must know its size first.  If it is a problem to know the object size each time you want to capture it, perhaps using the Home key, which sizes the view, not the camera position, would allow you to then grab some view parameters (which I am not familiar with) to use in positioning the camera or changing the lens focal length.


text:
Blender 2.8 - render image creates only an outline of the image
In 2.8, I have a complete scene in blender that I would like to render as a 2D image (and save as a .png file).  I view the scene from the camera and the attempt to render.  When I click Render->Render Image, I don't get what appears in viewport, instead I get just a faint silhouette outline of what appears in viewport.  Render settings are all default.  What am I doing wrong?

If you want to render the scene as it is displayed in the 3D view, you'll have to set the render engine to Workbench. You can do this in render tab in Blender 2.8.

Otherwise when rendering with Cycles or Eevee you need to setup materials and lighting otherwise you won't be seeing much in your render.

how do I set the engine?

@vndep I've added an image that shows where.

Thanks - that moves things in the right direction.  However, the background image does not appear.  WHy is that?

@vndep What kind of background image? Are you talking about an environment texture or a reference image added through Add > Image > Background?

Added through add>image>background.

@vndep That is just meant as a reference image for modelling and can't be rendered as far as I'm aware (it's essentially an Empty that displays in image just for the viewport). You can add a plane though and apply the texture to it or make the film transparent and composite the render and your image afterwards.

I added a new question to address how to add the image through a plane.  See  "https://blender.stackexchange.com/questions/146090/blender-2-8-adding-an-image-to-a-scene"


text:
Blender 2.8 (python) - how do I get the vector of the direction the camera points
In python, how do I calculate/find/retrieve the XYZ vector from the location of the camera and through the midpoint of the camera view?
In the example below the camera is at location (7.4, -6.9, 5.0) and points at the origin (0,0,0); therefore the vector should be (-7.4, +6.9, -5.0)
I suspect the camera's location and rotation parameters hold the answer, but the I can't figure out the calculations.  For example, in moving the origin there is clearly movement along the Y axis, but the rotation on the Y-axis is zero so I don't know how to do it.

Since a clear rotation camera (0,0,0) point down z-axis.
So the vector should be $camera\ rotation\ matrix\times Vector(0,0,-1)$
In code:
v = Vector((0,0,-1)) #Down vector
v.rotate(camera.rotation_euler)

v #this vector

Except
Keep in mind that camera can have another transform by parent offset and some other modifier. If the camera rotation is not pure, you will need to apply the transform to that rotation as well.

How would this work as a generalized algorithm, rather than specifically pointing at the origin?  For example, what if the camera is pointing at (2,8,-5)?

@vndep it doesn't matter where the camera is and where it's point at. Since camera doesn't allow apply any transform. The rotation of camera is same as rotation of the camera pointing vector if camera setting doesn't change. You can test it if you manually put camera in some places and use . and ctrl+alt+0 to point at some non-origin object to test it.

I just test it second ago and it is correct. It it not a generalized algorithm but just how camera is treated in blender. And also since v is an unit vector, the pointing vector will be an unit vector as well. You can normalize the difference vector between cam and obj to see the same vector.


text:
Rounded bevel for selected vertices in a plane
I am trying to create a rounded bevel for two of the four vertices in this arrow shape:

I selected the left-most vertex, pressed ctrl-shift-b and created the bevel as seen in the picture.  However, the bevel is a straight line whereas I would like it to have a rounded appearance.  Suggestions?

Option 1: Setting with Scroll wheel
If you use the scroll wheel while in bevel mode the bevel uses more edges, giving the corner a more rounded look.

Option 2: Using the advanced tool menu popup:
There is also another way (which doesn't need a scroll wheel) to set more advanced settings for the bevel function (actually works for any tool and add primitive actions).
After you did the tool action (in your case bevel) a small popup is seen in the left corner of the 3d-view screen (in Blender 2.80) which you can click to expand it. There you can modify the action you just did.

PS: In Blender 2.79b this advanced tool menu was located in the tools tab

Option 3: Use the +/- keys
As quoted from the comment from @lemon you can also

"use + or - from the keypad." - lemon

to increase the segments of the bevel tool.

Happy Blending! :)

Lacking a scroll wheel (laptop), I use the 3 button mouse emulator.  Is there a way to do this given my situation?

@vndep, use + or - from the keypad.

I now added the "Option 2" which you can also use. BTW: The advanced tool settings menu is really handy to use. For example you can directly change the properties of an object you add (height, diameter, segments, location, ....)

@lemon thank you! I added your suggestion to my answer (Option 3)

Thanks for these great solutions!


text:
Archimesh installing problems
The Archimesh add-ons don't appear in the add-ons list after installing them. I got this message: 'One or more addons do not have UTF-8 encoding!

It worked for me. I extracted the zip and copied the resulting directory to 2.68/scripts/addons/. How did you install them?

Voting to close, this is a bug report in Archimesh - Scripts need to use UTF8 encoding, if they don't - this error will be reported.

seems like this has been solved on the thread
http://blenderartists.org/forum/showthread.php?315980-Archimesh-Architecture-elements-%28rooms-doors-columns-stairs-tile-roofs%29/page2
when you go to the github link https://github.com/Antonioya/blender/tree/master/archimesh

you need to click on the zip file then select raw and it will download correctly.

It sounds like you extracted the zip and installed each .py file individually.
Try directly installing the zip instead:

Addons can be python scripts .py or .zip files (containing .py
  scripts).

Press Install from file in CtrlAltU> User Preferences > Addons:

Navigate to the zip and select it:

Enable the addon:

If you want to install it manually, you can:

Extract the zip
Copy the resulting directory containing the .py files into your //scripts/addons/ directory (// being the path to your blender config directory). See the wiki on file locations for more info on where this is:

Windows 7: C:\Users\%username%\AppData\Roaming\Blender Foundation\Blender\2.5x\scripts\addons
Windows XP: C:\Documents and Settings\%username%\Application Data\Blender Foundation\Blender\2.6x\scripts\addons
Linux: /home/$user/.config/blender/$version/scripts/addons

There is also a system wide location for the configuration directory, see the wiki for more details:

Blender can be installed system wide or run from an extracted bundled
  with all necessary files contained.
There are 3 different directories blender may use, their exact
  locations are operating system dependent.
LOCAL: location of configuration and runtime data (for self contained bundle)
USER: location of configuration files (normally in the user’s home directory).
SYSTEM: location of runtime data for system wide installation (may be read-only).

Note that the the path to offending files will be printed to the console:

To convert encoding to UTF-8 you can open the offending .py file in a text editor and resave with UTF-8 encoding selected.

While the is a comprehensive answer, its more generic documentation on howto install any addon and doesn't address the error asked in the question.

@ideasman42 I figured the OP might have done something wrong when installing the addon because it worked fine for me out of the box. (I was able to reproduce the error by installing each .py file in the zipped directory separately)


text:
ZBrush sculpting brushes equivalents in Blender
I'm sculpting a lot recently and most of the sculpt-related tutorials on Youtube are for ZBrush, nevertheless human anatomy knowledge contained therein is universally applicable.
To get more out of those tutorials it would be nice to have a list of brush equivalents, for example when they are talking about "clay buildup" brush in ZBrush, should I use clay or clay strips brush in Blender? Is "clay tubes" in ZBrush Blender's "clay strips"? Does "standard brush" equal "sculpt/draw"? It takes lots of effort and experimentation to find those equivalents with trial and error.
As for the list of Blender's sculpt brushes, I'm using this page:
https://blender.stackexchange.com/a/21622/1621

Probably it's better using actual ZBrush for sculpting in particular, taking into account its possibilities of handling with high res models. Blender's sculpt system is good but I don't think it's really has analogues for everything from ZBrush.

Try this: https://blender.stackexchange.com/questions/47885/how-to-import-zbrush-brushesfiles-zbp-to-blender ... there is my answer with link.

During months afetr I asked this question I was able to piece together some experience from various sources that now allows me to answer it, at least partially. I'll probably be editing this answer in the future and adding new items to the list.
The goal was to be able to use gazillion of ZBrush sculpting tutorials from Youtube and use them as a learning tool in Blender Sculpt mode. The conclusion is, in order to understand them, you have to learn ZBrush, there is no way around it. But you don't have to download and use the program itself, you can simply watch a few beginner tutorials. The best way to familiarize yourself with ZBrush basics is the latest playlist by Pixologic, published on 24.06.2016:
ZClassroom - How to Start with ZBrush
Another source that confirmed you can find some equivalents is a book "Blender 3D By Example":
https://books.google.pl/books?id=gtdOCwAAQBAJ&printsec=frontcover&vq=zbrush#v=onepage&q=zbrush&f=false

Here is my list:
    ------------------------------------------------------------
ZBrush                      Blender

Standard   ------------->   SculptDraw
Dam Standard  ---------->   Crease
Clay Buildup  ---------->   Clay Strips
Move      -------------->   Grab
hPolish   -------------->   Flatten
Trim      -------------->   Scrape/Peak [1]
Pinch     -------------->   Pinch
Smooth    -------------->   Smooth
Layer     -------------->   Layer
Inflate   -------------->   Inflate/Deflate

Some equivalent settings and keystrokes:
ZBrush                      Blender
------------------------------------------------------------
Z-intensity (U)   ------->  Strength (Shift+F)
Draw Size (S)   --------->  Radius (F)
Focal Shift   ----------->  Curve (submenu in the Toolshelf)
Rectangle Mask (Ctrl+LMB)   Box Mask (B)
Erase Mask       -------->  Clear Mask (Alt+M)
Inverse Mask (Ctrl+I) --->  Invert Mask (Ctrl+I)
Polygroups (Ctrl+W) ----->  Face Sets (Draw Face Sets brush in 2.83)

[1] see video by Gleb Alexandrov https://www.youtube.com/watch?v=YKPrGh1HTog


text:
Render border settings
In this question there is a screenshot showing the ability to set render border settings. However when I use Ctrl-b and select an area I don't see these settings in the options area, it just shows the text "Set Render Border" with a blank area (Blender 2.73b).  Was this ability removed?
I'm mainly interested in these settings to see if they can be interpolated in an animation.

Does this help: http://blender.stackexchange.com/a/45837/3710 ?

The ability to alter the values has been removed. Adjusting the values was removed in 2.69. Up until 2.71 you could adjust the camera only option.
While you may not be able to adjust the values from the operator you can access and adjust the values used for the border. For the final render they can be found at scene.render.border_max_x... Note that min to max values are 0.0 to 1.0 so the clipping is a percentage of the render size. You should be able to alter these values in a frame_change_pre handler.
I think cropping the image in the compositor would be a better approach. You can keyframe the settings of a crop node to move it around.

Some other options are to animate a mask in the movie clip editor (part of the camera tracking) or use object pass index and animate an object to create the mask.

Thanks for the other suggestions. I specifically wanted to do this without using scripting. I thought that it would be a way that I could divide the processing of an image's render for use with a renderfarm like sheepit that doesn't allow scripts to run.  The masking approach might work.

I don't recommend using the Crop node nor a mask as both will still render the entire frame. Instead, I'd recommend using the animated render border add-on. It allows you to animate the borders and also tweak their values.

Which adjusts the render border settings that I mention in the second paragraph and later expanded on in this example of using it. I suggested the crop node here as the question isn't about python so I suggested a more user friendly approach to animating the cropping.


text:
Is it possible to create a keymap item for simultaneous left/right mouse button press?
Is it possible to create a keymap item / something similar and assign it to a simultaneous left / right mous button press?
Explanation: I need an easy-to-access shortcut for my addon. It should work across all areas and contexts (right now I'm using Shift+Ctrl+Alt+Right-mouse, which is crazy and fails in several contexts, e.g edit mode.
I've tried things like
addon_keymaps = []
def register():
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='Window', space_type='EMPTY', region_type='WINDOW')
kmi = km.keymap_items.new(
    ColorPicker.bl_idname,
    type='RIGHTMOUSE',
    key_modifier = 'LEFTMOUSE',
    value='PRESS'
)
addon_keymaps.append((km, kmi))

but it does not work. Is it possible at all? (and if so, what am I doing wrong?)


text:
Cannot Apply Array Modifier

Modifier Cannot Be Applied to a mesh with Shape Keys

I have built a rollercoaster track, and in order to continue the build without lag, I must apply the Modifiers. Is there a fast and easy way I can apply these modifiers and get around the Shape Key issue?

Instead of turing it off, you can disable the visibility of the modifier temportarily. Then it should not affect the performance during editing. There are three small icons above the modifier (camera, eye and cube with vertices) which affect the visibility of the modifier during rendering, in object mode and in edit mode.

This has helped a tonne! didnt think of simply hiding the track. Ill just have to make the coaster follow the path, then enable the track again when rendering. Thanks Maddin!

To apply the modifier:

Duplicate the object "A" to "B" and remove Shape Keys from "B".
Apply modifiers on the duplicate "B"
Duplicate the original object again from "A" to "C", with a Shape Key transformation (choose one for now. we have to repeat for other Shape Keys)
Convert the second duplicate "C" to mesh using Alt-C "Convert to - Mesh from Curve/Meta/SurfText"
Select "C" (as selected) and then, "B" (as Active).
In Properties - Object Data - Shape Keys, we click in the down arrow and, in the menu, we click in "Join as Shapes". This will create the "Basis" with the original shape and a second shape key, with the same name as the object. Now, we have to change manually the name of the Shape Key.
"C" can be deleted. Repeat for each Shape Key.

This is based on SubSurf applying in Objecs with Shape Keys (to use in BGE) by Mario_Mey from blenderartists.org.

If the link goes, so does the answer.


text:
How to move keyframes using Python?
Is there a way to move a keyframe using Python (change the frame at which the keyframe is set)?
The keyframe already exists. I need to access it and move it, with the script.

This is not hard:
bpy.data.actions[aname].fcurves[i].keyframe_points[j].co[0] = fr1

The tricky part is picking the right fcurve[i] and keyframe_points[j] if there are more than one.  You'll have to check fcurve[i].data_path and (if it's a vector data_path like location or rotation*) fcurve[i].array_index to make sure you're altering the right fcurve.

You can also access co[0] and co[1] like co.x (frame) and co.y (value). The action associated with an object is accessible via Object.animation_data.action. Note that both animation_data and action can be None.


text:
Changing active camera will yield an incorrect rendering (camera view not reflected)
I have defined a Blender class to help me abstract out details for rendering, object manipulation etc. I setup my scene using this class and put 12 cameras in it. Then I start rendering objects by switching between each of these cameras. A very strange thing that I noticed was no matter what the camera coordinates are, the last camera ALWAYS renders a black image as I had mentioned before, although my objects are all located at (0, 0, 0). I did some trial and error and found out that adding a "fake" camera would resolve the issue. However, what I then noticed was the rendering results of camera00 and camera04 are ALWAYS the same although the location of both cameras are completely different. This happens even if I change all of the camera coordinates. Another other strange fact is that all other cameras render the right images. Initially I was thinking the camera coordinates are the same but when I loaded the .blend file on my laptop I noticed that is not the case. I can render the objects correctly if I manually load the blend file and render with camera04. However I cannot do my rendering like that as I have many objects. The way I am currently doing my renderings is by compiling Blender as a Python module and loading it on my machine's Python.
This is a very strange issue. Does anyone know whether I am doing something wrong or how I can resolve it? Am I activating the cameras properly?
Below you can see the class I have defined and how I do the rendering:
#blenderClass.py
import importlib

class Blender(object):
    def __init__(self):
        self.bpy = importlib.import_module("bpy")
        self.scene = self.bpy.context.scene

    def setupScene(self, camPosList):
        self.cleanScene()
        self.addSun()

        self.numCams = len(camPosList)
        for i, coords in enumerate(camPosList):
            self.bpy.ops.object.camera_add(location=tuple(coords))
            self.activeObj = self.scene.objects.active
            self.activeObj.name = 'camera.0' + str(i)
            self.activeObj.data.name = 'camera.0' + str(i)
            self.pointObjTo(self.activeObj, (0.0, 0.0, 0.0))

        # Add a fake camera but never activate it
        self.bpy.ops.object.camera_add(location=tuple(coords)) # Use the last coords
        self.activeObj = self.scene.objects.active
        self.activeObj.name = 'camera.0' + str(i+1) # Use the last i from the for loop
        self.activeObj.data.name = 'camera.0' + str(i+1)
        self.pointObjTo(self.activeObj, (0.0, 0.0, 0.0))

   def render(self, objPath, renderPath):
        self.bpy.ops.import_scene.obj(filepath=objPath, split_mode="OFF")
        for i in range(self.numCams):
            self.scene.render.filepath =  renderPath + str(i) + '.png'
            self.activateCamera(i)
            self.bpy.ops.render.render(write_still=True)

   def pointObjTo(self, obj, xyzTarget):
        direction = Vector(xyzTarget) - obj.location
        obj.rotation_euler = direction.to_track_quat('-Z', 'Y').to_euler()

   def activateCamera(self, camNo):
        self.scene.camera = self.scene.objects['camera.0' + str(camNo)]
        self.scene.update()

   def addSun(self, location=(0.0, 0.0, 1)):
        self.bpy.ops.object.lamp_add(type='SUN', location=location)
        self.activeObj = self.scene.objects.active
        self.activeObj.name = 'interiorIlluminator'
        self.activeObj.data.name = 'interiorIlluminator'
        self.activeObj.data.shadow_method = 'NOSHADOW'
        self.activeObj.data.energy = 0.8

    def cleanScene(self):
        self.removeLamps()
        self.removeMeshes(0)
        self.removeCameras()

    def removeMeshes(self, layer = -1):
        for obj in self.scene.objects:
            if obj.type == 'MESH' and obj.layers[layer != -1 and layer]:
                obj.select = True
            else:
                obj.select = False
        self.bpy.ops.object.delete()

    def removeCameras(self):
        for obj in self.scene.objects:
            if obj.type == 'CAMERA':
                obj.select = True
            else:
                obj.select = False
        self.bpy.ops.object.delete()

    def removeLamps(self):
        for obj in self.scene.objects:
            if obj.type == 'LAMP':
                obj.select = True
            else:
                obj.select = False
        self.bpy.ops.object.delete()

And here's how I do my renderings:
#main.py
import blenderClass import Blender
import numpy as np
camPosList = np.loadtxt('camPosList.txt')
blender = Blender()
blender.setupScene()
objPaths = ['obj1.obj', 'obj2.obj', 'obj3.obj', 'obj4.obj']

for objPath in objPaths:
     blender.render(objPath, 'somePath')

And here are the coordinates in camPosList::
1.106609463691711426e+00 -1.284419745206832886e-01 -4.973111748695373535e-01
2.114785015583038330e-01 -1.041638731956481934e+00 -5.988617539405822754e-01
6.345187127590179443e-02 7.305476069450378418e-02 -1.216143369674682617e+00
5.116637349128723145e-01 1.007419824600219727e+00 -4.601101875305175781e-01
9.366978406906127930e-01 4.701653420925140381e-01 6.244274377822875977e-01
7.511696219444274902e-01 -7.962130308151245117e-01 5.386640429496765137e-01
-9.366978406906127930e-01 -4.701653420925140381e-01 -6.244274377822875977e-01
-7.511696219444274902e-01 7.962130308151245117e-01 -5.386640429496765137e-01
-2.114785015583038330e-01 1.041638731956481934e+00 5.988617539405822754e-01
-6.345187127590179443e-02 -7.305476069450378418e-02 1.216143369674682617e+00
-5.116637349128723145e-01 -1.007419824600219727e+00 4.601101875305175781e-01
-1.106609463691711426e+00 1.284419745206832886e-01 4.973111748695373535e-01

You can download a set of rendering results from here:
https://drive.google.com/open?id=1vqX_lLCFY7W3gll5CJ2hoaNzmhK8BLxp
And finally a .Blende file:

I notice that the “activateCamera(self, camNo)” function assigns self.scene.camera twice - firstly to self.scene.objects['camera.0' + str(camNo)] and secondly to self.activeObj. Why is that? Without understanding more about this assignment I can’t say if this would be a problem but it certainly looks suspicious.

@RichSedman Sorry that was a mistake. I don't use self.activeObj for that at all. Updated my post

Does the guy who solves your issue get a credit in the paper?

@brockmann Yes; he/she will be acknowledged :)

@RichSedman I resolved the issue in a hacky way. But do you think any part of my original code could be culprit for this problem?

@Amir Glad you’ve managed to work around this. I’m afraid I don’t have any experience invoking Blender as a python class.

This is a very weird solution but adding another fake camera before adding camera.00 and doing the renderings from camera.00 to camera.11 resolves the issue! I'm not sure whether this is a bug or not but to me it certainly looks like a bug and I will report it.


text:
How to remove the watermark in the rendered image?
I used Blender cycles to render an image, but the output has a watermark with some words in the top left hand corner.
How can I make it disappear by changing the related setting?

http://blender.stackexchange.com/help/someone-answers

In the properties window, open Render tab, scroll down to Metadata section and disable Stamp Output.

@Peng  If this answer has satisfactorily answered your question you can mark it as accepted with the checkmark under the voting buttons.


text:
Python 2.8 - deleting .001, .002, etc
I found several threads on this subject but could not distill a solution.  I am trying to delete .001, .002, etc.
The code should delete these, but every time I rerun my code it is as if nothing was ever deleted; the count is now >0.250 and is rising rapidly.
Full disclosure:  The solution below is inefficient; it is the culmination of several efforts to solve my problem and represents my final "brute force" approach.
Thanks in advance for your suggestions:
def delete_object_iteration(objname):
    for x in range(1, 999):
        xs=str(x)
        on2=objname+'.'+xs.zfill(3)
        try:
            bpy.data.objects.remove(bpy.context.scene.objects[on2], do_unlink = True)
        except:
            pass
        delete_object_instance(on2)

def delete_object_instance(objname):
    try:
        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
    except:
        pass
    try:
        bpy.ops.object.select_all(action='DESELECT')
        bpy.data.objects[objname].select_set(True)
        bpy.ops.object.delete()
    except:
        pass
```

I'm a bit confused why you call delete_object_instance after you've already removed the object.

The following script works fast and removes the objects.
import bpy

def delete_object_iteration(obj_name):
    for x in range(1, 999):
        obj = bpy.context.scene.objects.get(obj_name + '.' + str(x).zfill(3))
        if obj is not None:
            bpy.data.objects.remove(obj, do_unlink=True)

delete_object_iteration("Cube")

The alternative approach would be using the operator with context override.
import bpy

def delete_object_iteration(obj_name):
    objs = []
    for x in range(1, 999):
        obj = bpy.context.scene.objects.get(obj_name + '.' + str(x).zfill(3))
        if obj is not None:
            objs.append(obj)
    bpy.ops.object.delete({"selected_objects": objs})

delete_object_iteration("Cube")

In case you don't want to remove only between 1 and 999:
import bpy

def is_match(prefix, name):
    split_name = name.split('.')
    if len(split_name) == 2 and split_name[0] == prefix and split_name[1].isdigit():
        return True
    else:
        return False

def delete_object_iteration(obj_name):
    for obj in bpy.context.scene.objects:
        if is_match(obj_name, obj.name):
            bpy.data.objects.remove(obj, do_unlink=True)

delete_object_iteration("Cube")

Purging orphans as well:
import bpy

def is_match(prefix, name):
    split_name = name.split('.')
    if len(split_name) == 2 and split_name[0] == prefix and split_name[1].isdigit():
        return True
    else:
        return False

def purge_orphans():
    old_type = bpy.context.area.type
    bpy.context.area.type = 'OUTLINER'
    bpy.context.space_data.display_mode = 'ORPHAN_DATA'
    bpy.ops.outliner.orphans_purge()
    bpy.context.area.type = old_type

def delete_object_iteration(obj_name):
    for obj in bpy.context.scene.objects:
        if is_match(obj_name, obj.name):
            bpy.data.objects.remove(obj, do_unlink=True)
    purge_orphans()

delete_object_iteration("Cube")

Oops... posted without noticing you  had edited answer to include similar.

@batFINGER no problem. You're answer also includes variations that mine doesn't.

Finding with re
Alternatively, find all objects that match a pattern using active objects name.  With object "Cube" active a simple re could be
regexp = r'Cube.\d+'

any object with a name starting with "Cube." and ending only with digits past that point will match.  Need only iterate over scene.objects, or any collection containing objects eg all in blend  bpy.data.objects, and see if they match, as opposed to finding if any of each of a  1000 exist.
There are other ways without re, eg split or rpartition on "." and test if part is numeric.
>>> "Cube.001".rpartition(".")
('Cube', '.', '001')

Test script finds the matches.
import bpy
import re

context = bpy.context
scene = context.scene
ob = context.object

rexp = f"{ob.name}.\d+"

matches = [o for o in scene.objects if re.fullmatch(rexp, o.name)]

print(matches)

Ok if we have matches, can iterate and delete from blend.
while matches:
    bpy.data.objects.remove(matches.pop())

Or with the operator, passing a context override.
if matches:
    bpy.ops.object.delete({"selected_objects" : matches})

There is a lot of over zealous hoo-ha re not using operators.  If you had 1000s of matches above, the operator is still called only once... IMO this is Ok.
but Don't!!!! do this
for o in matches:
    bpy.ops.some.op(....)

and call the operator 1000s of times.
Python performance with Blender operators
Why avoid bpy.ops?
Please also note that bpy.ops.object.select_pattern(...) has similar functionality, and this could be a 2 liner.
bpy.ops.object.select_pattern(pattern="Cube.*", extend=False)
bpy.ops.object.delete()

Which will delete "Cube.001.001" also.

Sorry to intrude .. but this is the sort of place I'm getting stuck trying to figure out  the API. The only ref. I have to bpy.ops.object.delete is this one .. I assume you're replacing a context parameter with a dictionary of your own ... where would I find the docs for that? Is context an default parameter for all ops calls, or something?

https://blender.stackexchange.com/questions/35653/reliable-way-to-find-out-the-required-context-for-an-operator  Would love to see the required context members in the docs.

Thanks. It's nice to know I'm not he only one. With the occasional help of folks like you, I'll muddle through.. :)


text:
Blender 2.8 - weathering effects
Is there an efficient way to add a weathering effect to an object?  By weathering, I am thinking of an overlaid thin layer of mottled grime on a sign or a car, maybe a little rust here or there.

How much does the non-trial version cost?

@whatamesh Is there a way to do what I want without Substance Painter?  I have nothing to do with that product...

The approach I settled on was relatively simple:  because the underlying object was a rectangle, I created a plane of the same dimensions and superimposed it on top; loaded a black and white image for texture and then adjusted the transparency.  It can be found here.

There are many video-tutorials for this topic on Youtube and (answered) questions here in BSE. To get you started I selected some of them for you:
How to Make Rust
Quickly Add Dirt to Crevices
Using Ambient Occlusion to add Grunge
Need to make (node setup) of realistic dirt/ grime/grunge on top of image texture of ceramic tiles


text:
Python 2.8 - how to assign a material in shading versus layout workspace
In Blender/python 2.8, I have code that creates and assigns a material correctly in the Layout workspace (Workbench engine), but when I switch to Eevee or Cycles engine the material does not exist.  The solution appears to be that I must create the material a second time in the Shading workspace.
Question:  how can I rework my code (below) so that the material gets added in the Shading workspace as well?
def add_plane_material(MaterialsIndex, MaterialName, R, G, B):
    bpy.ops.material.new()
    bpy.data.materials[MaterialsIndex].name=MaterialName
    bpy.data.materials[MaterialName].diffuse_color=(R,G,B,1)
    bpy.context.object.data.materials.append(bpy.data.materials[MaterialName])

```

Eevee and Cycles both offer a wide variety of materials. Do you want a diffuse material (this is probably the closest to the basic material used by the workspace engine)?

As a noob, the finer points of "diffuse material" versus other materials is kind of lost on me.  But the above code thus far gives me a material I want and thus I am hoping to replicate it as closely as possible with the Eevee and Cycles engines.

I hope my answer comes close to what you had in mind.

The following script allows you to create a material with the colors you'd like and assign it to a specific object. The material is only created once, if another material with the same name already exists that one is used. If it finds the expected shader node it sets the desired color. The first argument is the object you want the material assigned to, which can be retrieved e.g. through bpy.data.objects['NameOfYourObjectHere'].
def add_material(obj, material_name, r, g, b):
    material = bpy.data.materials.get(material_name)

    if material is None:
        material = bpy.data.materials.new(material_name)

    material.use_nodes = True
    principled_bsdf = material.node_tree.nodes.get('Principled BSDF')

    if principled_bsdf is not None:
        principled_bsdf.inputs[0].default_value = (r, g, b, 1)

    obj.active_material = material

Thanks - that works well; now the material shows up in the shading workspace as well as in layout.


text:
Blender 2.8 simple approach to overlaying dirt?
In Blender 2.8, within the boundaries of a big rectangle I have several overlapping objects (planes and text) to which I would like to overlay a semitransparent layer of dirt.
Will this work?
(a) Create a new plane that with the same dimensions as the big rectangle
(b) Assign a .png image of dirt to the new plane
(c) Position the new plane over the big rectangle
(d) Set the transparency of the new plane as desired
If so, I would appreciate suggestions on how to
(i) make the dirt.png image appear in the new plane and
(ii) set the transparency of the dirt
Thanks in advance!

Select the plane with the Black and white dirt image and switch its blend mode and shadow mode to "Alpha something", and play with the parameters until you get the look you're looking for.

What would I do if I want the grime to be darken the picture (like soot) rather than lighten it (like ash)?  It seems that the dark parts of the black and white picture become transparent.  Is it possible to reverse the effect (so that the white parts are transparent)?

yes, just swap the two inputs in the mix shader, black leads upper signal, white will switch to lower one (and gray will mix both).

Thanks - that works nicely.  Two questions/issues:  (a) why when I switch from Shading to Layout, everything goes gray?  (b) In Shading, the objects that are not now "dirty" have gone from gray to white.

Please clarify your question. When you switch from Shading to Layout are you stil in "rendered" view mode? Whta does it mean from gray to white? Maybe you could share your file.

For (a) it turns out to be q question of view mode.  For (b) an oversight on my part.


text:
Python 2.8 - why does linking the image texture node throw an error?
In Blender/Python 2.8, I am trying to create an image texture node for an object.  The last line of the code below throws this error:
AttributeError: 'NoneType' object has no attribute 'inputs'
I tried replacing 'Diffuse BSDF' with 'ShaderNodeTexImage' and it still threw the same error.
Your suggestions would be much appreciated.  Thanks in advance.
material = bpy.data.materials.get(material_name)
if material is None:
    material = bpy.data.materials.new(material_name)
material.use_nodes=True
nodes = material.node_tree.nodes
material_output = nodes.get("Material Output")
path=TextureFolder+TextureFilenamePost
imgTex = bpy.data.images.load(path)
node_texture = nodes.new(type='ShaderNodeTexImage')
node_texture.image = imgTex
node_texture.location = 0,200
links = material.node_tree.links
link = links.new(node_texture.outputs[0], nodes.get("Diffuse BSDF").inputs[0])

This happens because there is no Diffuse BSDF in your material. If you create a new material with bpy.data.materials.new() it will contain only as Principle BSDF and Material Output Node. You need to create the Diffuse BSDF node first.
nodes.get("Diffuse BSDF") returns None because it can't find a node with that name. The error occurs when you try to access input[0], which as the errors says, is no attribute of NoneType.

Thanks.  @rjg - This gives rise to another set of issues with the same code which I raise in this post:  https://blender.stackexchange.com/questions/146746/python-2-8-creating-diffuse-bsdf-in-a-shader-node-when-i-want-it-in-a-surface-n   If you care to comment on the follow on post, it would be greatly appreciated.

@vndep I was wrong about the material being empty. It does create a Principle BSDF and Material Output Node by default. Sorry for that.

That's OK - I appreciate any advice you can give!  I've whittled the problem down to a simple issue of linking the Diffuse BSDF to the output.  Do you have any suggestions?  I am now on this question...https://blender.stackexchange.com/questions/146746/python-2-8-creating-diffuse-bsdf-in-a-shader-node-when-i-want-it-in-a-surface-n

@vndep lemons answer should work well. Basically you need to connect the BSDF output socket from the Diffuse BSDF node with the Surface socket input of the Material Output node. So something like links.new(diffuse_BSDF.outputs["BSDF"], nodes.get("Material Output").inputs["Surface"])

It's better to do thing cleanly as lemon has shown by clearing the initial material and checking the return value of .get().


text:
function 'register' is not defined
I am trying to run a custom script when Blender starts.
My script location is

C:\Program Files (x86)\Blender Foundation\Blender\2.70\scripts\startup

My idea is to start a TCP server on Blender start up, but Blender is complaining:

NameError: name 'register' is not defined

This is my script:
import bpy
import socketserver

class MyTCPHandler(socketserver.BaseRequestHandler):

def handle(self):
    # self.request is the TCP socket connected to the client
    self.data = self.request.recv(1024).strip()
    print("{} wrote:".format(self.client_address[0]))
    print(self.data)
    # just send back the same data, but upper-cased
    self.request.sendall("[MOVE]MessageReceived[END]")

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

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

if __name__ == "__main__":

    register()

    # Create the server, binding to localhost on port 9999
    server = socketserver.TCPServer(("localhost", 9999), MyTCPHandler)

    # Activate the server; this will keep running until you
    # interrupt the program with Ctrl-C
    server.serve_forever()

The script has a few issues, first indentation seems not correct and seems to cause the error (could be caused by copy and paste).
Python relies on the indentation of code because it doesn't use braces to separate code segments syntactically.
Before a class can be registered as an operator the class must be inherit from bpy.types.Operator or bpy.types.Menu (see the docs whether there're more options).
The socketserver constructor is not invoked.
Related:

https://stackoverflow.com/questions/3277367/how-does-pythons-super-work-with-multiple-inheritance
Blenders build-in text editor provides some examples of operators as Templates acessible from the Menu.


text:
How to delete part of an fbx model?
I have exported a mesh character from Unreal Engine 4 as a fbx file. I want to remove everything but the head.
I literally have no idea how to use Blender and the UI seems confusing and overwhelming.
Could anyone possibly tell me how to delete everything but the head, step-by-step.
.blend file

This question appears to be off-topic because it is way too general

First, import the mesh by pressing File > Import > FBX and navigating to the .fbx file.

Once you have your object imported, ensure that it is the active object (orange outline). If it's not active, right click on it.
Then press Tab to enter Edit Mode where you can edit the underlying mesh.
In your case, you can select the parts of the mesh you want to delete by:

Selecting a vertex on the head with  RMB
Press CtrlL to select linked geometry
Press CtrlI to invert selection

Once you have the vertices you want to delete selected, press Delete > Vertices to delete them.

When I press Shift L it deselects the entire thing, and then when invert selection it would select the entire mesh. Why is this happening?

Thank you, been trying to figure this out for nearly 5+ hours :D

@Kevin Oops, I meant Ctrl L. Shift L deselects connected geometry.

Just note that some information might be lost when importing and exporting the model (such as some material or rig information) since the import and export code are for different versions and don't support the same features.


text:
Black artifacts in my renders
I'm getting black artifacts in my renders. It looks like black pepper.
I've already re-calculated the normals (they were already facing in the right direction, anyway). You can see the artifacts on the door and the awning:

I'm using v2.68, but I get the same thing in v2.70.

If you could upload your .blend file, I could find exactly what is causing the issue.

The black artifacts are caused by intersecting meshes. In order to fix the issue, select the house model, enter edit mode and use W > "Remove doubles". Finally, go back to object mode and check if you have any duplicates of the objects in your scene, and delete them.

Thanks for your help. What you suggested fixed the problem on the awning, but I'm still getting the artifacts on the post and front door.

I fixed it! Turns out, I had double objects in my post and on the door. Thanks again, user2926289!


text:
How to select and merge vertices into separate triangles?
For my blender model, I have an image of a half-sphere. On its face it is triangulated and I want to merge the triangles together so they are like the portion that the red arrow is pointing to:

What I have tried doing is first going to select on the bottom left, and then using circle select. I selected the areas and I tried doing many different things:
First, I tried pressing AltM and I was given the choice of merging at center, at cursor, or collapse. None of these can give the function I need.
Then, I tried pressing Select > Vertices > Connect and nothing happened.
I have tried using this: http://wiki.blender.org/index.php/Doc:2.4/Manual/Modeling/Meshes/Editing/Vertices/
Does anyone know what I should do?

Try selecting everything and pressing Alt+J

Switch to edge select mode (CtrlTab> Edge)

Select the edges you want to cut. Border select works well (B), or you can select a couple edges like the ones you want to select and press ShiftG> Face Angles.

Press W> Subdivide and turn up the smoothness in the redo panel.

Note
I very much recommend working with quads instead, and using a triangulate modifier to non-destructively triangulate the mesh in realtime.

By my count, the part of the sphere in which you have consolidated the triangles into quads amounts to 1/8 of the sphere. I would delete the other 7/8 of the sphere, and use an array modifier to add 7 more instances, and then apply the modifier to achieve what you are wanting to do.


text:
Blender 2.8 (Python) - resetting camera rotation to (0,0,0)
I am trying to set the camera rotation to 0,0,0.  It is not known in advance what the X,Y,Z rotation angles are before doing so.
My thought is to get the current rotation parameters using obj.rotation_euler and then doing a reverse rotation on each of the axes.
For some reason, the transform.rotate code below doesn't actually do anything.
Thanks in advance for your help!
obj=bpy.data.objects['Camera']
objrot=obj.rotation_euler
bpy.ops.transform.rotate(value=-objrot[0], orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, use_proportional_edit=True, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.ops.transform.rotate(value=-objrot[1], orient_axis='Y', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, use_proportional_edit=True, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.ops.transform.rotate(value=-objrot[2], orient_axis='Z', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, use_proportional_edit=True, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)

Martin's answer is the way to go. Note that setting camera rotationn to 0,0,0 means it will point straight down (i.e. looking negatively along the Z-axis)

bpy.context.scene.camera.rotation_euler = (0,0,0)


text:
Blender 2.8 (python) - How to set material color using hex value instead of RGB
I would like to rewrite the following script so that I can set the color of the material using a hex value; currently it works with RGB.
A search of the literature provides no suggestions as to how to proceed.
Any advice would be much appreciated!
def add_material(obj, material_name, r, g, b):
    material = bpy.data.materials.get(material_name)
    if material is None:
        material = bpy.data.materials.new(material_name)
    material.use_nodes = True
    principled_bsdf = material.node_tree.nodes['Principled BSDF']
    if principled_bsdf is not None:
        principled_bsdf.inputs[0].default_value = (r, g, b, 1)
    obj.active_material = material

Related: https://blender.stackexchange.com/questions/66259/properly-convert-hex-color-code-to-blender-rgb-in-python

You can convert a hex value to rgb like below, using shift and bitwise and operator, then divide it by 255 to get a value between 0 and 1.
import bpy

def hex_to_rgb( hex_value ):
    b = (hex_value & 0xFF) / 255.0
    g = ((hex_value >> 8) & 0xFF) / 255.0
    r = ((hex_value >> 16) & 0xFF) / 255.0
    return r, g, b

def add_material(obj, material_name, h):
    material = bpy.data.materials.get(material_name)
    if material is None:
        material = bpy.data.materials.new(material_name)
    material.use_nodes = True
    principled_bsdf = material.node_tree.nodes['Principled BSDF']
    if principled_bsdf is not None:
        principled_bsdf.inputs[0].default_value = (*hex_to_rgb(h), 1)
    obj.active_material = material

h = 0xE7E7FF

obj = bpy.context.object

add_material( obj, "test", h )

Note: you won't obtain the same value in the UI as the hex value is shown gamma corrected.

Hi Lemon I hope you will excuse me for this disappointment, but this Hex value does not coincide with the Hex value returned by the node color input, in fact if we check the Hex result of this conversion is F4F4FF while your input is E7E7FF

@Pastrokkio, yes as said in the note at the end of the answer the value is gamma corrected in the node field.

Hi , I would like to point out that I received the correct answer to this link, so it can be useful for the comunity https://blender.stackexchange.com/questions/158896/how-set-hex-in-rgb-node-python?noredirect=1#comment269316_158896

Final code version :
    def srgb_to_linearrgb(self, c):
        if   c < 0:       return 0
        elif c < 0.04045: return c/12.92
        else:             return ((c+0.055)/1.055)**2.4

    def hex_to_rgba( self, hex_value ):
        hex_color = hex_value[1:]

        r = int(hex_color[:2], base=16)
        sr = r / 255.0
        lr = self.srgb_to_linearrgb(sr)

        g = int(hex_color[2:4], base=16)
        sg = g / 255.0
        lg = self.srgb_to_linearrgb(sg)

        b = int(hex_color[4:6], base=16)
        sb = b / 255.0
        lb = self.srgb_to_linearrgb(sb)

        return tuple([lr, lg, lb, 1.0])


text:
Blender 2.8 (Python) - what does this console error mean
It occurs when I am printing to disk a .jpg image of my scene:
AL lib:  (EE) ALCmmdevPlayback_mixerProc:  WaitForSingleObjectEx error:  0x102

My script just stalls out after the error message appears.
Anything I can do about it?

That error is coming from your OpenAL (Open Audio Library) which encounters a problem. It may be unrelated to your issue though. You can temporarily disable the sound system by starting Blender from the terminal with the -noaudio flag or set Audio Device to Null in the preferences (Edit > Preferences).
If your script still fails to write to disk it's likely a bug in your script and not caused by a problem with OpenAL. You can revert the changes in the preferences if that's the case. Should the problem disappear with the suggested settings, then it would be nice if could write a bug report (Help > Report a Bug in Blender).


text:
Blender 2.8 - how to eliminate a shadow
I have a scene that I otherwise like, but has a shadow on a plane (image) that is serving as a backdrop.  Is there a setting I can adjust on the plane/image that will eliminate shadows cast on it?
Thanks in advance!

You wont get any shadows if you are using an Emission shader in your material for the backdrop.

Thanks that works!  How does one do that in python?

You can use this as a base for your script:
https://blender.stackexchange.com/questions/23436/control-cycles-material-nodes-and-material-properties-in-python

Thanks ... I tried to adapt the code and failed.  I have posted a new question on the problem and would greatly appreciate your suggestions, if you are interested in providing them.  https://blender.stackexchange.com/questions/146269/python-2-8-eliminating-shadow-by-adding-emission-shader-to-background-plane-im


text:
Grayed out object in the Scene Collection
For some reason, one of my two light objects has become gray and no longer appears in the scene.  It has XYZ coordinates, but when I look for it I don't see it.  How can I "un-gray" it so that it becomes usable again?

Click this little Funnel icon in your browser to open the Filter setting,

see if this Icon is on or off. You probably set the light to be Invisible in the viewport, i.e. the Monitor Symbol, and then reset the filters to just show the icons for visibility, i.e. the Eye.


text:
Access new objects location after separation of mesh?
Hello Blender scripters,
I am a beginner trying hard to work on some scripts. I have been stuck on this problem for some time and any help would be appreciated.
I have managed to programmatically select vertex groups and separate them into new meshes based on selection. However when I try to access the location of these newly created meshes in object mode they return me the location of the original mesh from which they were separated.
Is there anyway to calculate the location of these new meshes? Please let me know. Thanks!

After you separate the meshes their origins are still the same as when they were together. This is normal behaviour. After you separate the meshes into its parts you need to set origin to geometry for every newly created mesh.
import bpy

for object in bpy.context.selected_objects:
    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')  # set origin to geometry

After you do this you will be able to successfully query the new locations.


text:
How can I put the compositor viewer node result back into Cycles?
I am doing this experiment with Compositor Nodes and Cycles Nodes. There are times where I want to blur an image from Cycles and to bring it into Compositor, simply blur it and back to Cycles.
I have a feeling that this is not possible. But maybe there is a trick to be able to do this in a way that even though it is not realtime, it can be triggered and bake as needed?
A simpler test is if I am using Compositor, load an image, blur it or make adjustment and then export it into Viewer Node, is there in anyway I could ready that "Viewer Node" image into Cycles? -->  I tried this does not quite work, I am getting pink color.

Getting pink...
https://imgur.com/gallery/7df6Q

https://blender.stackexchange.com/questions/71106/cycles-blur-an-image-texture-node

You could probably do this with multiple Render Layers:

first layer renders or loads an image and blurs the result as desired
second layer renders the rest and composite it with the result of 1, either directly or by loading an image texture from file saved in 1.

example:

Sometimes with Blender I am not sure whether it is compositor rendering first and then Cycles at which order.
Maybe I could actually use 2 Blend files, where one is rendering out Image, and the other take the image... it's an idea suddenly pops on my mind.
Because at the moment, Viewer node seems to give output, but the data is not readable by Cycles somehow... a feature that might be possible to add.


text:
How does code execution work in an Animation Nodes node tree?
I need to understand the basic foundations of how the Animation Nodes add-on calculates and executes code.
So there is Auto-Execution, then options like Always, Tree Changed, Frame Changed, Property Changed.
Those options are ok for one node tree. I have not used multiple node trees.
Supposed I have a Script Node that I just need to run once. Jacques told me that I can use the Execute Node Tree button.
Which means... ok, suppose I have a Script node that just needs to do something one time: Perhaps calculating the shortest path distance of 10 vector positions based on a single point and target point.
When the above gets calculated all the time, it will just freeze Blender.
Should I then create a Script node in one node tree and execute it once, and then use the data and store it somewhere (maybe as Text) and then continue?
Another way, maybe I just want Animation Node to check an Object in the scene, and print out the name. One time only. When I use script node, it gets executed all the time.
There is this trigger thing, but I am not too familiar with it. Can we have example?

I will try to explain the execution system of AN:
At first there are normal nodes. Each node resembles a specific function. It computates an output based on the input.
Multiple nodes together form a network. All nodes that have the same color belong to the same network (except Invoke Subprogram nodes, these are a bit special to make it easier to see what belongs together).
There are different types of networks. At the highest level I differentiate between main and subprogram networks. By default all subprogram networks are colored and main networks are (light) gray. Furthermore there are different types of subprograms: Group, Loop and Script
Main networks can be executed on their own while subprograms cannot. Subprograms always need to be called from another network. Most of the time they even have additional input which the caller has to provide. To call subprograms we have the "Invoke Subprogram* node.
Multiple networks (both: main and subprograms) together make up a node tree in Blender. It is not important in which node tree the subprograms are because you the Invoke Subprogram node can also invoke subprograms that are in another tree. However, it is important in which node tree your main networks are.
Each node tree can be executed individually. Executing a node tree means to execute all the main networks in it.
Because of that each node tree has separate execution settings. A node tree can either be executed automatically (this is what the Auto Execution panel is for) or you can execute it manually (or both).
So in your case you could put the nodes that should only be executed once in one node tree. And all the others in another node tree. For the first one you can disable Auto Execution and just use the Execute Node Tree button.
I also wrote something about it here: https://blender.stackexchange.com/a/43697/5449


text:
How do I loft lines into a mesh with Animation Nodes?
This is yet again my confusion with Meshing using Animation Nodes. My idea is to duplicate Lines into multiple Lines object, which later I could loft. Apparently this is not yet simple. Maybe possible, if possible how to do this?

It's easier if you use an existing node to loft elements, which is the Spline Loft node instead. Basically, you create a bunch of splines before, feed that as a list to the node, and then decide on the amount of samples / divisions of the mesh. See this blend here:

Here's a screenshot of the full setup:

The loop below is a workaround for me to get a few splines in the fashion that you did. I feed a list of integers into it, only using the loop index to generate a few start and end coordinates. With that, I create straight splines and collect them in a list at the end.
This spline list I feed back into the loft node. The samples parameter determines the number of points on the spline which the node generates. Spline Samples of 2 means, only start and end point, so a straight line. Important: you also need to set the samples in the other direction. That's why I get the list length in the end, so each spline is then sampled as a division as well.
Using a bit of randomness, you get this:


text:
Export 3D model from Blender to .U3D for use in PDF file
.pdf files supports Displaying 3D models, you can view the model from any angle by mouse movements - sort of like looking through the viewport, only the object is fully rendered, "real", etc. This requires a .ud3 file. Blender does not export a .ud3 file. Any alternatives to achieve this?

.pdf need the 3d model to be in .u3d format so you should use a plugin to export your model to .u3d or use intermediate software . check this thread

Thread very helpful. I would add to several requests for a .py plug in for Blender that would allow an export of a .ud3 file. This .ude can be inserted into .pdf files..., great for product demos, portfolios, etc.

did you confirm that the BlenderToU3D plug-in is not working properly?

Well I tried to. Installed ok. Hit Export .ud3 and in the top info box in Blender is a quick message: "The exporter is accessed through the scene buttons. Please head there to use it." which left me baffled. Where are the scene buttons and what should I look for?

I'm going to try it

I'd like to revive this topic. Chebhou did you ever try this? If so, what happened?

as I recall it didn't work at that time but not sure about the details now ( edit your question to get attention  from other users)

You can find the scene button in the property Area, scroll down to find the u3d export.
I managed to export to u3d, but after putting it to pdf with latex the pdf failed to open correctly in adobe reader XI. a "3D data parsing error has occurred"

So, it actually did not work? And where to get the plugin?


text:
How to add update function to custom property using _RNA_UI
How to add update function? I tried this its wrong.
pbone = bpy.data.objects[ControleObj].pose.bones[ControleBone]

pbone[ControleName] = min

if "_RNA_UI" not in pbone.keys():
    pbone["_RNA_UI"] = {}

pbone["_RNA_UI"].update({"myControl": {"min":0.0, "max":1.0, "soft_min":0.0, "soft_max":1.0, "update" = FunctionName }})`

You shouldn't change _RNA_UI, it's used internally by Custom Properties panel. If you want an update callback for a property, register a bpy.props property: http://www.blender.org/api/blender_python_api_2_75_release/bpy.props.html#update-example


text:
Why the mesh is twisting when base bone is rotated?
I am trying to rig long year of dog.

It needs to bend along chain of bones
And its base bone should be able to rotate the whole ear without twist.

I understand why there is deformation but i need to understand why there is twist in whole ear when only base bone is rotated

Please check this EAR Rig File and help me with twist.

That deformation occurs because you didn't add weights in weight paint mode.

Select the armature and change to pose mode
In pose mode with the armature selected click the mesh
Change to weight paint mode
Select bone by bone and add vertex weight

Related:
Vertex Weight Issues

I understand why there is deformation but i need to understand why there is twist in whole ear when only base bone is rotated

You have two sets of bones DEF and MCH , MCH inherit the rotation from the root bone , while the DEF bones copy the location and the orientation of MCH but they keep their own rotation ( DEF bones are the ones controlling the mesh ) when you rotate the root or one of the MCH bones the DEF will follow but maintain its rotation ( which seems like the twisting effect )
A quick solution is to choose the first DEF bone and parented to the first MCH bone ( also check inherit rotation )

@ashwin does this answer your question ?


text:
switching between wacom and mouse
It get crazy while switching between wacom and mouse as they need different kind of button actions or say "user preferences"

For Example in wacom i can zoom using side touch strip. So free the midlle button click for special menu like "w". But to do this i need to change preference every time i switch.

Is there any quick or automatic way to blender can find whether i am using mouse or wacom pen and change between "user preferences"
Or any other work around?

I don't experience any problems like this. When I use my Wacom tablet, then go back to my mouse, everything is a seamless transition. What kind of button actions are you talking about?

Please check the added explanation

I just started to use my Wacom Intuos one week ago and I have not disconnected my 3 button gaming mouse. With Blender 2.8 I discovered that using the lower button of the tablet (equivalent to the middle mouse button) I can rotate the view, pressing Shift at the same time I can move the scene to the sides and pressing control I can zoom in and out. It is not necessary to change anything from the configuration and I can switch to the mouse if I want without any problem. My OS is GNU/Linux Debian 10 and my desktop is Mate.


text:
Cycles why image squence texture is automatically animating?
I have just added image sequence as texture and when i play the timeline the texture goes to next frame automatically why ?
here are the source blend + image files please check
Video of the error

You need to animate the 'offset' value of the image node. The offest needs to decrease by one for every one frame you go forward.
So on frame 5, you would need to make the offset '-4' as you have gone forward 4 frames (from frame 1):

So even though you have gone forward it will still show frame 1 of the image sequence.
If it was frame 7 you would offset by '-6' frames to still only show frame 1:

The following only works for the viewport, not the render.
You have 'Auto Refresh' turned on on your image nodes:

Turn this off if you don't want the frames to update automatically on frame changes.

it just stops changing in viewport preview. But when i render movie (render animation) the frames are still chaninging.
If i uncheck Cyclic then it gets pink once the last frame in sequence is changed. But all this without i animation it !!

Then it seems @cegaton's comment was correct about needing to animate the offset. Cyclic is if you want the image sequence to repeat. If you turn it off and you exceed the image sequence frame range it will display pink as it regards the textures as 'missing'.

i understand why it gets pink but why it is changing automatically. And its even not even working if i key the offset.

Because you have set it to image sequence. It is presumed you want to change to the next image as that will be the most common useage.

https://youtu.be/u-H0xmViiFQ please see the video its animating even when the offset is keyed to zero

the offset should be animated to the inverse of the current frame offset = -frame + current_slide

@ashwin updated answer.

In blender internal mayerial if i use image sequence it stays still unless i change image offset. But in cycles material it animates

If you don't want Blender to automatically advance the visible frame of your image sequence, set the "Frames" parameter to 1. This will effectively lock the image sequence on its currently visible frame, defined as: "Start Frame" + "Offset."
With this setup you should be able to animate the "Offset" parameter (or drive it with a driver) independent of the current frame.


text:
How to find the UV vertex count? is there a script to do so?
While unwrapping for Unity 3D game development "UV vertex" count is an important aspect.
I was reading this GPU: Optimizing Model Geometry
It says "Try to keep the number of UV mapping seams and hard edges (doubled-up vertices) as low as possible"
ie. Every time i create a seam or split UV i double that many nulber of UV vertices. If so ...
How do i find out what is the total and individual object UV vertex count in Blender ?
Is there a script to find UV vertex count?

What do you mean by "UV count"? I've done extensive work in Unity for several years and I've never heard of a "UV count"

@ Keith M, sorry i was not very clear in my question i feel. If you go by this link "GPU: Optimizing Model Geometry" https://docs.unity3d.com/355/Documentation/Manual/OptimizingGraphicsPerformance.html
Try to keep the number of UV mapping seams and hard edges (doubled-up vertices) as low as possible
Do they mean UV vertex count? if so how to find it out?

Working for 15 years with games his is pretty trivial stuff. You don't optimize the UV vert count, you make UVs according to your texturing needs.

This will print the UV vertex count of active UV layer of active object in Object Mode (does not work in edit mode):
import bpy

obj = bpy.context.active_object

# Store all UV vertex locations
uv_coords = []
for loop in obj.data.loops:
    uv_loc = obj.data.uv_layers.active.data[loop.index].uv
    uv_coords.append(tuple(map(lambda x: round(x,3), uv_loc[:])))

# Keep only the unique ones and count them
print("object {0} has {1} UV vertices".format(obj.name, len(set(uv_coords))))

@ Jerryno thank you. Sorry that i had not written my question clearly. Now i have added more details. I want to find count of "UV vertices"

I think the answer you want is a (total object verts - total uv verts)

This is a little rushed, and I still need to test it a little bit more, but it seems to return the correct number of UV vertices for simple meshes. UV unwrap your mesh and run this script in object mode:
import bpy
from collections import defaultdict

mesh=bpy.context.active_object.data

uv_layer = mesh.uv_layers[0].data
verts=defaultdict(list)
loc=defaultdict(list)
count=0

for p in mesh.polygons:
    for l in p.loop_indices:
        index = mesh.loops[l].vertex_index
        uv = uv_layer[l].uv
        co = mesh.vertices[index].co
        if (len(verts[index]) == 0):

            verts[index].append(round(uv.x,2))
            verts[index].append(round(uv.y,2))

            loc[index].append(round(co.x,2))
            loc[index].append(round(co.y,2))
            loc[index].append(round(co.z,2))

            count+=1
        else:
            uvs=verts[index]
            if(uv.x!=uvs[0] or uv.y!=uvs[1]):
                nIndex=len(verts.keys())

                while(len(verts[nIndex])>0):
                    nIndex+=1

                verts[nIndex].append(round(uv.x,2))
                verts[nIndex].append(round(uv.y,2))

                loc[nIndex].append(round(co.x,2))
                loc[nIndex].append(round(co.y,2))
                loc[nIndex].append(round(co.z,2))
                count+=1

uvco=[]

for f, b in zip(verts.items(), loc.items()):
    uvs1 = f[1]
    locs1 = b[1]

    for j, k in zip(verts.items(), loc.items()):
        uvs2 = j[1]
        locs2 = k[1]

        if (uvs1[0] == uvs2[0] and uvs1[1] == uvs2[1] and locs1[0] == locs2[0] and locs1[1] == locs2[1] and locs1[2] == locs2[2]):
            uvco.append((uvs1[0],uvs1[1],locs1[0],locs1[1],locs1[2]))

duplicatesStripped = set(tuple(i) for i in uvco)

print("Unique UV/Vertex coordinates: %s\n" %  duplicatesStripped)

print("There are %d UV vertices" % len(duplicatesStripped))

It's a little bit very messy, but I have to go to lunch now, I'll continue testing it when I get back


text:
Rotating a model of a character distorted the animation
I created a 3D model in Blender, I did a walk cycle on it so this character has an walking animation in it.
I want to use this model and its walk animation in Unity. But Unity is using Y as up direction and Blender uses Z, so when I exported it as FBX file into Unity, it is not working properly.
I would like to rotate the model in Blender first then export it as .fbx file. But the problem comes that when I rotated my model and applied the rotation by CtrlA, the model is rotated well but the animation is destroyed by the rotation, the animation is severely distorted, the legs and arms are in strange behaviors.

There are already a few questions regarding Unity and animation asked here, just search for unity. Not sure if it helps though, the answers are rather discouraging.