text:
How to document a PointerProperty prop?
I can't find any documentation about how to put a property of type PointerProperty in the addon_manual_map
In the following example, you put in the url_manual_mapping all the operators that I want to have access to the documentation with Right Click mouse.
   def addon_manual_map():
        url_manual_prefix = "https://docs.blender.org/manual/en/latest/"
        url_manual_mapping = (
            ("bpy.ops.mesh.add_object", "scene_layout/object/types.html"),
        )
        return url_manual_prefix, url_manual_mapping

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

Now I can't find anywhere how to document for example this prop:
C.scene.my_scene_prop.is_custom_scene

Where is_custom_scene is a property of type BoolProperty
Registered like this:
class MySceneProperties(bpy.types.PropertyGroup):
    is_custom_scene: bpy.props.BoolProperty(default=False)

def register():
    bpy.utils.register_class(MySceneProperties)
    bpy.types.Scene.my_scene_prop = bpy.props.PointerProperty(type=MySceneProperties)

I tried to get it with some different strings but to no avail, here are some examples I tried:
def addon_manual_map():
    url_manual_prefix = "https://docs.blender.org/manual/en/latest/"
    url_manual_mapping = (
        ("bpy.types.Scene.my_scene_prop.is_custom_scene", "scene_layout/object/types.html"),
        ("bpy.types.scene.my_scene_prop.is_custom_scene", "scene_layout/object/types.html"),
        ("bpy.types.scene.MySceneProperties.is_custom_scene", "scene_layout/object/types.html"),
        ("....etc....", "....etc....."),
            )
    return url_manual_prefix, url_manual_mapping

I've also referenced an answer here but haven't been able to apply it to my problem.

Have you tried all lowercase ? bpy.type.scene.my_scene_prop.is_custom_scene

Yes, as in the example. I also edited the question as I wrote bpy.type instead of bpy.types... (My mistake) Either way it doesn't seem to work


text:
Separate World Mapping on Z axis and make them independent?
My nodes config:

I'm trying to set the nodes in order to modify the top and bottom (+Z/-Z) independently with the Mapping Nodes, I also put a Map Range node to blend the +Z-Z coordinates
Changing the values of the Mapping nodes (Location Z or Scale Z) I don't get the desired effect.
The Mapping node (Bottom) should be able to Stretch on the Z axis (Only in the -Z part) with the Scale Z value so as to be homogeneous and blended with the upper part.
The Mapping (Top) node should do the same but at the top +Z
The biggest problem is that only 1 of the 2 mapping nodes will be right (Bottom) will control the Upper part of the world without affecting the upper one, while the other mapping (Top) will unfortunately change everything.
I wish I could just figure out how to configure the nodes to make independent with a feather boundary between -Z and +Z.
Oddly enough if I use the math greath Than (0.0) node instead of Map Range I get the desired result but without a gradient range, I'll get a sharp detachment.

If I've understood you correctly, the space you're interested in is Generated. You can take its 0-1 Z coordinate, and use some mapping of that as a factor in a Color Mix between 2 manipulations of it:

Below, the mapped image is mixed,

but you could mix the vector-spaces directly:

Here, to scale the top half:

In your second example it doesn't change much from mine with map range, but it helped me to understand that the range must be much lower, in fact I set From Min = 0.01 From Max = 0.00 , You get similar result, the map range node and that Color Ramp in this case they can both replace each other. Personally I prefer the Map Range node as it has the inputs to better control the node also via group node. However, it works just fine as well as in your second example.

Hi, @Noob Cat.. You're right there.. I wound up with the Color Ramp because I used color in it it earlier to visualize Z, and probably should have replaced it.(I have a standard ramp with thin constant stops near the ends to  see where 0,1, and ,5 are.)

source: Stack Exchange

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

sort: votes


text:
How can you show socket descriptions in My VIEW_3D panel into Blender 4.0?
From some version I noticed that the node_groups sockets have a new "description" attribute which however was not visible in the interface until the Blender 4.0 version which now makes it possible to insert the description directly from the "Group" panel of the Shader Editor.
The description works well only if you hover over the Group node input, but not if you hover over the property drawn in the panel (See code example below)
I wonder if this is expected behavior, or something can be done about it to show the description in my Panel too
class MYADDON_PT_MyPanel(Panel):

    bl_label = "My Panel"
    bl_idname = "MYADDON_PT_MyPanel"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "My Addon"

    def draw(self, context):

        ob = context.object
        if not ob:
            return
        mat = ob.active_material
        if not mat:
            return

        if not mat.use_nodes:
            return

        node_tree = mat.node_tree
        nodes = node_tree.nodes

        my_node = nodes.get("My Node")
        if not my_node:
            return

        layout = self.layout
        for n_input in my_node.inputs:
            layout.prop(n_input, 'default_value', text=n_input.name)

Example

Blender 4 has only just had its first beta release and isn't due for general release until  November so questions about it are off-topic here.   If you suspect it may be a bug you should report it via Blender's Help > Report a Bug menu giving a full description of what you're trying to do.

@JohnEason can you point to a source stating it is off-topic? I don't see anything about βeta here, in fact I don't see anything about αlpha… I could understand the reasoning of frowning upon alpha related questions/answers, because if the software changes (OK, it keeps changing, but old versions are available, and acquiring a particular alpha version is very hard) the content becomes obsolete. However this is not the case with beta versions - as long as a particular behavior is not a bug.

@MarkusvonBroady Apologies. I should have said that since it appears to be a bug in an unreleased version it is important to report it as a bug so that it can be corrected before the general release. I'm sure that I saw mention of reports on unreleased versions being off-topic a hile ago, but it looks asif I was wrong.

@MarkusvonBroady I don't know if there is a written rule but the matter of the fact is that most problems that users face with using alpha or beta versions will either be ironed out in the bug fixing phase, and/or should be reported to the bug tracker. Depending on the proximity of the official release date, things may or may not change without a warning so a valid answer may not be valid a few days later, and a question may not be valid a few days later.

That being said I think questions about Beta versions have their place here but only after the bug fixing phase has begun, and the API has stabilised and core features won't change drastically.

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


text:
How do I change the default color picker mode from HSV to RGB?
Blender 2.8x default is HSV, but I want RGB like in 2.7x.
Saving startup file doesn't store new settings.

In the preferences settings one can only change circle to square or HSV to HSL, nothing more. No circle or square RGB

"Saving startup file doesn't store new settings." Settings are saved in the settings file not startup, so you should probably be saving settings from the user preferences dialog

@Duarte Farrajota Ramos There is no such option in preferences, I can only change circle to square or HSV to HSL, nothing more (or I couldn't find)

https://blender.stackexchange.com/a/140994/19307

I tried to change it by code but there is no option as RGB color! bpy.context.preferences.view.color_picker_type = 'CIRCLE_HSV' I also try to change the NodeSocketColor but there is no access to this class

there is no option to change the color picker type to rgb
but you can download source of blender 2.83 and add an option to change colors to rgb

blender-2.83.5\source\blender\editors\interface_region_color_picker.c

Easy Solution
as you know enum has a default value

enum ePickerType {
  PICKER_TYPE_RGB = 0,
  PICKER_TYPE_HSV = 1,
  PICKER_TYPE_HEX = 2,
};

by default color picker type is PICKER_TYPE_HSV = 1
so you can change it to PICKER_TYPE_RGB = 0
 static char colormode = 0;

Hard Solution Adding to preferences
you should add a case for RGB in preferences
  switch (U.color_picker_type) {
    case USER_CP_SQUARE_SV:
      ui_colorpicker_square(block, ptr, prop, UI_GRAD_SV, cpicker);
      break;
    case USER_CP_SQUARE_HS:
      ui_colorpicker_square(block, ptr, prop, UI_GRAD_HS, cpicker);
      break;
    case USER_CP_SQUARE_HV:
      ui_colorpicker_square(block, ptr, prop, UI_GRAD_HV, cpicker);
      break;

    /* user default */
    case USER_CP_CIRCLE_HSV:
    case USER_CP_CIRCLE_HSL:
    case USER_CP_CIRCLE_RGB: # I ADD THIS CASE HERE
    default:
      ui_colorpicker_circle(block, ptr, prop, cpicker);
      break;
  }

there is a function to change the hsv/hsl to rgb:
void ui_color_picker_to_rgb(float r_cp0, float r_cp1, float r_cp2, float *r, float *g, float *b)
{
  switch (U.color_picker_type) {
    case USER_CP_CIRCLE_HSL:
      hsl_to_rgb(r_cp0, r_cp1, r_cp2, r, g, b);
      break;
    default:
      hsv_to_rgb(r_cp0, r_cp1, r_cp2, r, g, b);
      break;
  }
}

enum ePickerType {
  PICKER_TYPE_RGB = 0,
  PICKER_TYPE_HSV = 1,
  PICKER_TYPE_HEX = 2,
};

How does enum work?
 /* mode */
  yco = -1.5f * UI_UNIT_Y;
  UI_block_align_begin(block);
  bt = uiDefButC(block,
                 UI_BTYPE_ROW,
                 0,
                 IFACE_("RGB"),
                 0,
                 yco,
                 width / 3,
                 UI_UNIT_Y,
                 &colormode,
                 0.0,
                 (float)PICKER_TYPE_RGB,
                 0,
                 0,
                 "");

  UI_but_flag_disable(bt, UI_BUT_UNDO);
  UI_but_func_set(bt, ui_colorpicker_create_mode_cb, bt, NULL);
  bt->custom_data = cpicker;
  bt = uiDefButC(block,
                 UI_BTYPE_ROW,
                 0,
                 IFACE_((U.color_picker_type == USER_CP_CIRCLE_HSL) ? "HSL" : "HSV"),
                 width / 3,
                 yco,
                 width / 3,
                 UI_UNIT_Y,
                 &colormode,
                 0.0,
                 PICKER_TYPE_HSV,
                 0,
                 0,
                 "");

then you can use this function to change the color picker type:
bpy.context.preferences.view.color_picker_type = 'CIRCLE_RGB'

I also downloaded blender 2.79 source
I found a function to convert rgb to hsv
maybe useful:

2.79\scripts\addons\cycles\source\util\util_color.h

ccl_device float3 rgb_to_hsv(float3 rgb)
{
    float cmax, cmin, h, s, v, cdelta;
    float3 c;

    cmax = fmaxf(rgb.x, fmaxf(rgb.y, rgb.z));
    cmin = min(rgb.x, min(rgb.y, rgb.z));
    cdelta = cmax - cmin;

    v = cmax;

    if(cmax != 0.0f) {
        s = cdelta/cmax;
    }
    else {
        s = 0.0f;
        h = 0.0f;
    }

    if(s != 0.0f) {
        float3 cmax3 = make_float3(cmax, cmax, cmax);
        c = (cmax3 - rgb)/cdelta;

        if     (rgb.x == cmax) h =        c.z - c.y;
        else if(rgb.y == cmax) h = 2.0f + c.x - c.z;
        else                   h = 4.0f + c.y - c.x;

        h /= 6.0f;

        if(h < 0.0f)
            h += 1.0f;
    }
    else {
        h = 0.0f;
    }

    return make_float3(h, s, v);
}

@susu I edited my answer and I did my best to explain how to change the color picker type to RGB

For 2.9 i edited source/blender/editors/interface_templates.c with  'setting PICKER_TYPE_RGB = 0 and it worked fine.  But adding case USER_CP_CIRCLE_RGB: throws error: ‘USER_CP_CIRCLE_RGB’ undeclared (first use in this function);

@susu cheers!!! sorry as I'm a beginner I didn't know how to build the blender and how to test my code. but I was sure about my code! if you tell me how to test it I will try again.

https://wiki.blender.org/wiki/Building_Blender

could it be that the definition is set in a different file? /source/blender/editors/interface/interface_templates.c ?

@susu I will check it as soon as possible

Silly Solution
you can use a macro recorder to change the color type!!!
when you change the color type once it works for other colors until you close the blender
so use this program when you open the blender

import pyautogui

print(pyautogui.position())

pyautogui.moveTo(863,687,0.2) # Materil Position
pyautogui.click()
pyautogui.moveTo(976,677,0.2) # Color Position
pyautogui.click()
pyautogui.moveTo(834,559,0.2) # Change The Color Type to RGB
pyautogui.click()


text:
How to make selections more visible Blender 2.8?
In Blender 2.8's UI I cannot see what I am selecting.
This is Blender 2.79.

These are default settings in Blender 2.8.
I'm having a hard time seeing what vertices and what edges are selected, it is hard for me to distinguish the black Vertices from the orange ones.

With a bit of editing the Themes I managed to increase the contrast - at severe cost of general visibility of the rest of the model. I sacrificed all other contrasts to maximize it for selected vertices & edges.

Turning on X-Ray made the edges clearer but I do not want to worki with X-Ray on just for better visibility.

Turning Line Width to "Thick" in the Preferences makes the Outline stand out even further, however every edge becomes so fat it's it smothers all small details and kills the point of a 4k Monitor.

I was going to recommend Line Width, but I see you already tried it. Unfortunately, since 4k monitors have only recently seen "mainstream adoption", it may be some time before blender is optimized for them. I've seen others complain about UI scale too (because even after editing UI scaling in preferences, some parts just don't scale). Best thing you can do is find a good place to make a feature request, and try and put some more pressure on the issue.

@ChristopherBennett It's still bad on a 2K Monitor. But since everything is larger, you don't have to move your face to within 3 inches of the monitor to realise you cannot see what you are doing.

@ChristopherBennett It would be sweet if the "thick" Line Width would work only for selected/active edges. That would probably solve the issue. Other issue is that if you switch from edge to vert select mode, edges become greyed out unless you have X-Ray turned on

Select Edges (Highlighted) in Viewport Overlays makes selected edges & vertex look as of 2.79.


text:
Show number of Tris selected
Is there a reason it doesn't show you the number of Tris selected? Seems benighted to me. I really need this feature.

Does this answer your question? Bottom Status Bar Doesn't Show Verts, Faces, Tris Information In v2.9a

It could possibly be scripted, but @susu the OP is right, tri count doesn't update.


text:
Animating a mesh deformation using python
I have a 3D mesh in Blender that undergoes some modifications. The mesh is imported from python data. By using a python script, I modify the location of the vertices of the mesh to move them along the normal according to a function which is defined for every single vertex in the mesh. This function is also defined for N frames and determines the amount of vertex translation along the local normal for each frame, i.e. f(iVertex, iFrame). This can create an animation if played from frame number 1 to frame N. In addition, the mesh itself is not translating or rotating and in fact, it is its shape that undergoes gradual deformation and change. I am looking for a strategy that can animate this shape deformation using a python script.

Since you have the function just append it to a handler ( frame_change_pre )  you'll have to wrap it in another function to loop through verts

Thank you for the great suggestion. It worked just fine.

you should write an answer to help others with the same problem

As suggested by Chebhou, the problem can be addressed perfectly and very elegantly by using frame_change_pre. I was inspired by the example that was posted here and I bring it here for the readers' convenience:
import bpy
import math

# for demo it creates a cube if it doesn't exist,
# but this can be any existing named object.
if not 'Cube' in bpy.data.objects:
    bpy.ops.mesh.primitive_cube_add()

frames_per_revolution = 120.0
step_size = 2*math.pi / frames_per_revolution

def set_object_location(n):
    x = math.sin(n) * 5
    y = math.cos(n) * 5
    z = 0.0
    ob = bpy.data.objects.get("Cube")
    ob.location = (x, y, z)

# every frame change, this function is called.
def my_handler(scene):
    frame = scene.frame_current
    n = frame % frames_per_revolution

    if n == 0:
        set_object_location(n)
    else:
        set_object_location(n*step_size)

bpy.app.handlers.frame_change_pre.append(my_handler)

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


text:
Get if a drag and drop was done from the asset browser in python?
My idea is to use a modal operator, or a modal function that runs in the background.
The idea is to get an if statemen event based on a hypothetical drag and drop from the asset browser.
def modal(self, context, event):
    if event.type == 'TIMER':
        # Dummy Example:

        # if drag_and_drop_event:
        #     print("Drag and drop event from asset browser")

    return {'PASS_THROUGH'}

I don't know if that's the correct approach. I can't find a better idea than this.
So I limit myself to this question, precisely, capture any drag and drop event from the asset browser.
As @Gorgius suggested in the comments, better to use a bpy.app.timer for this example and not a modal
def in_1_seconds():
    # Dummy Example:

    # if drag_and_drop_event:
    #     print("Drag and drop event from asset browser")
    return 1.0

bpy.app.timers.register(in_1_seconds, first_interval=1)

AFAIK there is no way to get this event with the python API (yet). Also be careful with modal operators running in the background, they deactivate autosave. Better use application timers for that

Yeah, I made an example with a modal, but it was better to do it with bpy.app.timers with a function

I do not think there is any option or code to do that. Only way that I can think of, to get past this, is by using application timers. For more information on them, use this link: Application timers

I am not sure but if you drag and drop in python it might create lag. It allows you to get round it by using drag and drop on the actual website by loading it and then dragging it straight onto the picture.

@Z-animator Yes exactly, it was one of the plausible ways. But I really don't know what API to use to intercept a drag and drop. (I added it in the question in addition to the modal)


text:
How to create Callback to move an object on the X/Y/Z axis of the local axes with property?
I want to move the object on its local axes, I think by default there isn't a Blender Python property that allows it, I have to draw the X/Y/Z sliders of the local location in the user interface to move the object.
My idea is a custom property called local_location or local_location_x local_location_y local_location_z
Using this, create a callback function:
def update_local_location():
    ob = self.id_data

# Property declared into PropertyGroup (bpy.types.Object)

local_location_x: FloatPropery(update=update_local_location)

Normally to move a location object it is sufficient to use this line in the interface:
layout.prop(ob, "location")

or to show only one slider, in this case X-axis:
layout.prop(ob, "location", index=0)

The goal is to design a slider that can move the object on its local axis and not on the Global one.
I'm missing figure out how to properly create that Callback function in case blender doesn't have a python API to move to local location
I also tried using Batfinger's answer below, but it doesn't seem to work well:
Change Object's Location on local Z-Axis using Slider

moving an object along its local axis is a built in feature... so (to me), your question is not clear.

@lemon Yes, but usually it will move on the global axis. I have to move it on the Local axis, so it depends on the orientation of the object. I just need to draw 3 prop sliders that can move the object on the local X/Y/Z axis

So grad along XX (twice) for X local axis is not what you're looking for? why?

Sorry, I do not understand what you mean. I simply have to draw 3 sliders, which move the object on its local axes. I don't understand if Blender already has a Python API that allows it.

I don't consider myself a reputable source, because I'm quite a noob, but I do something similar to what I think it is that you're asking.
Maybe you can do something with this code. I think in your case all that might be of interest is the bpy.ops.transform.translate line, but I don't know how you would use it with a slider. I use a checkbox to select the axis. I use a button click to move the desired distance that comes from what I think you call a slider.
This is a snippet that moves the object a specified distance based on the measurement unit selected, in this case inches, on a selected axis, on any transformation orientation:
class KF_OT_MOVOBJ(bpy.types.Operator):
"""Move object along selected axis"""
bl_label = "Move Object"
bl_idname = "kf.movobj"

def execute(self, context):

    if (bpy.data.scenes["Scene"].my_props.dist_enum == 'U_INCH' and bpy.data.scenes["Scene"].my_props.x_bool):
        mov_dist_num = bpy.data.scenes["Scene"].my_props.mov_dist_num * 0.0254
        bpy.ops.transform.translate(value=(mov_dist_num, 0, 0), orient_axis_ortho='X', constraint_axis=(True, False, False))

    elif (bpy.data.scenes["Scene"].my_props.dist_enum == 'U_INCH' and bpy.data.scenes["Scene"].my_props.y_bool):
        mov_dist_num = bpy.data.scenes["Scene"].my_props.mov_dist_num * 0.0254
        bpy.ops.transform.translate(value=(0, mov_dist_num, 0), orient_axis_ortho='X', constraint_axis=(False, True, False))

    elif (bpy.data.scenes["Scene"].my_props.dist_enum == 'U_INCH' and bpy.data.scenes["Scene"].my_props.z_bool):
        mov_dist_num = bpy.data.scenes["Scene"].my_props.mov_dist_num * 0.0254
        bpy.ops.transform.translate(value=(0, 0, mov_dist_num), orient_axis_ortho='X', constraint_axis=(False, False, True))   # etc.,etc.

    return {'FINISHED'}

The code I left out is the same as above, but it covers different measurement unit conversions and the various axis selections.
Here is the link to the transform operators: https://docs.blender.org/api/current/bpy.ops.transform.html

For object mode

import bpy
from bpy.types import Panel
from bpy.props import FloatVectorProperty
from mathutils import Vector

import bpy
from bpy.app.handlers import persistent

is_updating = False
@persistent
def upd_handler(dummy): # update the n-panel prop when active object location changed
    global is_updating
    if is_updating: return
    is_updating = True

    try:
        if bpy.context.scene.my_tool.loc != bpy.context.object.location:
            bpy.context.scene.my_tool.loc[:] = bpy.context.object.location
            print("update")
    except:
        pass

    is_updating = False

class MyProperties(bpy.types.PropertyGroup):
    is_updating = False
    def upd_loc(self, context):
        cls = self.__class__
        if cls.is_updating: return
        cls.is_updating = True

        try:
            obj = bpy.context.object
            old_loc = obj.location
            prop = bpy.context.scene.my_tool.loc

            if old_loc[0] != prop[0]:
                vec = Vector((prop[0] - old_loc[0], 0, 0)) @ obj.matrix_world.inverted()
                obj.location += vec
            elif old_loc[1] != prop[1]:
                vec = Vector((0, prop[1] - old_loc[1], 0)) @ obj.matrix_world.inverted()
                obj.location += vec
            else:
                vec = Vector((0, 0, prop[2] - old_loc[2])) @ obj.matrix_world.inverted()
                obj.location += vec

        except:
            pass

        cls.is_updating = False

    loc: FloatVectorProperty(name="Location", size=3, subtype="XYZ", update=upd_loc)

class XX(Panel):
    bl_idname = "XX_PT_Panel"
    bl_label = "Panel"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "TEST"

    def draw(self, context):
        layout = self.layout
        mytool = context.scene.my_tool
        layout.prop(mytool, "loc")

def register():
    bpy.utils.register_class(MyProperties)
    bpy.utils.register_class(XX)
    bpy.types.Scene.my_tool = bpy.props.PointerProperty(type=MyProperties)

    if upd_handler not in bpy.app.handlers.depsgraph_update_post:
        bpy.app.handlers.depsgraph_update_post.append(upd_handler)

def unregister():
    bpy.utils.unregister_class(MyProperties)
    bpy.utils.unregister_class(XX)
    del bpy.types.Scene.my_tool

    if upd_handler in bpy.app.handlers.depsgraph_update_post:
        bpy.app.handlers.depsgraph_update_post.remove(upd_handler)

if __name__ == "__main__":
    register()

Sounds interesting, but I don't understand, in that video, it looks like you're interacting on Slider X. But why do the values also change on Y and Z? shouldn't be Local values, so they shouldn't actually change upon interaction on a Local X axis. Then, I wonder. Why a handler function for this? Isn't a callback function enough to update everything?

It is based on the rotation of the object, if the object euler_rotation is not (0, 0, 0), it moves the local space.

If upd_handler is removed, it won't update the active object position, you can remove it and try.

upd_loc only runs when the value you define changes, so it doesn't run when the active object changes.

I think it's not a good idea to use Handlers, are there Get/Set/Update functions that can do this or am I wrong? Keep in mind that the initial value will always be 0,0,0 as the object in question will always be positioned in the center of the Global Default axes

Get/Set Update only runs when getting/modifying the value. When you select other object, it doesn't update. You could consider using Message Bus to subscribe an existing attribute, but it will fail on drag the object using the move tool. https://docs.blender.org/api/3.5/bpy.msgbus.html

If you want to control the local location so that it affects the normal location, you can just rotate the local rotation like so:
import bpy
from bpy import context as C, data as D
from bpy.types import SpaceView3D
from mathutils import Vector

last_pos = Vector()

def fun():
    global last_pos
    if C.area.type != 'VIEW_3D':
        return
    cube, empty = D.objects['Cube'], D.objects['Empty']
    if empty.location == last_pos:
        return
    last_pos = empty.location.copy()

    new_pos = last_pos.copy()
    new_pos.rotate(cube.rotation_euler)
    cube.location = new_pos

try:
    SpaceView3D.draw_handler_remove(SpaceView3D.my_handler, 'WINDOW')
except (AttributeError, ValueError):
    pass

SpaceView3D.my_handler = SpaceView3D.draw_handler_add(fun, (), 'WINDOW', 'PRE_VIEW')

Well you probably want to also scale that location, changing this line:
new_pos = last_pos.copy()

to
new_pos = last_pos.copy() * cube.scale

Reversing this operation is not hard, just invert the Euler rotation [I wonder if there's a more convenient way than the one I'm using, other than converting to a matrix to use its inverted() method?], divide by the scale [again, what's the best way to do this?] rather than multiplying it, and of course switch the source with the target (the empty and the cube):
def fun():
    global last_pos
    if C.area.type != 'VIEW_3D':
        return
    cube, empty = D.objects['Cube'], D.objects['Empty']
    if cube.location == last_pos:
        return
    last_pos = cube.location.copy()

    euler = cube.rotation_euler.copy()
    euler.x *= -1
    euler.y *= -1
    euler.z *= -1
    euler.order = euler.order[::-1]
    new_pos = last_pos.copy()
    new_pos.rotate(euler)
    new_pos.x /= cube.scale.x
    new_pos.y /= cube.scale.y
    new_pos.z /= cube.scale.z

    empty.location = new_pos

In regards to the interface part, I think it's beside the main point and requires another question phrased in a way the answers aren't opinion-based (so asking for the best way to implement this is out of the question, pun intended).


text:
How to get and enumerate all the object.empty_display_type in python?
I would like to build a enum function that returns me all types of empty_diplay_type that exist, I am aware of the ones that currently exist, but I am creating a property that needs to change the empty_diplay_type.
Unfortunately I don't know where to look in Blender API
This property is tied to the scene with a PointerProperty,
Then the callback fc looks for all empty and must change the type of empty.
Like this example:
empty_type_list=[]
def enum_empty_types(self, context):

    if empty_type_list:
        return empty_type_list

    for eType in ['PLAIN_AXES', 'ARROWS', 'SINGLE_ARROW']:  #etc. etc.
        empty_type_list.append((eType, eType.replace("_", " ").title(), ""))

    return empty_type_list

def update_empty_type(self, context):

    for o in context.scene.objects:
        if o.type == 'EMPTY':
            o.empty_display_type = self.empty_types

class MySceneProp(bpy.types.PropertyGroup):

    empty_types: EnumProperty(items=enum_empty_types, update=update_empty_type)

Looking for bpy.types.Object.bl_rna.properties['empty_display_type'].enum_items?

@scurest Uh yes, so: bpy.types.Object.bl_rna.properties['empty_display_type'].enum_items.keys()
Please give this as an answer, so that I can give you the score as a valid answer, as you have found the answer to my question.


text:
Local rotation with array and curve modifiers
Is it possible to get local rotations on objects generated with an array modifier that are deforming to a curve?
A picture will work better:

I'm trying to avoid having the "seams" line up for each array object. A random rotation would be ideal, but even a constant offset would do.
I've tried using an object offset in the array modifier, but that interacts poorly with the curve modifier.
Here's how I have the modifiers set up:

Will you move them along the path? Also, do the cylinders need to deform?

Can you post the blend file?

Related: https://blender.stackexchange.com/questions/102944/assign-a-custom-orientation-to-each-instance-of-a-dupli-object : it's a quesiton of mine that hasn't been answered, but I've received some useful comments (about using particle systems) that I've incorporated in the question and might represent an interesting approach to this problem.

In Array Modifier Use Empty as Object Offset. Make sure your objects are located in the center of the 3D space (0,0,0)
Turn off Relative Offset and move the Empty along the Z axis.
To rotate the copies simply rotate the Empty around Z axis.

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


text:
Better quality blur in the compositor
I'm trying to get rid of an artifact in my compositor setup:

I get these rings:

Is this a range problem with the information coming out of the nodes? Or is it a limitation in the image type/display?

Have the same problem with the smoothness of colors transition after rendering the gradient texture. Thanks for asking this question :).

I suspect it's a limitation with the number of colours the output image can represent; I tried running the output of the ColourRamp (shown here) through an additional blur which didn't fix it :/

related: http://video.stackexchange.com/a/14570/6685

Note that this is a blurred ellipse mask in the compositor, not a render.

It is a limitation of the color depth. Gradients appear "stepped" when they are spread out over large areas and there is not enough bit depth to accurately represent the gradient transition. The first step (no pun intended) would be switching your color depth from 8 to 16 in your render settings. Also follow the advice in the comments others have posted above - basically saying the same thing in a different way, whether you call it "color banding" or "gradient stepping".


text:
Smooth vertices with snapping
I'm trying my first ever retopology of a high-poly triangle mesh to a low-poly quad mesh. I'm using a combination of of Bsurfaces and snap-to-face on my target mesh:

As a tidying step, I'd like to smooth the vertices of my new low-poly mesh. The "Smooth Vertex" tool doesn't honor the snap-to-face setting, so gives results like this:

Is there a tool that can smooth vertices, while staying snapped to the source mesh?

Maybe try Smooth modifier followed by one more Shrinkwrap modfier with a bit modified settings (so it doesn't get rid of all results of smoothing). But I'd say it's something to choose between - either create roughly original low poly mesh and keep the low poly count, or recreate it with smoothed surfaces (and more polys).

It would be easier for You to use Shrinkwrap modifier on the lower poly mesh and make high poly mesh its target. This way no matter what you do, vertices will stick to high poly mesh surface. I usually also check "keep above the surface" option and make Offset something higher then 0, but it's not crucial.


text:
What do the sampler numbers at the bottom of the image editor mean?

When in the Image Editor, left clicking on a pixel makes a small row of numbers appear at the bottom.
I know what some of these mean, but others are a mystery to me...

From left to right: X & Y are the coordinates you clicked on.
R, G, and B are the RGB values for that pixel.
A is Alpha.
These values are in Scene Referred values in a infinite linear scale,
The numbers after "CM" are the Color-Managed values.  Based on how you have set the Color Management section of your scene, it's telling you what the effective colors will be after applying the settings.
R, G, and B are adjusted for your color management, and the little square next to them is showing a visual representation of the adjusted color.
Then H, S, and V are Hue, Saturation, and Value, which is simply a different way of representing the R, G, B values.
HSV is closer to how humans perceive color, whereas RGB is based on colors of light, so some people prefer to work in that color space.
The L is Luma, which is a gamma-corrected sum of R, G, and B.  Basically if you converted a color to grayscale, how bright it would be.
Since yours already is grayscale, the L value is the same as the RGB and V values.
Here's way too much detail: https://en.wikipedia.org/wiki/HSL_and_HSV
The RGB on the left are "scene-referred" values, meaning they are the actual values in the scene.
Only formats such as .hdr or .exr can hold this kind of information.
If you were to display this information without a color transform by the color management, the colors would look wrong, too dark and contrasty, and all values beyond 1 would be ignored or clipped in the standard sRGB display transform (the clip point is at 16.19 when using filmic).
The numbers to the right of the "CM" indicator are "display-referred" values, meaning they are adjusted to show on a monitor based on your CM settings.
These are my scene settings, for example. If you change them you'll see the "CM" numbers will be different.

If you're not familiar with color management, I suggest watching this video: https://www.blenderguru.com/tutorials/secret-ingredient-photorealism
Read also:
Render with a wider dynamic range in cycles to produce photorealistic looking images

I'm afraid this only answers a very small portion of my question. Could you please edit to elaborate?

added more detail; let me know if that helps or if you need more info on any of it!

R, G and B are the scene referred pixel values. Scene referred values have no maximum, and are not some sort of representation of a 0-255 range. They can be infinitely high. The CM values are the resulting values after Look and View Transform, both found in the Color Management section, are applied. The CM values have to be within a 0-1 range, and are sent like this to your monitor.

ah yes, you are correct.  I wasn't thinking of images like .hdr or .exr that can have a large range of values.  I'll edit my answer.

Better, but please note that there are no conversions of 0 - 255 range happening anywhere. That terminology comes from Applications like Photoshop, which made that choice rather from a UI perspective, not from the data which was meant to be represented. In Blender we are dealing with a rendering context. Rendering is theoretically unlimited in terms of R,G,B values it can produce (practically limited by hardware). I'm pointing this out because your answer refers to .hdr and .exr imagery, but does not mention the content of a renderlayer before it is saved to an image at all.

see https://blender.stackexchange.com/questions/46825/render-with-a-wider-dynamic-range-in-cycles-to-produce-photorealistic-looking-im for deeper information about scene referred and display referred RGB handling. The core principles are described there.

yes, rendering is theoretically unlimited.  However, for standard image formats, it's not a UI choice to display values as 0-255.  1 byte per channel is very common for PNG and JPG files (and on the web), and the data is stored that way in the file, so selecting a pixel on a JPG in the Blender UI it is converting that pixel data to a 0-1 range.  However, for a render you are correct that this isn't a valid statement.


text:
How to apply images from the compositor to a model?
I know I can edit photos in the compositor, but can I apply the result of my edit to my current model? For example, I used the compositor to edit the headlight of a car. Can I apply this edit of the headlight to my model? If so, how can I do it?

Yes. Load your image texture in the compositor, edit, and then save the result via Image Viewer and UV/Image Editor set to 'Image Viewer'. Load the saved image as a texture in the model's material and appropriate UV coordinates, etc. For now, there doesn't exist a definite link for live editing from the compositor to the material texture, but in the Cycles material node editor you CAN use color mix nodes and curve nodes, etc. to interactively edit some properties of the image texture.


text:
Animation Nodes. Rotate instanced objects in their individual rotation axis
I've been trying to make instanced objects in AN rotate in their individual rotation axis towards the direction of an Empty object. I can get them to rotate towards the correct general direction, but I haven't been able to make them "calculate" this rotation in an "individual" manner, if that makes sense. Here's an image that shows what I have so far and what I'm trying to achieve (the content within the pink bounds):

You need to get a one direction for each object:

Yes, I was trying to get this "unique" value for each instance of the object but I couldn't sucessfully replicate your node tree... Did you test it against an object like the one on my screens? Many thanks though! Also, I've found a very simple solution by adding a "Track to" constraint to the object XD So I'm using AN now, only to replicate the objects...

Yes used Suzanne to test it. Depending on the configuration, may need to change the axis for "direction to rotation". In the screen capture above, did not take care of it. But should be Y and Z.

I've found a rather simple way, using a blender's "constraint" on my objects. All I've done was added the "Track to" contraint to the object, tracking it to the empty. I've made sure AN copied the contrained by checking all boxes on the instancer node... Here's the result:


text:
Linking an object to a flying camera
I want to link one of the objects in my scene to be linked with a flying camera and render it. I am looking for a simplified Call of Duty style, which can be watched in the youtube video here, where the gun or other tools can always be seen in the hand of the player.
My scene includes a large cave and I want to attach a stick to a flying camera inside the cave so that when I move the camera I can always see a small tip of the stick oriented with a fixed angle with respect to the camera in the rendered video. I want to fly the camera to look at the top, bottom, and side walls of the cave while walking towards the end of the cave. I would be grateful for any tip.

You can read about parenting right here ... http://blender.stackexchange.com/questions/26108/how-do-i-parent-objects ... it's highly recommended that you do a search before posting a question.

@hawkenfox, thank you, I did a search using keywords linking objects and camera but I did not know about parenting, which seems like a great idea. Thank you.

No problem then, cheers.


text:
Selecting the other side of the object in a boolean operation
I am trying to cut an object using a plane into two objects. I am using difference boolean modifier. How can I tell Blender which part I want and which part I don't want? I have no control on which part should remain after the boolean operation. Could someone help me on this?
Update: (for better illustration of the question). For example, let's say we have a cube which is cut by a plane. How can I selectively specify which part of the following cube should be removed after the boolean operation on the cube and the plane? For example, how can I remove part (1) of the cube instead of part (2)? I am trying to be able to tell Blender remove the part which I don't want.
I should say that the boolean modifier works perfectly with the plane being the cutter my object is splitted into a correct mesh. I would like to only be able to remove the other remaining object.

When you are using Difference the other object is 'subtracted' from the one with the modifier. To get the other side you have to set the modifier to Intersect. This is the part where both objects overlap. The third option, Union would give you the boolean 'sum' of both objects.
In the image below the monkey head has the boolean modifier, the other object in the modifier is the cube.

BTW: notice the eye missing in the intersection case? The boolean modifier works on the object's volumes, but the monkey head is not a closed mesh, so the volume is not really defined. This may cause problems in some cases, so be aware of that.
EDIT: And as @stacker mentioned in the comments, since the boolean modifier works on the volume of the objects it might not work properly with a plane, at least when the edge of the plane is inside the volume of the other object.
UPDATE
There is no way to tell blender that it should take the other side of the object when using the boolean modifier set to Difference, since this is just the way the difference of two sets is defined: The difference of the sets A and B A\B are all points in A that are not in B. What points are in B is defined by the normal of your cutting plane; The normal points to the outside.
If you want the other half of the cube you have to flip the normal of the plane or set the boolean modifier to Intersect. The intersection of two sets A and B A^B is all points in A that are also in B. This is exactly the opposite of the difference.

You could add that this is performed using a cube and won't work with plane.

@maddin45: I have updated my question for better illustration.

@Ahm I've updated my answer accordingly. I hope this clears things up.


text:
"Joining" points in one mesh
Given: a mesh which forms one-n'th of a torus. I Alt-D-duplicate it, rotate the copy by 360°/n, and get the ends to meet up. Repeat n-1 times.
I have now a nicely symmetric object which I can edit further. This is not the problem.
The problem is that when I move a vertex at the border between copies, that nice alignment is destroyed. Obviously I cannot join the corresponding vertices; it's the same underlying mesh, after all..
Thus, how can I keep them in sync while editing? Repeating the edit steps on the "other" side is tedious, and snap-to-vertex doesn't help much either.
To clarify: I want to create a closed object with n-fold symmetry which stays closed and symmetric, no matter which vertex/edge/face I move. A normal torus will not stay symmetric. A 1/nth-torus with n-1 360°/n-rotated copies will not stay closed when I move a vertex/edge/face at the border.

One point to note is that the term for a point in Blender is called a "vertex", not "vortex".

I think you should be using the "screw" modifier for this.

Are you simply talking about removing overlapping vertices? if so, A to select all vertices, then W > Removing Doubles.

You could merge the vertices by invoking the Remove Doubles operator

In your case you could create the torus without duplicated vertices, starting with an e.g. an 1/8th

By rotating using the
Spin Tool Alt-R in Edit Mode

Alt-R does not seem to do anything in my version of Blender. In any case, did you actually try moving e.g. the top-most vertex after this? Did that action leave a hole in the torus?

@MatthiasUrlichs You need to be in Edit Mode, and yes you won't have duplicated vertices with the settings used in the image.

I don't completely understand the problem you are encountering, but here are a few things you might try:

While in Edit mode, before you start modeling (such as duplicating your torus sections) turn on "Automatically merge vertices moved to the same location":

This makes sure you won't have double, non-merged vertices in the same spot, thus you won't have to use Remove Doubles later on.
When you use ALTD to duplicate the torus section, you are creating what is called a Linked Duplicate. With Linked Duplicates, whenever you modify the section, ALL of the sections will be effected, as shown here:

However, if you don't want this to happen, use SHIFTD to create non-linked Duplicates. With these kinds of Duplicates, when you edit one, the others remain unedited, as shown here:

If you want to learn more about the differences between Duplicates and Linked Duplicates, you can read more about them here:  http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Objects/Duplication

Thanks, but I do know the difference between a duplicate and a linked duplicate. The point is that auto-merging vertices does not work for linked duplicates. In your first linked-duplicate example, you moved a random vertex on the surface of the quarter-torus. That obviously works. However, moving a vertex on the very top (or left etc.), where the duplicates join will leave a hole.

Try using an Array modifier:

Add a torus and delete three quarters of it:

Add an empty and rotate it 90° around the Z (or whatever axis to which the torus is aligned)

Add an array modifier to the torus, with Object offset enabled and the empty selected as the offset object:

By using the 3D cursor as the pivot point and being suitably careful about how you move your vertices maintaining a manifold mesh shouldn't be too hard. Another advantage to the array modifier is that it updates in edit mode.


text:
How can I rotate/twist a torus about its major circle?
The problem: I am building a torus with an intricate regular pattern that includes a twist.
A simple example:
http://netz.smurf.noris.de/blender2.png
I have built one torus segment – my "real" example is obviously a lot more intricate, not just a simple inset operation.
Now I want to transform the left segment into the right one. The end goal is to do that six times so that, in this example, I get a torus with a doubly-winded spiral around it.

Do you mean you have a cylinder and want to bend it in order to make from it a part of torus ? It's easier to do if original cylinder isn't rotated / twisted.

No, I already have a sixth of a torus. If there's a way to straighten the thing that doesn't involve moving a whole lot of vertices manually …?

I think you really need to find a picture to show us the end result of your model. Your description is lacking, I am afraid it's very difficult to understand what you are looking for.

I have changed the image and extended the description.

As far as I know, there is no easy way to rotate about a curved axis.  Your best bet would be to model the segments straight, use an array modifier, then bend them.
First model a straight segment of the object.

Next add an Empty to the scene and position it at the end of the segment.  Then add an Array modifier to the segment, and uncheck Constant Offset and Relative Offset and enable Object Offset, selecting the empty as the offset object.
The Array modifier works by duplicating the geometry of the mesh and placing it at the position of the offset object, further parts of the array copy this relative transformation.

Now add a Simple Deform modifier to the object and set it to Bend with an angle of 360°.  You will probably also have to add another empty and use it as the Simple Deform origin so you can rotate the axis being bent around.

You can adjust the diameter of the torus by increasing the Array count.  Note that since my example model is 90°, I need to use multiples of 4 for the array modifier so that the teeth line up at the seam.

Thanks for the elaborate answer. This does seem to mean that I need to re-do my design on a cylinder. Any good ideas how to straighten the torus segment out? A "wobbly" result would work for me.

@MatthiasUrlichs  You could add a Simple Deform modifier (set to bend) to bend it straight.  You would need to do some math to figure out the exact bend angle.

Draw the Desired Profile
Add the Screw Modifier - For the Screw Amount, be sure to calculate the Circumference / Arc Length.
Add a Bezier Circle / Arc
Apply the Screw Modifier, rotate about the Center of Screw Object to lay parallel to the Bezier Circle, Then position the Screw Origin to the Bezier Circle's Origin.
Add the Curve Modifier to the Screw Object, and for the reference object, select the Bezier Circle.

Umm, no. I don't want to rotate around Z (I know how to do that …), I want to rotate/twist around the major circumference of the torus this is a part of.

OK, I will revise my answer to suit your needs.

One more thing, to control the resolution change the 'Steps' value.

This doesn't answer the question, the OP is starting with a 3d object that is a curved cylinder. This doesn't address that anywhere.

@dval - Read the question again... "The problem: I am building a torus...". What part of "I am building" says that the OP is starting with the 3D object 1st?

If you are referring to the comments below that, fine use what you already have as a reference. When I offer a solution (especially if it is better, than a path already traveled), then it's up to the OP to make that decision to backtrack or not. Either way this does address the question as stated.

@RickRiggs, a yes, I was looking at the final question, I didn't realize your answer was posted before the edit. sorry. removed downvote. (update< I will removed downvote if the answer is edited. I gues add space and save it or something?)

Modelling

A cylinder plain or elaborate can be made first, then add a [Curve Modifier]. Cylinder first, then curve it.

Above Example 1

Above Example 2

Hmm. I have updated my question; could you elaborate? I don't quite see how a twirly knotted torus can transform my torus segment into something that's twisted but not knotted.


text:
Stretching + array with object offset = bug?
I created a torus, stretched it (X=1.3), and added an Array modifier (n=5) with an Object Offset (an Empty that does nothing).
The effect is that the stretch is applied to the original copy. it's undone in the second copy and later copies are subsequently narrower. Needless to say this is not what I intend to do. To "fix" this I need to set the stretch values of the Empty to those of the torus.
Why is that necessary? doesn't make sense to me and smells like a bug, as I'd expect that adding a "no-op" Empty to an Array should not affect the result.

Hello could you please share your file?

Apply the scale (Ctrl-A) to the torus.

@JohnEason Well that obviously fixes the immediate problem, but that doesn't tell me why adding an Empty which does nothing results in scaling things down.

@moonboots attached

The empty does not do nothing, whether the difference in transform comes from the arrayed object or the empty, there is still a relative difference between the two. If you want the empty to do nothing, set its X scale to 1.3

This is how Array Modifier is supposed to work. There is no bug or error. This is intended functionality and it should be like this. An array in object offset mode takes the transforms of the offset object and repeats them. Those are translation, rotation and scale. If the translation/location, rotation or scale values are different in the object repeated and the offset object, the difference is repeated in the array.
You have to apply the scale of your object with ctrl+a, or match the offset object's scale so there is no difference in them if you do not want to repeat that difference across your array. That's the whole point of object offset mode in array modifier - you can change not only location, but rotation and scale in arrays with it.


text:
BGE glsl setUniform problem
In Blender 2.69 and 2.70 I tried to make a simple GLSL shader that has one uniform value. However, it seems like the uniform value isn't applied correctly. The scene is showing a black cube. How can I fix it?
import bge

cont = bge.logic.getCurrentController()

vs = '''
    void main() {
        gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    }
'''

fs = '''
    uniform float c;
    void main() {
        gl_FragColor = vec4(c, c, c, 1.0);
    }
'''

mesh = cont.owner.meshes[0]
for mat in mesh.materials:
    shader = mat.getShader()
    shader.setSource(vs, fs, 0)
    shader.setUniform1f('c', 0.5)

i partly figured it out myself.
if i play the scene in the stand alone player.
the uniform value is applied correctly.
i don't know why the viewport mode bge player doesn't work correctly.

The problem is the last argument of setSource, which isn´t documented. Looking at the blender source code this argument is named "apply" and expects a boolean.
So:
shader.setSource(vs, fs, True)

should fix the problem. Note, that you should also switch to textured view mode.


text:
Armature Deformations different while rendering
I have a character rigged, and the character is in a scene.  I pose the armature in the view port in solid view. I check it in rendered view in cycles. Everything is good, the character is sitting on a couch. Everything seems good.
When I render an image, however, the rotations are exagerated, and the legs are bent up to the characters chin (nearly 180 degrees) when they appeared at about 90 degrees in preview.

Try pressing 'i' with the armature selected, and then select 'Visual LocRotScale'a from the menu. Do this for the armature and the pig, should fix your issue.

There are no keyframes to begin with.  Doing this for the armature does nothing.  Doing it on the pig's mesh makes the pig's mesh jump away from the armature....  Which I didn't expect, but I suppose makes sense.   Long story short, that isn't it, unless I'm missing something.

Can you share your blend so someone can see what is happening? blend-exchange.giantcowfilms.com is the preferred method, then add the link to your question.


text:
Creating a flowing effect with Cycles noise
I've got a Cycles noise node and would like to give it a flowing effect.
This is kind of what I mean:

I achieved this by sliding the noise distortion back and forth. The problem is that the result looks like it's moving forward, then rewinding; I'd like something that appears to continuously flow.
I can imagine that some clever texture coordinate mapping could do this. Or maybe something else?

Slide it back and forth works with most ladies but here try to only slide forward (with a driver for example) - it's procedural. That will be a continuous flow. You can also alter the Z mapping axis making a cloud-like effect, where it changes but does not move. You can combine this.

Can't really keep sliding the distortion forward, because eventually it gets too high and looks much different. Changing the z mapping wouldn't work if this was rendered on a sphere, would it?

For a sphere you need spherical mapping to make the Z be aligned with sphere normals: http://blender.stackexchange.com/a/45169/7777 and a Z-offsetting will work. If that will work for you I can write it as an answer.

Yeah, I think that'll work as long as you include the sphere mapping bit

Ahh yes cegaton's link hit the nail on the head


text:
How do you set the start/end handles of a curve?
I have a curve that isn't a closed loop.

Is it possible to change the start/end handles so the gap is in a different place?


text:
How to set visible render layers with Python?
How can I set my scene's visible layers from Python? I'd like to make layers 0 and 4 visible. Here's what I've tried:
for i in range(20):
    bpy.context.scene.layers[i] = False

bpy.context.scene.layers[0] = True
bpy.context.scene.layers[4] = True

Please [edit] your question to include an explanation of what result this current code is producing and, if necessary, why this result isn't what you want.

I couldn't identify a reproducible pattern in my code, but Haunt_House has it figured out in his answer

Took me a while as well, but once I saw that always the last visible layer remained, it was easy. How about you put the improved code as an edit in your question? My code might be ugly and too long, but it is readable.

I'd do it like this:  visible=[0,4];  for i in range(20): bpy.context.scene.layers[i] = i in visible

Try it with visible = [3,4] and only layer 0 turned on.. It'll still keep layer 0. It'll work if layer 0 is always the one to be switched on.

Ohh of course (duh)!

My code may be awful (abeit easily readable), but I think the problem you have is this: it's impossible to turn all layers off. One must be turned on, so a loop to disable them all doesn't work. It seems that Blender is checking anytime you try to disable a layer whether it's the last man standing.
I simply turned it around by first switching the desired layers on and then disabling all others.
import bpy

visible = [0,4]
for b in visible:
    bpy.context.scene.layers[b] = 1

a  = 0
while a < 20:
    if a not in visible:
        bpy.context.scene.layers[a]= 0
    a += 1

edit: batFINGER reduced it to two lines, so give his comment an upvote (:
import bpy

visible = [3,6,9]
scene.layers = [l in visible for l in range(20)]

Creating the full list before assigning it is a smart move.

scene.layers = [l in visible for l in range(20)]  as long as visible has one valid index.  Else does nothing.

@batFINGER Now that's good code. Eight lines reduced to 2 ( :

@batFINGER What makes me wonder a bit is that at least superficially 'l' gets used before being defined and it still works. Seems like I need more books.

Yep, python list comprehension is a bit tricky at first.

@Haunt_House I want to do rendering from specific layers and import an object into another layer simultaneously. Do you know how to do that possibly? If so, could you please take a look at my question here and see if you can offer a solution?

@Amir I already had a look at your question. But It's not my specialty. Answering python questions is rare for me. Just look at how much better samblers answer is.

The layers visibility (for both object and scene) is a list of boolean values, you can generate a list of bools by multiplying a single bool array -
bpy.context.scene.layers = [True]+[False]*2+[True]+[False]*16

You just need to make sure the length of the list is 20.
You can also use list comprehension -
bpy.context.scene.layers = [x in [0,4] for x in range(20)]

I want to do rendering from specific layers and import an object into another layer simultaneously. Do you know how to do that possibly? If so, could you please take a look at my question here and see if you can offer a solution?


text:
Baking metaball solver
I'm animating a particle system of metaballs, and finding that the scene takes a long time to initialize before it can even start rendering. I'm finding it annoying as I work on materials, since there's a lot of recalculating the same metalballs.
Is it possible to bake complicated metaball calculations?

In object data tab try to change the render resolution to higher value.

I've lowered it way down on purpose though. When it's high, I lose too much geometry to the point where the object is unrecognisable.

Turns out rendering in the viewport does the trick (not sure why hitting F-12 forces a bunch of refreshing though..)

Rendering in the viewport is fine for playing with material at a single frame. My material is animated, so I really need to step through the timeline to get a feel for how it looks.


text:
How to deal with a scene that has both very large and very small objects
I'd like to make an animation of some objects moving around on flat plane which stretches to the horizon:

Then I'd like to move the camera waaaayyyy into the sky and show that the ground is actually a text object. I'm finding the difference in scales really tough to work on in a single scene (e.g. clipping is driving me nuts).
Is it possible to do the described shot in a single scene? Or am I better off splitting it into two scenes and somehow stitch the animation back together in the video sequence editor?

I've decided to go for two separate scenes. Merging them might be OK for this case, but I can certainly imagine wanting continuous scale variation at some point (e.g. microscopic, zoom out to the microscope, soom out over the building, zoom out over the planet, zoom out over the galaxy...)

Why not drive the scale of the objects as an inverse function to the distance of the camera? That way the camera doesn't have to move as far while the objects take up less room.
You can add drivers to the objects that you want scaled. They should take the local location of the camera and divide it into 1. Resulting in a smaller value for the scene.
In fact if there are many objects then i would parent them to an empty and simply drive it's scale.
Here are the drivers with the function attached:

Remember to copy this driver to each channel for uniform scaling.
finally remember that any materials that exist in world space will not scale with the UVs of the objects.

That's pretty ingenious. But, so that every one reading can understand your suggestion, you should expand your post to contain how.

Please do. Scale is a bugaboo in many instances. Knowing how to "drive the scale of the objects...camera" would be very helpful.

Sadly all I seem to achieve is inverting the child objects. Unfortunately I just don't know how to return a normalised rational number, as multiplying by -1 is just an inverse function. There just doesn't seem to be an Modify Transform via constraints or driver. Although a driver might achieve it. I tried to use bones driven from camera location. Failing that you could just do it manually.


text:
Where are PyNode socket values stored?
I'm having trouble wrapping my head around how information flows through PyNodes.. Where/how should I set the value of my node's output sockets?
I've been trying to implement this in my node's update method. My idea is that I should be able to access the value of the input sockets, do something with the values, then set the value of the output sockets. My problem is that it doesn't appear that the NodeSocket class actually stores values anywhere.

How can I access the value in my node's input sockets?
Where should I implement the actual processing that my node should be responsible for?
How can I set the value of my node's output sockets?

check this example http://blenderartists.org/forum/showthread.php?331299-Cycles-Custom-Float-Node&p=2606082&viewfull=1#post2606082

related: http://blender.stackexchange.com/questions/23430/cycles-pynode-which-outputs-objects-properties, Jacques Lucke says: For now pynodes aren't ment to work in cycles/compositor/.. They are visually there but won't do anything. I think the script by Atom only works because it is such a simple node that does in fact nothing. Might be better to extend Animation Nodes for your needs.

Similar to what I came up with here

@poor I should be able to make nodes do actual work, as long as they live in a custom node tree type, right? What I think I'm trying to head towards is wrapping some/all of the scipy.ndimage methods, along with some input/output nodes for reading/writing numpy arrays from/to various filetypes.

My experience in this is very limited..., but maybe this: http://blender.stackexchange.com/questions/23465/how-to-add-backdrop-images-for-py-nodes/30743#30743 could be interesting in your case.


text:
Particle System Slot vs Settings
Why is the name of a particle system slot different from the name of the particle system settings it contains?

This is not the same as material slots, where the slot and the material share a name.

Its like object and mesh relation, you can switch different settings on the particle system like you can change mesh on the object or switch texture on material.

@Denis, mind writing that as an answer? or can I?

even the material slot and the material have different names ( and they have the same relation as this )

@Chebhou, If you change the name of the slot, the name of the material changes with it (and vice versa)

@ajwood my mistake; I thought they don't

Could whoever writes that out as an answer explain why the particle-slot/-settings and object/mesh relationship is different from the material-slot/material?

@ajwood the material slot has different structure because you can apply multiple materials to objects unlike object/mesh

actually the material slot has a separate name but it is read only and set by blender to match the material name so basically it's the same

@Denis You can assign multiple particle systems to an object in the same was you can apply multiple materials, no?

@ajwood you are right, Chebhou gave correct explanation about material slots.

Particle System name is different from Particle Settings name because you can have Multiple setting for each Particle System. By creating multiple settings you can quickly switch between them to see the difference instead of replacing the Particle System.


text:
How to render only shadow instead of an object?
In Blender internal render, that has been deprecated, there was an option for material to render only shadow that is cast on an object, not the object itself. Is there a way to do the same in the Eeevee render in Blender 2.9x ?
EDIT: In cycles, there is an option "Shadow catcher" under the object's visibility settings. What I would like is similar option or solution in Eevee.

You should change your question, because like this you are asking two totally different things. Or you should delete your EDIT part. Or delete all this question and ask a new one focused on your part in EDIT. Like now it is messy. Thank you

Eevee
Render Only Shadow instead of Object

In Principle BSDF set Alpha zero
and under Material Properties > Settings > Blend Mode > Alpha Clip

Reaction on your EDIT:
Shadow Catcher

Shader to RGB with some tweaking in Color Ramp
and under Material Properties > Settings > Blend Mode > Alpha Blend

almost looks like you have an AMD gpu issue, lol.

...and shadow mode: opaque, else it won't work


text:
Offset an animation fcurve in python?
I want to offset an entire range of keyframes (all) in an individual animation fcurve using python.  Is there an operator or function that will do this without needing to iterate through the keyframes individually - basically like performing a move command in the graph editor (G Y, 10)?   More specifically, I would like to apply an object's Delta Transforms into its current animation in a python script.

In response to your comment to your question, here's an example, using an operator override, to move every fcurve 3 units on the X axis:
def get_override(area_type, region_type):
    for area in bpy.context.screen.areas:
        if area.type == area_type:
            for region in area.regions:
                if region.type == region_type:
                    override = {'area': area, 'region': region}
                    return override
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "\n Make sure it's open while executing script.")

override = get_override( 'GRAPH_EDITOR', 'WINDOW' )

bpy.ops.graph.select_all(override)
bpy.ops.transform.translate(override, value=(3, 0, 0))

What you need to do is replace the select_all call with code that selects only the F-Curve you want to modify, as the transform op operates on all selected curves.
This will only work if you do have a graph editor window open.
Here is the manual entry with details on overriding context if you need more information.
3.2 Update
Context overrides are deprecated in Blender 3.2 and are scheduled to be removed in Blender 3.3  The replacement is temp_override. The manual has examples of how to use the new function.

Thanks much.   That looks like it would do what I want.   The catch is keeping the Graph Editor panel open.

If you want to use bpy.ops 99% of the time you have to have an appropriate editor open, alas.

Move All keyframe_points for a object
import bpy

def move_kp(obj, dx):
    anim_data           = obj.animation_data
    if not anim_data:   return

    action              = anim_data.action
    if not action:      return

    for fc in action.fcurves:
        for kp in fc.keyframe_points:
            kp.co[0]            += dx
            kp.handle_left[0]   += dx
            kp.handle_right[0]  += dx

move_kp(bpy.context.object, 10)

There have a api function to move keypoint
But only work on special cases
bpy.ops.transform.translate(value=(10, 0, 0), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, True, True), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)

Thanks for the method, which is basically iterating through individual keyframes.   I would prefer to use the transform ALL method, but I didn't know how to apply it to the graph editor instead of the object.   Maybe it is context sensitive like it is in the interface (which ever panel the mouse is over).  I need to figure out how to change the context to the graph editor, then isolate only a specific channel on which to apply the translate method.  I'm sure it can be done, I only have difficulty finding the proper commands in the API.


text:
Why are my donut sprinkles distorted?

I am following the Blender 3.0 Tutorial: Donut part 9/10.
I created a second mesh to practice on, but the sprinkles look kind of flattened. I don´t know why. I tweaked the Scale Settings in Instance on Points to get it right.
On my first try in the back you can see that the sprinkles barely touch the icing.

Is the donut also distorted? As in did you make a square donut? Or is the original a circle?

The original is a circle (in the background). The other one is square on intention.

Try applying scale on your sprinkles.
Select the sprinkle objects and press Ctrl+A > Apply Scale. If it made a change, then you'll have to tweak the scale values in the Geometry Nodes tab to get it right.
If it didn't solve the problem, it's probably because you have weight painted on the down side of the icing.


text:
Armature becomes deformed when exported from Blender into gltf format
Context
I'm currently trying to create a hand model with an armature for use within a game. Something I'm doing is leading to the armature becoming corrupted when exporting to glb format.
To try to eliminate sources for my mistakes I tried experimenting with a known good model. If that known good model is directly loaded into my application it looks correct and deforms correctly with the armature.

If I import* that glb into blender it again looks correct

But if I then export** that model back to gltf (.glb) format and load that into my application the hand is badly corrupted

It's hard to see in a still image but it is still vaguely handlike with clear fingers. Just very badly deformed.
The exact same thing happens when I create a hand and armature from scratch in blender so I think it's going wrong in the export not the import.
If I turn off any armature control in the application the mesh appears correct (but obviously doesn't move). Equally when the armature control is turned on the hand sort of follows the movements requested (bending the index figure at the right time) but within a corrupted overall shape
Question
How should I export a mesh and armature into gltf format such that the armature behaves correctly.
Notes
I do have skinning turned on in the export

Going through the import and export seems to misalign the armature from the mesh in the loading application, despite looking correct in blender. Could there be some advanced way of providing an offset in gltf that isn't well supported? Interestingly turning off the Transform > +Y up option changes the way the mesh and armature are misaligned (90 degrees wrong -> 180 degrees wrong)

*Import is done with File > Import > GLTF 2.0
** Export is done with File > Export > GLTF 2.0

Does your second export work if you import it back into Blender? Does it work with https://gltf-viewer.donmccurdy.com/?

@scurest is still seems to work but it is "different". The bones have moved from the armature to the pose, I've added a screen shot to the question. It also opens in the viewer BUT shows an interesting warning "Node with a skinned mesh is not root. Parent transforms will not affect a skinned mesh.". Not sure if that's the problem, feels suspicious at least. I also get a second warning "Image contains unsupported features like non-default colorspace information, non-square pixels, or animation."

The bones moving to pose just means you're in Pose mode. If it works in both those don't you think the issue is with your application instead? If you still think there's a problem with export, suggest filing a bug. I don't think there's enough info here to debug.

@scurest Hmm, I'm beginning to think there may indeed be an issue with my application (or I think the library I'm using). Possibly that it supports some subset of GLTF but not the whole standard and in my "known good" example that feature isn't used and in what is exported from blender it is. Loading up the mesh and some debug points for the armature in my application shows the armature rotated away from the mesh in the exported case. Equally playing with the "+Y up option" export option changes the way its wrong, which further suggests not the full standard is supported


text:
Are Blender Cloth Physics Based on a Cloth Simulation Model?
What research is leveraged to implement Blender Cloth? I know of several cloth models - Geometric, Physical, Particle - as well as their authors - Provot, Baraff & Witkin - but I am not certain if Blender utilizes one or any of these.
For example, I am not sure what is actually changed when you decrease the Structural Stiffness value from 15 to 10, or even what a "Stiffness" of 1 unit actually means (mathematically or physically). This also applies for the physics and maths of "Quality" step sizes, "Structural" and "Bending" qualities, and the "Spring" variables under the Damping setting. This powerpoint has helped, as has this .pdf, but neither offers complete answers to my questions.

I think blender uses it's own proprietary cloth solver

You have multiple questions in this question. Each questions should focus on a single problem.

Sources are available here / here. For more serious information on the implementation you could try to contact the devs.

You're on the right track with Provot's Physically Based Cloth Model.

Good values to try out might be the following Mass/Structural/Bending values: Default (0.3,15,0.5); Heavier, Faster, Greater Force (1.0,15,0.5); Allows Stretching and Shearing (0.3,0.01,0.5); Doesn't Allow Bending (0.3,15,55)

Summary: Initially in 2004, Todd Koeckeritz leveraged Provot's Cloth Model (Deformation Constraints in a Mass-Spring Model to Describe Rigid Cloth Behavior); also, he leveraged simplified portions of Provot's Cloth Collision Model (Collision and self-collision handling in cloth model dedicated to design garments). Then in 2006, Daniel Genrich completed an implementation of Mezger's Cloth Collision Model (Improved Collision Detection and Response Techniques for Cloth Animation). Additionally, Todd Koeckeritz created a parameter named "Steps"/"Quality" to handle time steps. Finally in 2008, Daniel Genrich released Blender Cloth (according to BlenderNation.com).

Research Papers:
Todd Koeckeritz (Contributor of Blender Cloth) says in April 2006:

Provot was chosen when we started the project because I had the code written already from two years ago when I was working on cloth as a python module. So, we've started with that. However, the few semi-unique characteristics of the Provot paper referenced in the wiki page are being replaced now with a similar process from another paper. So, in some ways Provot is gone, or will be in the next release. However, the nice feature described by Provot in section 5 of his paper, deals with eliminating the super-elastic/rubbery effect that some cloth simulators exhibit. That was my reason for choosing the paper two+ years ago.

The initial checkin of Blender Cloth files for "trunk/blender/source/blender/makesdna/DNA_cloth_types.h" by Daniel Genrich (Contributor of Blender Cloth) reads in September 2007:
+/**
+* This struct contains all the global data required to run a simulation.
+* At the time of this writing, this structure contains data appropriate
+* to run a simulation as described in Deformation Constraints in a
+* Mass-Spring Model to Describe Rigid Cloth Behavior by Xavier Provot.
+*
+* I've tried to keep similar, if not exact names for the variables as
+* are presented in the paper.  Where I've changed the concept slightly,
+* as in stepsPerFrame comapred to the time step in the paper, I've used
+* variables with different names to minimize confusion.
+**/

Todd Koeckeritz talks about his implementation of Provot's Cloth Collision Model in April 2006:

What we have now is a partial implementation of one described by Provot in his paper "Collision and self collision handling in cloth model dedicated to design garments."  We may not implement all that is described in that paper, but we do need to get friction working properly and get it working properly with moving and/or deforming collision objects.  What we have now works fine for dropping pieces of cloth on cubes and such, but there's no sliding when there should be and it isn't working now with collision meshes being deformed by armatures and such.

Todd Koeckeritz talks about Daniel Genrich implementation of Mezger's Cloth Collision Model in March/April 2006:

Genscher is focusing on work on the k-dop collision system [...]
  The collision system we've implemented is described in papers by Metzger in 2002 and 2003 and is known as K-DOP BVH. From an end user standpoint, there isn't too much that needs to be understood about this implementation that is specific to the collision system. In most cases, you either want to spend CPU time computing collisions or you don't.

Todd Koeckeritz talks about Time Steps in April 2006:

There is one more important concept for an end user to understand and that is the one of how the simulation deals with time. It is impossible to model all the atoms or molecules in a piece of cloth and those objects with which it might collide as it would simply take too much time to compute the results, so we compromise by using the point masses and springs described above. There is a similar problem when it comes to dealing with time. While some parts of the cloth modifier attempt to deal with time in a continuous sense, other parts only compute the results at specific points in time. For example, think of dropping a ball on frame one and having it hit the ground on frame 21. If you only had results on frame 1 and frame 21, you'd have no idea on how the ball behaved between those frames. It might have been moving at a constant velocity or it might have been accelerated from rest by gravity or another force. On the other hand, if you had all the frames from 1 to 21, you could examine the position of the ball in each frame and then know much better how the ball moved during that time. With that new information, you can then better predict how the ball should move between frames 22 and 51. The cloth modifier has some similar problems, although we deal with them at the sub-frame level. To do this a parameter called Steps is provided. The higher the number of steps, the more time is spent computing a result, however that result should be more precise. The lowest setting for Steps is 1, meaning we'll run the simulation once per frame. This is the fastest way to get a result from the cloth modifier, however, the results might be less physically accurate than if you choose a larger number.

In April 2006, Todd Koeckeritz called it "Steps". Between September 2007 and January 2008,  Daniel Genrich renamed "Steps Per Frame" to "Quality". The following code diff of "/source/blender/src/buttons_object.c" represents these changes:
-               uiDefButS(block, NUM, B_DIFF, "Steps:",                    10,80,100,20, &sb->minloops,  1.00,  30000.0, 10, 0, "Solver steps/frame ");
-               uiDefButI(block, NUM, B_DIFF, "Steps per Frame:",          10,150,150,20, &clmd->sim_parms.stepsPerFrame, 1.0, 100.0, 5, 0, "Quality of the simulation (higher=better=slower)");
+               uiDefButI(block, NUM, B_CLOTH_RENEW, "Quality:",           10,150,150,20, &clmd->sim_parms->stepsPerFrame, 4.0, 100.0, 5, 0, "Quality of the simulation (higher=better=slower)");

Parameters:
The Blender Cloth Modifier is based on a Spring Network, according to Todd Koeckeritz in April 2006:

The spring network is built of three types of springs and the user is allowed to control the stiffness of the springs separately: (1) Structural Springs are built on the edges of the mesh. They provide the main structural integrity of the cloth. (2) Shear Springs are built on the diagonals of quad faces and provide some resistance to shearing forces in the cloth. (3) Flexion Springs are built similarly to the Structural Springs, but are built on top of two close to parallel Structural Springs. Flexion Springs provide resistance to folding, the stiffer they are, the more the cloth will attempt to retain its original shape. Think of them as starch for your collar.

The Blender Cloth Controls were more detailed in April 2006:

Collision : This toggles whether the object is a collision object.    Collision objects are not cloth objects, they only allow the cloth
  objects to react to them when they collide. To collide with a cloth
  object, this button should be toggled on and the object should share
  a layer with the cloth objects with which it should collide.
Bake Settings : This button switches the mode of the cloth modifier    panel to baking mode, allowing the user to bake the results.
  Simulation Type : Presently there is only one solver implemented, the
  Provot solver as described in his paper above. There are however 3
  forms of integration, Explicit Euler, Middle Point and Runge-Kutta.
Collision Type : This allows the user to specify what type of    collisions to process for the cloth object. Presently only the None
  and KDOP options are available.
Pinned Vertex Group : If a vertex group is chosen in this menu, those    vertices are not affected by the cloth modifier. They are
  pinned in    place.
Mass Scale Vertex Group : This vertex group allows the user to    multiply the point mass by the influence/weight a vertice has in the
  vertex group. Thus parts of the cloth can have different weights
  making part of it appear wet or heavier for other reasons.
Mass Vertex Group : This vertex group allows the user to directly    specify the weight of the vertices. The Scale parameter is used to
  adjust the results of this.
Scale : This allows the user to scale the results of applying a Mass    Vertex Group.
Gravity X, Y and Z : These provide an external force to the cloth.
Spring Stiffness : These three parameters control the Structural,    Shear and Flexion spring stiffness.
Damping Springs : This is the damping factor applied to motion    produced by the springs.
Damping Viscous : This damping factor is applied to all motion of the    cloth, higher values produce results like moving through water
  or    mud.
Damping Self Fr : This will be used as the damping factor for    friction caused by self collisions of the cloth.
Damping Friction : This damping factor is applied to the cloth    vertices that collide with collisoin objects.
Simulation Steps : This controls how many steps per frame are used in    the simulation. Higher values produce better results in general,
  but    take longer to compute.
Simulate Adjustments : Adjustments controls whether or not attempts    are made to keep the springs in the cloth from exceeding their
  original length multipled by Tc. When set to -1, the Structural
  springs get increasingly stiffer, up to 100 times stiffer, as the
  springs's length divided by its original length aproaches Tc. At 0
  (zero), not adjustments are made. At 1 (one) or greater, Provot's
  algorithm of adjusting the springs is done as many times as specified
  by this parameter.
Simulation Mass : This specifies the base mass of a vertice in a    cloth object. The final value of the mass for any given vertice can
  be influenced by the Mass Scale Vertex Group and/or the Maxx Vertex
  Group.
Simulation MinZ : Provides an artificial floor below which the cloth    vertices will not go.
Simulation Epsilon : This provides a buffer distance for collision    detection and response. In the current implementation, small values
  in the range of 0.001 to 0.005 generally work best, although in some
  cases larger values may be desired.
Simulatin Tc : This specifies the critical deformation length as a    ratio to the original spring length. This value has no effect if
  Adjustments are 0 (zero).
Simulation Spr Len : This allows the user to specify an artificially    large or small base spring length. When this value is
  1.0, the    simulation behaves normally. With values less than 1 (one), the    springs are treated as if they were shorter than they
  actually are    which can be useful to shrink clothing to fit tighter
  on a model ...    think spandex. If this value is greater than 1
  (one), it provides an    artificial force to expand the cloth object
  which can be useful to    give bounce to a skirt or dress.
Simulation Pre-roll : This provides some artificial frames prior to    the start of the animation to allow the cloth to find its resting
  position.
Simulation Col Loop : This is the maximum number of times per step    collisions will be tested. This parameter is likely to go away.

Daniel Genrich simplified the controls by May 2008:

StructStiff: Structural Stiffness also includes shear stiffness. Both    define the stiffness of the structure of the cloth. Lower
  values will    make the cloth look like elastic rubber.
BendStiff: Bending Stiffness describes how the cloth forms its    wrinkles. Higher values result in bigger but not necessarily more
  wrinkles.
Spring Damp: Specifies how much the amount of movement will be    lowered. This can prevent unwanted jiggling, and can result also in
  smoother animation.
Air Damp: How thick is the air? How much movement will it stop due to    its thickness? Practically speaking, you receive slower movement
  of    cloth with higher air damping. With air damping set to zero, you
  have    moon surface conditions.
Quality: More quality gives more stable cloth (less jiggling with    high BendStiff) and additionally you receive better collision
  responses.
Mass: More mass gives heavier cloth, with slightly more weight on the    border like normal cloth.
Gravity: X, Y and Z direction of the gravity you want to have working    on the cloth.
Min Distance: Defines the cloth thickness where the collision    response kicks in. It helps to keep a minimum distance between the
  Cloth and the colliding mesh. Just increase it if you encounter
  collision penetrations (This is only one of two available options
  to resolve that issue - you could also increase the Quality on the
  first Cloth panel).
Friction: Friction defines how good a cloth can slide over a    collision object. See this for how friction effects the cloth
  collisions.
Min Distance: Defines the cloth thickness where the selfcollision    response kicks in. It helps to keep a minimum distance between the
  Cloth.
Selfcoll Quality: This values helps you to resolve several layers of    selfcollisions. Be carefull: the Collision Quality has to be at
  least    as high as Selfcoll Quality to have it working!
StructStiff VGroup: Vertex Group to be used for Structural Stiffness    scaling.
BendStiff VGroup: Vertex Group to be used for Bending Stiffness    scaling.
StructStiff Max: Defines the Structural Stiffness maximum. The    structural stiffness gets scaled between this maximum (the red
  painted values on the vertex group) and the minimum StructStiff on
  the first Cloth panel (blue painted vertices on the vertex group). A
  linear interpolation function is used inbetween.
BendStiff Max: Defines the Bending Stiffness maximum. The bending    stiffness gets scaled between this maximum (the red painted values on
  the vertex group) and the minimum BendStiff on the first Cloth panel
  (blue painted vertices on the vertex group). A linear interpolation
  function is used inbetween.

As of today (April 2015), the controls for Blender have three damping forces (Spring, Velocity, Air). Provot's model explains these three damping forces as follows (respectively: Internal, Gravity, Viscous-Damping/Air):

The internal force is the resultant of the tensions of the springs
  linking P_ij to its neighbors. The external force is of various nature
  according to the kind of load to which we wish the model to be
  exposed. Omnipresent loads will be gravity, a viscous damping, and a
  viscous interaction with an air stream or wind. Let g be the
  acceleration of gravity, the weight of P_ij is given by F_g=mg. The
  viscous damping will be given by F_d=-C_dv where C_d is a damping
  coefficient and v is the velocity of point P_ij. The role of this
  damping is in fact to model in first approximation the dissipation of
  the mechanical energy of our model. It is introduced as an external
  force but could actually be considered as an internal force as well.
  Finally, a viscous fluid moving at a uniform velocity u exerts on the
  surface of a body moving at a velocity v a force F_v = C_v((n dot
  (u-v))n where n is the unit normal on the surface.

The controls today (April 2015) are very similar to the controls in May 2008. The full set of updated parameters can be found in the the current Blender Manual:
http://www.blender.org/manual/physics/cloth.html

There was a blog about development, it's gone but a copy can be located here
I believe the simulator is particle based, and you might be able to find a few details there.  However, the best approach would be the blender developers mailing list, or even browsing the source code.
Normally I think pointing someone at the source code is a very incomplete answer, but you mentioned you are using this for a lab.  So I'm assuming that you need a very detailed answer of how it is simulated.  Also keep in mind that Blender is an animation package.  It creates results that look good, not necessarily results that are physically accurate.


text:
Vertex Group Weight Influence
I'm having trouble with understanding vertex weight influence.
As you can see, I have the vertex group painted how I want it.
When binding the armature to the mesh, I used Armature Deform > With Empty Groups and assigned the vertices to the groups. Then I did the weight painting manually. A vertex with any weight, 0.000 - 1.000, is influenced 100%. I don't like this.

It seems the vertex weight is being disregarded. It seems that a vertex with any weight on it at all is 100% influenced. (note: adding a VertexWeight Mod didn't help).
Lind to .blend

Can you post the .blend somewhere so we can view it? I'm not sure what the issue is. Normally, the weight will work by default.

Will do. Link is added to the main question now.

Are the problematic vertices part of a single vertex groups only? AFAIK there need to be at least two assigned vertex groups, even if the weight is 0.0 for the other group.

I thought about that, And added another one opposite of it. No luck. Over in the right side there it shows six i think. They're all assigned

I personally would not have done it like that.
I'd rather separate each mechanical part in several objects and assign each bone to its solid part, except for pipes which require their own bones, with maybe a "spline IK" constraint...

The location that you have the issue is the barrier between what gets moved and what doesn't. The mesh faces in this section can easily get stretched too much with the motion of the attached pieces.
I would recommend using a curve object for the hose instead of a mesh. By giving the curve a full fill and a bevel depth and increasing the resolution you get a nice round hose.

To animate the hose you add a hook to one or more of the curve points. While in edit mode select one of the curve points and press CtrlH and select Hook to New Object. This will create an empty at the location of the curve point as well as add a hook constraint. in object mode when you move the empty the curve point will move with it.

The beauty of a curve in this scenario is it maintains the hose shape no matter how far you stretch the points from one another. Parenting the empty to your piston will keep the end of the hose in place.
while stretching the hose too far will create a noticeable distortion you may want to add more hooks to the next curve point and use a limit distance constraint so that the coiled hose picks up and follows the movement.

For the final animation you would want to animate some rotation on the empties to prevent kinks in the hose.
You can look at my simple example file here.

Yes! this will work brilliantly! Doesn't answer the question of the vertices. But sometimes its good to start somewhere completely different. I was using a curve with an array because I've only every used the bevel curve once and completely forgot about it :P This will be the answer i choose.


text:
Animating cape (Blender 2.79)
I am trying to do an animation that involves a cape. I decided I would try to use the cloth simulation but I ran into an issue. My normal method for animating with a character involves the character to be in one spot in one frame, and then the next frame they are in a different location. I decided to test this with the cloth simulation to see how it would react. Unfortunately, the jump makes the cape go crazy.

Here's a download for the file: http://pasteall.org/blend/index.php?id=52662
What I want is for the cape to stay roughly in the same position before the jump. What would be the best way to achieve this, or is there another way I could animate the cape?

Relevant: https://blender.stackexchange.com/questions/86393/why-is-my-cloth-simulation-jagged

Holy smoke! You need to slow down the jump a lot! If you make the cape a more solid material, and slow down the jump a lot (Maybe to 5 frames). Also, what would make a better simulation would be to make the cape facing the opposite direction of the jump. AKA, if you jump -5 on the x axis, set the cape to be pointing towards the positive side.

Is there any way to reset the cloth during your animation? Like having two different starting points.

You only need to re-bake the cloth to reset it with different settings.

But could I start a new simulation later in the animation?

I'm not entirely sure why you would want to do that, but yes, you can, and it's tricky.


text:
How do I create and set the depth of a cube in blender 2.80?
In edit mode I click on add cube, I click on the screen to set the location of the 3d cursor. Then I click and drag to create a rectangle shaped cube.
But how do I set the depth to be the same as one of the other sides ? Or how do I define the depth at all?
I am not seeing any properties relating to the size of the cube being created. The cube created for me is very thin rectangle like a plank of laminate flooring and I cant work out how to make it thicker and square like a wooden post.
Creating a square cube or post seems such a basic thing and yet it stumps me.

If you are using the Edit Mode "Add Cube" tool, you should get handles that you can use to modify your cube visually:
After creating the cube (by dragging the left mouse button), orbit around the cube by holding down the MMB middle mouse button, then just grab a face and pull it in the desired direction. I'm not aware of a way to use these handles with exact numbers.

However, if you want to create a new cube and set its dimensions, I suggest adding it in Object Mode with Add > Mesh > Cube. In the "number" panel (N) you will be able to set its dimensions precisely.

Thank you.I found that as well as addcube on the left hand menu there is also an add menu with a cube at the top of the pane in edit mode, though that only allows you to set 1 dimension, but it does create a cube ! So I think its is only the object mode version that lets you set all 3 dimensions explicitly. So from your answer and from what I have found using it, I think that the edit mode add cube tool in the left hand  tools panel cant  currently create a square cube !

Yes, that's what I meant. To be able to set dimensions precisely you should use Object Mode's number panel. With the cube tool in edit mode you can obtain any proportions, but only visually. Another thing I didn't mention is that in any mode you can add a unit cube (Add > Cube) then do Scale constrained to each axis separately, and type in the amount (e.g. "S", "X", "1.26", "Enter").  My suggestion is: never use the Edit Mode Cube tool (unless you need it to bridge pieces in an approximate way, or set a simulation domain, or something like that).