text:
Making the buttonpress F6 into a scripted button
In bpy how would I make a button of the F6 operation? That way I can have a button to call a panel. I would just add it to the top of my panel.

Do you want your button to show the operator properties dialog or do you want to show a floating panel that you have filled in?

If you mean the "redo last" operation, which I believe is the default key binding for this function, then you can use this: (note that    you'll have to include bl_info and register and unregister functions    as in the code snippet below )
import bpy

class redo_last_operator(bpy.types.Operator):
    bl_idname = "screen.redo_last_operator"
    bl_label = "redo last"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self,context):
        bpy.ops.screen.redo_last()
        return {'FINISHED'}

Please note that importing this as an add-on will only add the operator to Blender, not add a Button to any panel. You can do that yourself, however, by creating a panel for it or adding it to a Panel yourself. The following code will create a panel as well:
import bpy

bl_info = {
    "version": (1, 0),
    "blender": (2, 75, 0),
    "name": "Redo Last Operator",
    "description": """Creates an operator for the redo last menu""" ,
    "category": "File",
    "location": """""",
}

class redo_last_operator(bpy.types.Operator):
    # this class is meant only for destroying data blocks of a certain type, very powerful but very dangerous
    bl_idname = "screen.redo_last_operator"
    bl_label = "redo last"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self,context):
        bpy.ops.screen.redo_last()
        return {'FINISHED'}

class redo_last_operator_panel(bpy.types.Panel):
    bl_label="redo last"
    bl_idname="redo_last_operator"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_category='Addons'

    def draw(self,context):
        self.layout.operator(redo_last_operator.bl_idname)

def register():
    bpy.utils.register_class(redo_last_operator)
    bpy.utils.register_class(redo_last_operator_panel)

def unregister():
    bpy.utils.unregister_class(redo_last_operator)
    bpy.utils.unregister_class(redo_last_operator_panel)

if __name__ == "__main__":
    register()

If, on the other hand, you meant another operation, you can use the same code and still bind it to the button by replacing the code under execute().

The issue with your script is it just runs an infinite loop, your operator's execute() is simply calling itself. You would need to use a different bl_idname for your operator, or you can just use the existing operator in your panel. Also don't add questions to your answer, If you are unsure of the persons question ask for more detail in the comments before answering.

You're right that my script did run recursively, I changed my answer to reflect the fix.

well the thing is is that I have a library of operators that are being called but the panels have to come up with F6. Its there a way to call the options panel up automatically?

I don't fully understand which options panel you wish - I presume you're talking about the panel that appears when the "redo last" operator points to the creation of a new primitive or other type of parametric object? If so, you'll need to track down those specific operators, and call them within your own code. At least that's the only thing I can think of.

This does actually not call the redo.last interface. It seems to me as one cannot call it from inside a script. but a button can contain just operator("screen.redo_last").

There seem to be an issue with calling the bpy.ops.screen.redo_last inside a custom command.
But you can simply create a button and let the button call screen.redo_last directly.
import bpy

bl_info = {
    "version": (1, 0),
    "blender": (2, 75, 0),
    "name": "Redo Last Operator",
    "description": """Creates an operator for the redo last menu""" ,
    "category": "File",
    "location": """""",
}

class redo_last_operator_panel(bpy.types.Panel):
    bl_label="redo last"
    bl_idname="redo_last_operator"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_category='Addons'

    def draw(self,context):
        self.layout.operator("screen.redo_last")

def register():
    bpy.utils.register_class(redo_last_operator)
    bpy.utils.register_class(redo_last_operator_panel)

def unregister():
    bpy.utils.unregister_class(redo_last_operator)
    bpy.utils.unregister_class(redo_last_operator_panel)

if __name__ == "__main__":
    register()


text:
How do you link to documentation via an operator
So I have a series of operators I would like to link to documentation wherever I right click and choose online manual. How do I set up operators to link to them or configure it? Is there a way I can do it on the operators themselves?

In the file  2.77/scripts/startup/bl_operators/wm.py you will find all the wm.doc_* operators,
class WM_OT_doc_view_manual(Operator):
    """Load online manual"""
    bl_idname = "wm.doc_view_manual"
    bl_label = "View Manual"

    doc_id = doc_id
    ...

We can override this operator to call our own.  Here the doc_id is
import bpy
from bl_operators.wm import WM_OT_doc_view_manual, doc_id

class Overide_doc_view_manual(WM_OT_doc_view_manual):
    doc_id = doc_id
    def invoke(self, context, event):
        print("Invoke")
        return {'FINISHED'}

    def execute(self, context):
        print("Online manual", self.doc_id)
        return {'FINISHED'}

def execute(self, context):
    print("Called myClass")
    return {'FINISHED'}
# lazy register
bpy.utils.register_class(Overide_doc_view_manual)

what about adding this to custom operators on a per operator basis?

source: Stack Exchange

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

sort: votes


text:
Use Console Entries to Drive Class Presets
So above the ui in blender it shows a pulldown of all the operations performed while modelling. Is there any way to perform a bevel and then take the properties from the above bar and use that as a template for an operation.

The idea is to set up a bevel that can be repeated with the same parameters set by the user. Allowing equal bevelling. Maybe it would work better if there was a bevel that once done would set the preset for subsequent bevels.

Sure, you could copy that bpy.ops.mesh.bevel() line to the python console and execute it again. You would have to ensure that you're in edit mode with a mesh selected. You could also use a script to apply the bevel to multiple objects if you wanted. Let me know what you're looking for and I can try to narrow done the solution for you.

You can look at the context.window_manager.operators collection.  The property settings are in the properties collection.  items(...) returns a list of key, value pairs
setattr(op, key, value)
# a key value pair of ("width", 3)
#equivalent of
op.width = 3

Put this in a draw method and it will list all operators by name, and if it's a bevel op expand on the call method as seen in the INFO panel and list the key value pairs.
    box = layout.box()
    for o in context.window_manager.operators:
        row = box.row()
        row.label(text=o.name)
        if o.name == 'Bevel':
            bbox = box.box()
            row = bbox.row()
            row.label(text="bpy.ops.mesh.bevel(%s)" % ", "
                     .join(["%s=%s" % (k, str(v))
                            for k, v in o.properties.items()]))
            for k, v in o.properties.items():
                row = bbox.row()
                row.label(text="%s = %s" % (k, str(v)))

Here is a modal timer operator that captures the bevel operator properties once it becomes context.active_operator to do something while it is happening.
(Test Code)
Put your mesh into edit mode, then run the operator, the operator will cancel when the user leaves edit mode, this can be changed.
Whenever a bevel operator is used it saves the settings to a dictionary on the operator, and while a bevel operator is context.active_operator prints the settings to the system console.
import bpy

class ModalTimerOperator(bpy.types.Operator):
    """Operator which runs its self from a timer"""
    bl_idname = "wm.modal_timer_operator"
    bl_label = "Modal Timer Operator"

    _timer = None
    bevel_operators = {}

    def modal(self, context, event):
        if context.mode != 'EDIT_MESH':
            self.cancel(context)
            return {'CANCELLED'}

        if event.type == 'TIMER':

            op = context.active_operator
            if op is None:
                return {'PASS_THROUGH'}

            if op.name == 'CSharpen':
                op.bevelwidth += 0.01
                if not op.run_modal:
                    #cancelled from CSharpen Operator update prop
                    self.cancel(context)
                    return {'CANCELLED'}

            elif op.name == "Bevel": # op.rna_type.identifier == "MESH_OT_bevel":
                key = hash(op)
                # save the operator props in a dictionary
                print("BEVEL", len(self.bevel_operators))
                print("bpy.ops.mesh.bevel(%s)" % " ,".join(["%s=%s" % (k, str(v)) for k, v in op.properties.items()]))
                self.bevel_operators.setdefault(key,
                                     {k:v for k,v in op.properties.items()})

        return {'PASS_THROUGH'}

    def execute(self, context):
        wm = context.window_manager
        self._timer = wm.event_timer_add(0.1, context.window)
        wm.modal_handler_add(self)
        return {'RUNNING_MODAL'}

    def cancel(self, context):
        print("Operator Cancelled")
        wm = context.window_manager
        wm.event_timer_remove(self._timer)
        # perform pre cancel here
        # print out the bevel operator dic

        for h, bo in self.bevel_operators.items():
            print(h, bo)

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

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

if __name__ == "__main__":
    register()

    # test call
    bpy.ops.wm.modal_timer_operator()

from code I set up from another answer to you where this operator talks to that operator "Csharpen"

I'll post the full code on BA that "talks" to Csharpen registerred op.

how about not having it connected to csharpen. I dont think the operator csharpen was supposed to have values piped into it. I meant more like a macro recorder for bevel that would allow it to be re-ran with the same values. Csharpen ideally was just supposed to collapse selected modifiers and run the sharpening operation and bevel it via modifier.

Then remove the   'if  op.name == 'CSharpen':` conditional block.  The code is in way of suggestion.  And yeah the modal timer is prob a bit OTT on one hand, ..

So what about the op being Bevel? So there isnt a way to retrieve the last operator of bevel in that area where it shows stuff like a callback or something?

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


text:
Scripting Reverse Boolean
So how would I script something that basically duplicated an object and took the last boolean modifier and reversed it while keeping the original modifier order? For example difference to intersect and vice versa?

import bpy
context = bpy.context
scene = context.scene

obj = context.object.copy()

bool_mods = [m for m in obj.modifiers if m.type == 'BOOLEAN']

if len(bool_mods):
    mod = bool_mods[-1]
    if mod.operation == 'DIFFERENCE':
        mod.operation = 'INTERSECT'
    elif mod.operation == 'INTERSECT':
        mod.operation = 'DIFFERENCE'

scene.objects.link(obj)

you are the best batfinger! This is exactly what I needed. Also in an understandable format! It works perfectly! Now I am dealing with this silly custom menu icon bs. Its driving me batty haha.

Try this if x is the object you want to modify and copyX is the modified object:
import copy

copyX = copy.copy(x)
last = None

for i, val in enumerate(copyX):
    if type(val) == bool:
        last = i

if last is not None:
    copyX[last] = not copyX[last]

thats an interesting answer that also does the job!


text:
Split row inside of pop up panel while keeping formatting
So I have a panel I want to create a split option for. I experimented with box, row and column but was unable to get anywhere. I basiclly just want (S) and (C) on the same menu without extending the panel to be longer.
else:
                #C/S Sharpen Split Option
                layout = self.layout
                row = layout.row(align=False)
                split = row.split(percentage=0.5)
                col = split.row()

                Ssharpen = icons.get("Ssharpen")
                CSharpen = icons.get("CSharpen")

                col.operator("ssharpen.objects", text = "(S)", icon_value=Ssharpen.icon_id)
                col.operator("csharpen.objects", text = "(C)", icon_value=CSharpen.icon_id)

this is what the menu looks like normally

While the extended menu looks cool I would like it more if I was able to lock it to that layout and had guidance text in the blank area.
But I would rather it just have both the S and C in a panel thats the same size as normal.

use colum_flow(x) and col.label("for the text")
(colum must be equal to get a nice look)
else:
            #C/S Sharpen Split Option
            layout = self.layout
            row = layout.row(align=False)
            split = row.split(percentage=0.5)
            col = split.colum_flow(2)

            Ssharpen = icons.get("Ssharpen")
            CSharpen = icons.get("CSharpen")

            col.operator("ssharpen.objects", text = "(S)", icon_value=Ssharpen.icon_id)
            col.operator("csharpen.objects", text = "(C)", icon_value=CSharpen.icon_id)

it is not exactly what you want, but near...
import bpy

class SimpleCustomMenu(bpy.types.Menu):
    bl_label = "Simple Custom Menu"
    bl_idname = "OBJECT_MT_simple_custom_menu"

    def draw(self, context):
        layout = self.layout.column_flow(2)

        layout.operator("object.duplicate_move", text="Duplicate")
        layout.label("1. use for text")
        layout.label("2. use for text")
        layout.label("3. use for text")

        layout.operator("object.duplicate_move_linked", text="Duplicate Linked")
        layout.operator("object.duplicate_move_linked", text="Duplicate Linked")
        layout.operator("object.duplicate_move_linked", text="Duplicate Linked")
        layout.operator("object.duplicate_move_linked", text="Duplicate Linked")

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

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

if __name__ == "__main__":
    register()

    # The menu can also be called from scripts
    bpy.ops.wm.call_menu(name=SimpleCustomMenu.bl_idname)

awesome. I am still fairly confused with it but I will continue messing with it. I feel I am missing something with formatting inside of panel boxes. But this answers my question!

Zeffii also posted a good example here: http://blender.stackexchange.com/questions/44356/fighting-split-col-and-aligning-row-content


text:
How to make a conditional that uses existing modifier value if present and adds one if not present
So how would i script an operator to ignore a bevel that is on the object but add a bevel if it is already on the object. But also if a bevel is there to keep that width value instead of modifying it.
class csharpenOperator(bpy.types.Operator):
'''Sharpen With Modifiers and Bevelling'''
bl_idname = "csharpen.objects"
bl_label = "CSharpen"
bl_options = {'REGISTER', 'UNDO'}

items = [(x.identifier, x.name, x.description, x.icon)
         for x in bpy.types.Modifier.bl_rna.properties['type'].enum_items]

modtypes = EnumProperty(name="Modifier Types",
                       items=[(id, name, desc, icon, 2**i) for i, (id, name, desc, icon) in enumerate(items)
                               if id in ['BOOLEAN', 'MIRROR', 'BEVEL', 'SOLIDIFY']],
                       description="Don't apply these",
                       default={'BEVEL'},
                       options={'ENUM_FLAG'})

angle = FloatProperty(name="AutoSmooth Angle",
                      description="Set AutoSmooth angle",
                      default= radians(60.0),
                      min = 0.0,
                      max = radians(180.0),
                      subtype='ANGLE')

bevelwidth = FloatProperty(name="Bevel Width Amount",
                           description="Set Bevel Width",
                           default=0.0200,
                           min =
                           0.002,
                           max =0.25)

apply_all = BoolProperty(default = True)

original_bevel = FloatProperty()

@classmethod
def poll(cls, context):
    ob = context.object
    if ob is None:
        return False
    return (ob.type == 'MESH')

    #F6 MENU
def draw(self, context):
    layout = self.layout
    box = layout.box()
    # DRAW YOUR PROPERTIES IN A BOX
    #box.prop( self, 'ssharpangle', text = "SsharpAngle")
    col = box.column()
    col.prop(self, "modtypes", expand=True)
    box.prop( self, 'angle', text = "SmoothingAngle" )
    box.prop( self, 'bevelwidth', text = "BevelWidth")
    box.prop( self, 'apply_all', text = "ApplyAll")

def execute(self, context):
    scene = context.scene
    ob = context.object  # soapbox call don't use bpy.context as context is passed
    obs = context.selected_objects
    angle = self.angle
    original_bevel = self.original_bevel
    bevelwidth = self.bevelwidth

    #Sets Original Bevel To Initial Value
    #original_bevel = 0.2
    original_bevel = bpy.context.object.modifiers["Bevel"].width

    #Just Trying To Make It Work
    bpy.ops.object.modifier_remove(modifier="Bevel")
    bpy.ops.object.modifier_remove(modifier="Solidify")
    #so that the csharp doesnt mesh up the object

    #keep the old here for now
    bpy.ops.object.modifier_add(type='BEVEL')
    bpy.context.object.modifiers["Bevel"].use_clamp_overlap = False
    bpy.context.object.modifiers["Bevel"].show_in_editmode = False
    bpy.context.object.modifiers["Bevel"].width = bevelwidth
    bpy.context.object.modifiers["Bevel"].segments = 3
    bpy.context.object.modifiers["Bevel"].profile = 0.70
    bpy.context.object.modifiers["Bevel"].limit_method = 'WEIGHT'

    mod_dic = {}
    if self.apply_all:
        #remove modifiers no one would want applied in this instance

        #bpy.ops.object.modifier_remove(modifier="Bevel")
        #bpy.ops.object.modifier_remove(modifier="Solidify")
        # replace with
        mods = [m for m in ob.modifiers if m.type in self.modtypes]
        for mod in mods:

            mod_dic[mod.name] = {k:getattr(mod, k) for k in mod.bl_rna.properties.keys()
                                 if k not in ["rna_type"]}
            print(mod_dic)
            ob.modifiers.remove(mod)

        #convert to mesh for sanity
        #bpy.ops.object.convert(target='MESH')
        #Object.to_mesh(scene, apply_modifiers, settings, calc_tessface=True, calc_undeformed=False)

        mesh_name = ob.data.name
        ob.data.name = 'XXXX'
        # remove the old mesh
        if not ob.data.users:
            bpy.data.meshes.remove(ob.data)
        mesh = ob.to_mesh(scene, True, 'PREVIEW') # or 'RENDER'
        ob.modifiers.clear()
        mesh.name = mesh_name
        ob.data = mesh

        for name, settings in mod_dic.items():
            m = ob.modifiers.new(name, settings["type"])
            for s, v in settings.items():
                if s == "type":
                    continue
                setattr(m, s, v)

    return {'FINISHED'}

I think at some point I got confused as to how the script works which could be whats making it hard. But the expected behavior is always if a bevel isnt present then add one but now I have a 2nd operator that puts a bevel on the object just to allow this operator to work without error.

You should check for BEVEL type in your "for mod in mods" loop. Then you can add the new bevel mod after if your loop returns no bevel types.

The code  ob = context.object lets you  use ob as an object reference rather than  bpy.context.object

To check if a modifier named "Bevel" exists and if not add one
obj = context.object
mod = obj.modifiers.get("Bevel") # returns None if not present

if mod is None:
    # add one
    mod = object.modifers.new("Bevel", 'BEVEL')

    mod.use_clamp_overlap = False
    mod.show_in_editmode = False
    mod.width = bevelwidth
    mod.segments = 3
    mod.profile = 0.70
    mod.limit_method = 'WEIGHT'

Note, get is used as
obj.modifiers["Bevel"]

will throw an error if there is no modifier named Bevel
I'd suggest using name apart from "Bevel", the default name for a bevel modifier if you are going to add a custom one.
To get all the BEVEL type modifiers, as suggested by Todd_McIntosh
mods = [m for m in ob.modifiers if m.type == 'BEVEL']
print(obj.name, "has", len(mods), " BEVEL modifiers")
for mod in mods:
    print(mod.name)

which was in the first incarnation of the answer Why does bpy.ops.object.convert(target='MESH') have an error? and was changed to allow you to copy, remove, apply others then re-add, for more than just the BEVEL modifier
The same collection.get(...) and collection.new(...) or collection.add(...) works for most collections on blender. Use python console auto-complete ctrl-space to see what options are available.
>>> C.object.modifiers.new(
new()
ObjectModifiers.new(name, type)
Add a new modifier
>>> C.object.modifiers.new(

ah now im confused. So I guess i am falling behind on my understanding of the code since the dictionary was added. I think it has become more complicated than my understanding is capable of. So I would need to add this to the for loop? Is there a way to keep it simple where it does the normal operation however it just adds a bevel if not present?

It might be an idea to create a dedicated  post in http://blenderartists.org/forum/forumdisplay.php?11-Python-Support , rather than adding a new question here pertaining to each new issue.

yeah youre right. I will try another mean for these issues because its just getting more and more complex and presenting new issues with each change. sorry about that!

Absolutely no problem at all, happy to help on BA.  Remember the print statement is your friend, for instance printing the dictionary will show it's just a quick way to store the modifier settings.  Coding is a J curve type of thing, a little perseverance and it will be worth it.


text:
How would I put the sculpt brush menu inside of an operator? So it can be a popup
So I attempted to right click locate source and use the line for the brush here
 toolsettings = context.tool_settings
 settings = self.paint_settings(context)
 brush = settings.brush
 layout.template_ID_preview(settings, "brush")

However I dont think I am understanding how it works. I figured it would be as easy as the matcap which was just this.
view = context.space_data
layout.template_icon_view(view, "matcap_icon")

Here's an example of how I wanted to put it in an operator.


text:
How to Select Vertices In the position of an active selection?
So this class is supposed to select the verts of an active object that is inside of another object but it only works at position near 0,0,0.
class ComplexSplitcheck(bpy.types.Operator):
bl_idname = "split.check"
bl_label = "Split Check"
bl_options = {"REGISTER", "UNDO"}
bl_description = ""

max_dist = 1.84467e+19

def execute(self, context):
    selected = bpy.context.selected_objects
    active = bpy.context.active_object
    selected.remove(active)

    for obj in selected:
        for v in active.data.vertices:
            if is_inside((active.matrix_world * v.co), self.max_dist, obj):
                v.select = True

    return {'FINISHED'}

def is_inside(p, max_dist, obj):
result, point, normal, face = obj.closest_point_on_mesh(p, max_dist)
p2 = point-p
v = p2.dot(normal)
return not(v < 0.0)

I expect closest_point_on_mesh is only intended to be used on it's own mesh data, try converting the global point to a point local to the target data.


text:
When I bake a specular map out from Blender they always contain the glossy colors?
So a specular map should be black and white correct? I don't understand how to bake specular maps using cycles that are in the proper black and white form.

Bake the Specularity data, not the light interaction
According to the Wikipedia, specular maps contains the valuest that:

represents the amount of reflectivity a surface has.

These maps are used in order to give to the rendering engine the information about how the light should interact when hitting that particular pixel of the surface.
What you should bake is the data about where a surface is capable of reflecting light and where is not, and not how the light interact with the surface (Glossy color, Glossy Direct, Glossy indirect, Combined....) because these are the result of the render engine.
Let's consider a simple material made of a Diffuse and Glossy shader mixed with a musgrave texture:

In this case it's easy to understand that the amount of Specularity is equal to the values that go into te mix shader factor. Where is black is Diffuse (no Specularity), where is white is Glossy (Specularity).
To bake that data just use an emission shader picking the color from the cable that is going into the mix shader's input socket

Here's the counter-prove. The baked map is now controlling the specularity of the surface as the musgrave was doing before.

For complex shaders things becomes harder, you'll have to build a custom nodetree capable of exctracting the Specularity data on each passage (e.g. if you are using multiple mix shaders).


text:
Concerning ease of use Internal or Cycles for applying, and baking textures to Unity?
So okay I see many tutorials that are really GOOD, but to my surprise they are done with Internal even if the video is not old.
When I was comparing bake options I didn't see all the options I expected to see as I did see on the Internal bake options for example: Displacement I did not see this option for cycles. This option is important for baking out a combined height map.
From my current experience it appears to me that Cycles is more for the animation side of things, renders etc, whilst Blender Internal is still great for working with your various maps. I could be totally wrong, but as far as I can tell I should be using Internal for the time being to work with my game textures.
If anyone could shed some light on the situation I would really appreciate it.
TL;DR - Is Blender Internal better for game texturing and baking or is Cycles still the way to go, and I'm just not getting it yet.

I personally regard the internal as a technical resource: I use it for mattes and the like. It also does things like displacement baking quite well. However, if you want to bake anything that is even remotely related to light, use Cycles. (With the notable exception of baking AO. Cycles creates noise while the internal gives the same result noise-free.)

Well for simple combined baking of diffuse, specular, and normal maps from several materials as far as I can see the process is pretty straight forward on Internal. Would you consider my statement accurate?

Yes. It is straightforward and, if for your use case it works, great. What I meant is that Cycles is made to produce as realistic results as possible. If you compare the maps from the two renderers, you will see that Cycles is more accurate with things like shadows. What I would personally do would be to make the specular and normal maps in the internal (though if you need a cage, only Cycles can do one afaik., not sure.) as they are faster and noise-free. However I would do the diffuse in cycles as it is raytraced and more realistic. This is only my oppinion. Do whatever best works for you.


text:
How can I combine 4 intersecting/converging polygons?
So I really can't figure out a good way to combine these at the convergence point.

I guess I should also add would it even be worth combining if it is for game use or some sort of production work?

try this: http://blender.stackexchange.com/questions/28574/simple-way-to-creating-vertices-at-intersecting-planes-and-deleting-leftover-int/28577

Denis this helped, but gives me an undesired outcome. I think I'll just need to leave it as is.

There is an addon called "pipe joints". Not updated anymore but still usable.

Unless you're concerned about excess mesh (which can slow things down when they get too much) you shouldn't need to worry about it.


text:
How to deal with loop cuts on twisted geometry
Say that I have some thing twisted like this thing
And that I want to add a loopcut through what from this view is the inner faces. Following these quads now spills out to the outer faces as well. Repeating the procedure will give more and more spiraly things. How to avoid this, if I still want to have this object as a manifold.

If this is a mobius ring, as it has only one face I don't see how you can avoid that

What about putting in n-gons (n > 4) as isolators?

As all mobius strips, there is no 'inner faces'. There is no inner 'edge'. There is but one 'edge', 'The' edge. As well as only one 'face'.
Study the topology yourself, this is the main property of the mobius strip

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


text:
Collect, apply modifiers, and triangulate meshes before export, without touching the original mesh
I try to export a collection of meshes such that

The original meshes is not touched by the exporter
All modifiers affect the exported mesh
The exported mesh is triangulated
It should not look like the file has been changed by the exporter

It is permissable to not fullfil the fourth requirement though.
Here is my preparation functions, used to copy the meshes and joining them into one:
def collect_meshes(collection):
    meshes = []
    for object in collection:
        if object.type == 'MESH':
            tmp = object.copy()
            tmp.data = object.data.copy()
            meshes.append(tmp)
    return meshes

def apply_modifiers(objects):
    context = bpy.context.copy()
    for object in objects:
        # Cannot select this object because it is not in a view layer
        # object.select_set(True)
        for modifier in object.modifiers:
            # How to apply a modifier on a different object?
            # bpy.ops.object.modifier_apply(context, modifier =  modifier.name)
            pass

def join_meshes(mesh_array):
    context = bpy.context.copy()
    context['active_object'] = mesh_array[0]
    context['selected_editable_objects'] = mesh_array
    bpy.ops.object.join(context)
    return context['active_object']

def triangulate(mesh):
    bm = bmesh.new()
    bm.from_mesh(mesh)
    bmesh.ops.triangulate(bm, faces = bm.faces[:])
    bm.to_mesh(mesh)

In case something went wrong, I also have the following cleanup:
class MeshCopy:
    def __init__(self, mesh):
        self.__mesh = mesh

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.__mesh.user_clear()
        bpy.data.objects.remove(self.__mesh)

    def get(self):
        return self.__mesh

So I can use the with statement for RAII. Is only way to get this working to create a copy of the original file, and export the content of that file and then delete the copy?

Bmesh from object.
See How do I get a mesh data-block with modifiers and shape keys applied in Blender 2.8?  Can use the evaluated mesh and look at loop_triangles or with a bmesh and call the bmesh triangulate operator. In both cases no new data need be added to file.
The two answers show how to get the evaluated mesh as either a bmesh or an evauated mesh.  In either case there would appear little need to bother with a context manager to use the with statement.

Result of running on two selected subsurfed default cubes, creating one joined and triangulated to export
Here is an example that creates a joined and triangulated bmesh from all the selected mesh objects.
Just as with multiple calls to bm.from_mesh(...) can be used to read multiple meshes into one bmesh, can do same for bm.from_object.
On each "read" the new vertices are transformed by the objects matrix world.
To demonstrate result, a new mesh object is created and added to scene, whereas the exporter can simply re format the bmesh data.
import bpy
import bmesh
context = bpy.context

meshobs = [o for o in context.selected_objects if o.type == 'MESH']

dg = context.evaluated_depsgraph_get()

bm = bmesh.new()

for o in meshobs:
    n = len(bm.verts)
    bm.from_object(o, dg)
    bmesh.ops.transform(
            bm,
            verts=bm.verts[n:],
            matrix=o.matrix_world,
            )

bmesh.ops.triangulate(
        bm,
        faces=bm.faces,
        )

# new object to test
me = bpy.data.meshes.new("TriExportTest")
bm.to_mesh(me)
ob = bpy.data.objects.new("TriExportTest", me)
context.collection.objects.link(ob)

World or Object Coordinates?
Note the created bmesh above will have its vertices use the global coordinates of the input meshes. And an identity matrix world (no transform)  To more closely emulate the join operator, by using object space of the active object
Save and calculate inverse of matrix world of active object.
mw = context.active_object.matrix_world
mwi = mw.inverted()

then in the bmesh transform operator
    matrix = mwi @ o.matrix_world

and finally assign the matrix world to the joined object
ob = bpy.data.objects.new("TriExportTest", me)
ob.matrix_world = mw

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


text:
Besides weight, what determines how much a vertex group is affected by bones
As you can see, the middle part of the wing, doesn't keep up when I try to pose it. Apparently, the vertices in between are held back for some reason. The same is true for the inner bone, though it is not that much.

[

I had these vertices assigned to another vertex group as well. Removing that connection solved the problem.

Beside weight, it's weight relative to others bones. Check all your others vertex groups and remove all weight from wing vertices.


text:
Emit particles from faces with a specified normal
Is it possible to only use faces whose normal points in certain directions, for example, only emit particles from faces pointing in the positive z direction. or some other condition, like it must lay in the x-y plane with z the z component within -0.5 to 0.5? It could be done by manual selection and using vertex groups, but that would be quite time consuming. Another solution would be to select vertices that fulfill the condition.

Two possible workarounds I can think of is to use either Dynamic Paint (never used it myself, not sure if you specific case can be achieved) to have an image texture drive particles, or the Vertex Weight Proximity modifier https://blender.stackexchange.com/questions/165827/using-a-b%c3%a9zier-curve-to-raise-lower-height-of-vertices/165831 https://blender.stackexchange.com/questions/153177/worms-crawling-under-skin/153181

Here is a script to do it
import bpy
import bmesh

# Get the active mesh

current_object = bpy.context.object
leaf_veto = current_object.vertex_groups.new(name = "leaf_veto")

me = bpy.context.object.data

# Get a BMesh representation
bm = bmesh.new()   # create an empty BMesh
bm.from_mesh(me)   # fill it in from a Mesh
verts = []
# Modify the BMesh, can do anything here...
for v in bm.verts:
    if v.normal.z > 0.5 or v.normal.z < -0.5:
        verts.append(v.index)
# Finish up, write the bmesh back to the mesh
bm.free()  # free and prevent further access
leaf_veto.add(verts, 1.0, 'ADD')

Now, ban particles from leaf_veto vertex group

The particle options in Blender are rather limited at the time (they promised to change that in 2015...) so the only solution I can think of is Animation Nodes or Python, delete the particles depending on their start direction.

So something similar to https://stackoverflow.com/questions/58654905/listing-vertices-per-face-in-python-blender-bpy and assign vertices to a vertex group, which should be possible through the python API?

yes, that's one way. My suggestion was much more blunt, but it would work with deformed meshes, so that's why it came to my mind


text:
Select adjacent faces
Suppose that i have a some quads. How do I select the next quad in one direction. If I use Ctrl, then blender tries to find the shortest distance using some norm. I want it to only consider faces that will not cause a 90 degree turn. Sort of select face loop. I want the selection to follow the arrow rather than taking the shortcut. The keyboard shortcut selects the faces that has been selected in the figure, which does not follow the path.

If you select a face, then the next one, then [Ctrl Shift +], it will select the next one and so on, but I'm not sure this is what you want

Pretty sure you can select adjacent faces by doing ALT+LMB.

Have you used the knife tool to cut this "path" into the grid mesh? The result would be a lot of ngons and poles. That's a bad mesh topology. Blender's selection tools such as ALT+click for face loop selection only work when you have a clean quad mesh. Otherwise, it will stop right at the next pole/ngon.

@RPaladin ALT+LMB doesn't do anything.

@Moonboots That works

If you select a face, then the next one, then CtrlShiftNumpad +, it will select the next one and so on


text:
Importing objects from 3Ds Max to Blender with instancing
What format or method is necessary to transfer a scene from Max to Blender without breaking instancing? I am trying to get some terrain, buildings, and trees from a large city scape working. They were made in Max, and have proper instancing. Right now I have them as .objs. The instancing breaks, causing any renders to require a huge amount of resources. Is there something I can do on either the Max end or Blender end to make this work? I can have it re-exported with different settings or formats.

Not sure an automated way exist. If you are familiar with python you could write your own exporter. Export only point reference from max and automatically assign instanced objects to it in blender (or face if you need some kind of orientation/scale support).

The only thing I can think of, short of scripting, would be to manually re-instance the objects in blender. You can do this by either deleting all the objects except one, pressing Alt-D to instance it, then place the instance where you want it in the scene. Or you could select all the objects that need to share the same mesh, then press Ctrl-L > Object Data.

FBX supports instancing. I'm not familiar with now Max handles FBX, but I transfer between blender and maya with FBX all the time to keep my instances. As far as I can tell, Autodesk has done a pretty decent job of making FBX work between their own packages, so my guess is it will work for Max as well. Make sure you export from Max with the proper plugin version or blender won't be able to read it properly. Blender supports the 2014 version (7.4) for binary and 2010 (6.1) for ascii. I use binary constantly and have never had issues with it. All my stuff is simple geometry, though. It obviously won't transfer rigs properly.
Hope that answers your question. I don't have Max installed, so I can't test it myself.

authors: Андрій Немченко


text:
Select objects based on size
I am generating rubble with cell fracture. This means I have hundreds of objects. For various reasons, I want to select all of the larger pieces. Is there a way to select all objects above a certain size, or deselect all below a certain size?
Scripts are good too.

This script will select all the objects that have a similar volume to the selected object (by similar I mean the same rough scale - tens, hundreds, thousands, etc):
import bpy, bmesh

bm = bmesh.new()
bm.from_mesh( bpy.context.object.data )

ref_obj_name     = bpy.context.object.name
reference_volume = float( bm.calc_volume() )
ref_vol_scale    = ( '%.0E' % reference_volume )[-3:]

# Select all the objects in the scene that have a similar volume (of the same scale)
for o in [ m for m in bpy.context.scene.objects if m.type == 'MESH' ]:
    if o.name == ref_obj_name: continue

    bm = bmesh.new()
    bm.from_mesh( o.data )

    vol       = float( bm.calc_volume() )
    vol_scale = ( '%.0E' % vol )[-3:]

    if vol_scale == ref_vol_scale:
        o.select = True

Works also in blender 2.8. Just change the last line to: o.select_set(True) Thank you!

Thank you for the script. Is it possible to make it more accurate and add things like bounding box parameters, maybe?


text:
Magnet vertices together
I am looking for a way to have vertices snap onto each other based on proximity and distance. For example, if I had 2 loops of vertices, I would want it to snap each vertex in loop 1 to the closest corresponding vertex in loop 2 at their midpoint. However, if they are more than a certain distance apart, the vertices would not be affected.
It would be like having 2 different loops/meshes shrinkwrap onto each other, but meeting in the middle.
I am sure this is possible with a script. Is there any way to do it without scripting?

It sounds like you could just use Remove Doubles, and adjust your merge distance.
The only thing here is they don't meet half way. That may be dependent on Mesh origin though. I'll do a little checking and get back.

Nope this is not based on origin, I think it is more based on vertex indices based on how it acts.

Shrinkwrap with a pass of limited disolve seems to work pretty good just be sure to use it on a closed mesh that has enough topology do bend at the right places.

That would sort of work, but then it merges the vertices. I want to keep them separate, as the mesh will be deforming.

You can always use a shrinkwrap modifier on a broken mesh like this, just be sure to check the option to keep it above the surface, and make sure it has enough subdivisions.

I appended my answer to show you what I'm talking about.


text:
Performance impact of turning up Max transparency bounces?
When using transparent objects, if you do not allow enough transparency bounces (set in Light Paths) then you will get black artifacts. Having more transparent surfaces and bounces slows down the render. But does it matter if your Max bounces area higher than the number of surfaces in your file? If you have 0 transparent shaders present and turn Max bounces up, does it matter? Is there any reason not to always leave it at a high number?

No, it has no effect if you do not have any transparent shaders in your scene. Setting it too high could result in a lot of extra bounces being calculated for little result on some stray transparent object. One of those corner cases that comes up sometimes. Additionally, some would say the default of 8 (with no early path termination, since the minimum is also 8) is already a "high" number. It depends on your scene and your goals. Adjust accordingly.


text:
What nodes clamp your values?
It seems that certain nodes, as part of their function, will clamp their output to between 0 and 1 regardless of the input number. I am not entirely sure of this. Is there a list of what nodes will do this in Cycles and the Compositor?

Most nodes should not.
Cycles works under a scene referred rendering model, which means that there is no notion of white or black, but merely a range of values that traverse from some low value to a theoretically (within the quantization limits of 32 bit float) infinite range of light.
As such, all nodes should never clamp, or they will not deal with the scene referred data correctly.
Some by design might map such as the Range node. The Colour Ramp sadly is based on a fixed 0.0-1.0 range which greatly diminishes it's usefulness with modern renderers.
The precise answer to the best of my knowledge, is that there is no comprehensive listing. This is something anyone could map out however via the wiki with a table and a little help from contributions.

Some nodes clamp input values and some intermediate calculations to sane values - often between 0...1 or -1...1
The only nodes that clamp output values should have a clamp option that the user needs to enable for the output to be clamped. I think this list is limited to Math and MixRGB in both material and compositor and the Map Range and Map Value available in the compositor.


text:
Build color ramp out of math nodes?
I want to use color ramps or RGB curve effects in my node groups. This runs into the problem that the only sockets these nodes have is their input image and factor. This means if I have them in a group, I cannot control the actual ramp/curve stops with inputs from outside the group.
Is it possible to build a custom math node group that would do the same thing as a color ramp or RGB curve, but would allow me access to an equivalent of stops?

You'll have to deal with the fact that there will be a "given number" of handles though. I don't think that the node interface nowdays allows to let you add them interactively from the node group imput. If you want to use just 2 handles, I would suggest to give a look at this related answer: http://blender.stackexchange.com/a/34593/15140 (the first part: Create a Map Range node) where is shown how to reproduce the behaviour of a linear-2handles-color ramp node.

I want to make a group that could have several handles. Most uses would need only two, but sometimes I may go as far as 4. Thanks for the link.

You mean like this?

If your group is not instanced consider using colored frames instead of groups to organize your nodes.

Unfortunately there is no way to create a group node exactly like the Color Ramp, where you can add and remove color swatches at will.  To get around this I have created a node with two movable swatches, you can then combine multiple of these nodes together to have the functionality of multiple swatches.

The theory:
The two input colors are plugged directly into a Mix RGB node.  The two Pos inputs need to be sent through a function and plugged into the mix factor.  The position of the first swatch needs to be mapped to $0$ to get just the first color out of the mix node.  The position of the second swatch needs to be mapped to $1$ to get just the second color out of the mix node.

The math:
Here's a graph to visualize what we are trying to do, on the x-axis is the input factor of the color ramp, on the y-axis is the desired output, $a$ and $b$ are the positions of the two swatches.

With some simple algebra we can find the equation of the line to be:
$$
y = \frac{1}{b-a}x + \frac{a}{a-b}
$$
The math nodes below are simply replicating this equation.  The final Add node also has Clamp checked to clamp the output to the interval $[0,1]$, which is what the mix node accepts.

Taken from my answer here.

Thanks for this nice setup, really helpful. I wonder if there's a way to replicate the constant interpolation type of the color ramp...? I always manually add a rgb curve and shift the black point to the right, but I guess this also can be done with simple math tricks, right?

@poor I believe that can be done with a greater than node plugged into the mix factor.


text:
Export from Blender to Maya preserving Materials and Crease
I have a character in Blender. It needs to be exported to Maya for rendering in VRAY. I need to figure out how to preserve the following:
1) Textures and UVs.
2) Material assignments to different parts of the mesh.
3) Crease. Currently the model is using a subsurf modifier in Blender, and some edges need to be creased. Maya also has options to smooth and subdivide the mesh, and it's own form of Creasing to preserve edges.
4) Group assignments of multiple objects.
5) Challenge Mode: The rig. The character will actually be rigged in Maya, so I'm not worried about this for this specific project. But it'd be nice to know how to do it in general.
What format and settings do I need? Is there one that can handle all of these issues?

Maybe using a .fbx?  You may need to apply the subsurf modifier in Blender for it to be "baked" into the model (or the fbx exporter may do that automatically).  Please note, I have not used Maya, I just know what Unity does and it appears to work.  You may or may not need to relink your textures though.

I want to avoid applying the subsurf, as that will make the mesh a nightmare for the rigger, and we don't want that level of topology in the viewport.

You do know that there is vray for blender. However that does not help since you are exporting it to be rigged in maya.

Yes, I do. Unfortunately this project involves a team, and we have a lot of assets coming from other programs that we can cleanly bring into Maya, but not Blender. We'd just render in Blender with Cycles if we could get all our scenes and stuff in, but there's too many other import/export problems.

Unfortunately, FBX is the only serious option currently (maybe with Collada, but that format is not much supported/developed nowadays…).
FBX can support edge crease (LayerElementCrease node), just never had time/reasons to implement that in Blender. And I'd need a simple FBX file exported e.g. from Maya, with a dummy cube and various levels of crease on its edges, to be reasonably sure we do handle it correctly…
Besides that, afaik FBX does not support/have notion of groups of objects.
It should support reasonably simple rigging, but do not expect advanced stuff (like drivers, constraints, etc.) to survive, only basic bones skinned with basic vgroups.


text:
Blender Video Editor: Clip stays attached to cursor after releasing left click during drag
I am having a problem with the blender sequence editor and editing clips. Whenever I want to move a clip or trim it, I would hold left click (I set it as left click) to trim/move the clip but when I stop holding left click, the clip or end of the clip still stays attached to my cursor until I click again. Is there a way to set this so that I don't have to click 2 times to trim/move a clip and instead just drag them?

With the clip selected, you can hit 'g' to move (just like the 3D view, the Graph Editor, the Node editor, etc) and use your mouse to reposition the sequence. When you are finished, left-click to accept, or right-click to undo.
I think you will find that this is very easy to use, and, even better (because it is exactly like the rest of blender) it is also easy to remember.

While I do like that while using the 3D viewport and modelling/animating, it completely throws me off for the sequence editor because I'm so used to just dragging the clip and letting go of it to put it in place or to trim it. But if there is no way to enable that feature then I'll just adapt to the 2 mouse clicks to move or using the g button and click.


text:
Determine which face was clicked in BGE
How might one go about determining which face of a model was clicked on a mouse up event inside BGE? For example, I have a map model with several selectable locations. Each location consists of at least one face (some more). I need to know which face was selected after user clicks mouse, to know which location to send a character model.

I'm not sure but i think  the normal is a face in rayCast return the hit object, point and normal.

You could also combine a "mouse over" with a "mouse click" sensor then send a message to the character, containing the selected location

@Quacksilber Yes, this is the gist of what I'm trying to do, but how can I obtain the face (normal) that was clicked? In bge after the mouse click event, how do I know which normal was clicked?

Depends on the number and size of these areas. Maybe you could post a picture of your map, with locations? My Approach would be to make individual objects , set to invisible, that each cover a location; but as I said this method only makes sense if your map isnt too big :)

@Quacksilber !! That's actually what I'm doing right now! :) I was just trying to come up with a way to not have to create individual collision objects for each location. One thing I was thinking was having an array that contained the vertex positions of each location, then on mouse click do a raycast and see if the click position turns up in any of those points. Then if so, I could change the material color of those normals and move the character to the center location. Does that sound feasible or overly complex? lol


text:
Properly setting up a height map using nodes
I am attempting to recreate the output I get from materialize in blender using nodes, but seem to be having an issue. This is the result I get from materialize (node the depth in the joints between the blocks):

And this is the result I'm getting in blender:

The following is my node setup:

Is there a way to recreate this effect using a height map within blender (version 2.9)?

The "magic" of regular bump maps disappears when looking at the texture at grazing angles. Unfortunately in this case I think you'll have to use a heavily subdivided mesh and real displacement to get the same effect. There is parallax occlusion mapping in the works but I don't think it will be available any time soon https://devtalk.blender.org/t/parallax-occlusion-mapping/15774 . My 2 cents

If you have a normal map and a displacement map, there is no need to combine them. If you just want the bumpy look without loads of geometry, just use the normal map. If you want a hyper-detailed, displaced mesh; just use the displacement map.

@Gorgious I do believe that's what I'm after. If there's currently no support, that answers my question :)


text:
axis_conversion producing unexpected result?
I am attempting to convert the world transforms of scene objects into a different coordinate system (-Z forward Y up) using axis_conversion method as follows:
import bpy
from bpy_extras.io_utils import axis_conversion
import mathutils

m = axis_conversion(from_forward='Y',
        from_up='Z',
        to_forward='-Z',
        to_up='Y').to_4x4()

for obj in bpy.context.selectable_objects:
    print(obj.name + "-----------------------------------")
    print(obj.matrix_world)
    nm = m * obj.matrix_world
    print(nm)
    #obj.matrix_world = nm

This produces the following output:
OilDrum_low.005-----------------------------------
<Matrix 4x4 (0.0100,  0.0000,  0.0000, 17.0000)
            (0.0000, -0.0000, -0.0100, 20.2891)
            (0.0000,  0.0100, -0.0000,  2.1153)
            (0.0000,  0.0000,  0.0000,  1.0000)>
<Matrix 4x4 (0.0100,  0.0000,  0.0000, 0.0000)
            (0.0000, -0.0000, -0.0100, 0.0000)
            (0.0000, -0.0100, -0.0000, 0.0000)
            (0.0000,  0.0000,  0.0000, 1.0000)>

The calculated matrices do not appear to have any of the translation data. Did I mix something up while doing this?

Issue is that in version 3.5 python introduced a matrix multiplication operator @, and I was unaware you had to use this syntax instead of the normal multiplication operator *. Changing this line:
nm = m * obj.matrix_world

to this
nm = m @ obj.matrix_world

resolves issue and I now receive results as expected.


text:
Procedural brush stroke texture?
I want to make some procedural textures that look like a bunch of brush strokes, pencil scribbles, or the like. The core component being that they are a collection of strokes that go mostly in the same direction and overlay each other, but each contains some smaller bristle marks, scratches, grain, etc. Any ideas on the best way to do these things?
Here are a few examples of what I want to make off google (which I assume were done by hand)

Where you want to create it? In Blender?

Yes, with Cycles material Nodes. I could make them by hand in photoshop, but I'm trying to avoid image textures any more than possible due to VRAM.

oh, sorry, I've read it too fast. I've tought that you want to make brush for grease pencil or texture paint :)

Have you considered using a procedurally mapped image texture? (box mapping?)

@gandalf3 I've thought of using image textures with various mapping or random coords, or several image textures that are then mixed together in different random combinations and with procedurals. But I figured I'd ask if anyone had come up with a good method that was purely procedural.

Ok here I got it. I think that matches it pretty well.

From the look of the first image, I think a combination of wave and noise textures, with colorramp control and some offset-repeats might work. I will experiment and get back with results.

authors: Леон Савельев


text:
Why does render resolution affect RAM use?
I am trying to understand all the factors that effect RAM use so I can get the most out of my graphics cards VRAM when rendering. I understand that the amount of geometry and the resolution of textures make a big difference. However, I do not understand why render resolution does. Can anyone explain why?

The image that is rendered need to go in the ram, so bigger image need more ram, have a look here: View Memory Usage There are other points like adaptive subdiv, but I'm not a specialist of these kind of questions.


text:
Update a shapekey Basis from another shapekey
I am editing a character that has many shapekeys for facial expressions. I have made some changes to the character's overall face to adjust its features (no vertices added or removed though.) I have done these changes as their own shapekey for convenience.
I now want to add these changes into the Basis without breaking all my other expressions. I have found that I can move my changes to be second in the list after Basis and delete Basis, and my changes are now the new Basis. However, it does not work with my expression keys, as when I use them, it undoes the changes I made by moving vertices back to their position in the original Basis, even though these points are not usually moved by the expression keys.
My expressions currently work properly with my changes as their own shape key. How can I make the changes into my new Basis and also update my expressions to behave the same way?

Related: http://blender.stackexchange.com/questions/34758/how-about-blendshapes-not-shape-keys

Ironically, your question actually solved my question! :-) Moving a new "Basis" key to the top and deleting the old Basis key indeed creates a new neutral position without affecting the vertex locations of existing shapekeys (they still use the old Basis position). This is perfect, and exactly what I needed. Thank you!! :-)

One thing to be aware of though, is if you edit the new Basis shapekey after following the procedure described above, the changes WILL propagate to all other keys. So if this is not desired, you will need to repeat the above process (creating new Basis, moving to top, etc) every time a change to the Basis is needed.

Let's say you have 3 shapekeys: Base, new Face, expression.
The first is the old mesh, the second the new modified mesh, the third the old expression movement you want to preserve.
Select the object and the basis mesh, enter edit mode, select all vertices, Ctrl V "Blend from shape": in the toolshelf (T) in the bottom left of the 3D view you will have to choose the "new Face" shape key, and set an amount (Typically 1.0).
Exit edit mode and you should have your expression shape key working on the new face.
Once you understand the principle you will have to tweak the values and the shape keys, maybe propagating not all but only some vertices, setting the amount not to fully 1.0, or tweaking your old expression shape keys, but you will have a good starting point.

This is a great tip that worked well for me. I had a few different shapekeys and I wanted to change the basis to one of the shapekeys. Once I'd changed the basis I then used the same technique to "minus" the same shapekey from the others so that they returned to something like how I had them before changing the basis.

Here's something that has worked for me...
Create a new shapekey from the basis and make the changes you want to your mesh. Exit edit mode and set the value of your new shapekey to 1. Just leave it on all the time and all the other shapekeys will be modified by it, just as if you had changed the basis shapekey.
I also discovered that if you move the new shapekey up above the basis shapekey in the list, you can't accidentally unset it. Or you can use the pushpin to lock it. Then you can make as many revision shapekeys as you want.
Maybe it's a hacky workaround, but you could use this to make variations on a single head shape that could also be undone or updated, without losing your other shapekeys.

You can use animation nodes to do this!
this case the driving shapes are added rather than mixed. Note that for each add, you must subtract a copy of your original from the result (see the vector math subtracts). Make sure use modifiers is on and you are not using world space.

In studios would often use blendshapes(shapekeys) in maya to do this as the targets stay live and are naturally additive. In this way you can isolate deformations and chain them together in a specific order feeding one last shape into your skinned mesh. Great way to keep things sane.


text:
Loop cut/subdivide triangle
I have the top shape. If I subdivide it, I get the second shape. What I want is a way to get the third. I made it by subdividing the two long edges of the triangle, and then knifing between them, but I want a way to automate it.

In edge select mode, select the 3 edges starting from the vertex on the right, then W subdivide

Two possibilities (at least).

W then subdivide, once the edges are selected: you have to be in edge select mode to do that.

Knife tool (activated by K) then hold the Ctrl key to cut at the middle of the wanted parts (you have to click at each cut you want to position and to validate with Enter at the end)

This last way is certainly more easy. For instance :

In edit mode, select the left hand edges and press Offset Edge Slide in the toolbar (Ctrl + Shift + R).  A factor of 0.5 will place the new edge in the centre.


text:
Dilate/Erode: Difference between Step and Distance mode?
What is the difference between the Dilate/Erode nodes Step and Distance modes? I can tell they are doing different things, but I'm interested in the technical details and the documentation does not cover it.

In Step and Distance mode, the Erode/Dilate node samples through all pixels and compares their value to the neighbouring pixels. If a neighbouring pixel has a lesser value, than it is matched the sample pixels value.
The following pseudo python shall demonstrate.
FOREACH a OF allPixels:
    FOREACH b NEXT TO a:
        IF (a > b):
            b = a

In Step mode, the adjacent pixels are right, top, left, bottom.

In Distance mode, the adjacent pixels include diagonal connections.

Here is a comparison of an example.

authors: Ильдар Ахметов


text:
Freestyle depth of field
I am using Freestyle on a Cycles scene with some depth of field. The Freestyle doesn't get affected by the depth of field, and so pops out too much on objects that aren't in focus. I am looking for any sort of trick or method to get some blur on that FS without also blurring it on the focus.
I could switch to doing fake DoF on the whole scene in post processing, but are there any other options?

Answering my own question, it looks like the best option is similar to what squarespiral suggested, but instead use Distance from Object, and place the object (likely an empty) at the focal point of the shot. Then use distance from object to add thickness, alpha, etc.

I have the same Problem! Can you post some photos of demonstrating it so it & Thanks!

Freestyle is applied after the actual render, so the short answer is: no, you have to work with post processing (maybe filtering the freestyle edges with a Kirsch filter and apply the blur only to that portion of the image).
But, you might be able to fake something using the "Distance from camera" modifiers in freestyle. This modifier can be applied to color, alpha and thickness. The settings are under line style - here is a quick example:


text:
Convert Object texture coords to Polar
I am building a procedural eye texture setup based around Object coordinates. As part of the project, I am trying to re-create a setup that is normally used for UV textures.
This tutorial shows how to re-map Rectangular coords to Polar in order to have a procedural texture radiate out from the center of the eye: https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Advanced_Tutorials/Procedural_Eyeball_in_Cycles
I am trying to re-create the same effect, but using Object Coords instead of UV. Is this possible?

How about a color ramped circular gradient?

It should be the same as using UV except that you won’t need to subtract 0.5 to move the origin as object coords are already centred around zero - ie, simply use arctan(y/x).

@RichSedman Thanks. I've tried removing the subtraction and I'm still not getting the proper result. Can you post an answer with the nodes? Thanks.

@Drudge I've added an answer to include additional nodes to convert to properly to the range 0.0 to 1.0 (the arctangent returns radians for only half the rotation so needs some conversion). Hope this helps.

You can convert Object coordinates into Polar coordinates using the 'arctangent' trigonometric function by using :
arctangent(y/x)

This will produce a result in Radians (where there are pi radians in 360 degrees) although without additional nodes it will only produce results for half the rotation (and will produce negative values).
The following nodes should produce a result that varies from 0.0 to 1.0 :

To explain this a bit, the Object coordinates are split into the separate X, Y, Z components and the Divide node used to generate Y / X. This is passed to the Arctangent node which produces the angle (in radians) between -pi/2 and pi/2 for half a rotation (for the second half it repeats -pi/2 to pi/2). This is divided by 2*pi to convert it to the range -0.25 to 0.25 and 0.25 added to shift the range to 0.0 to 0.5. The Less Than node is then used to detect the second half of the rotation and add 0.5, resulting in the full rotation mapping from 0.0 to 1.0 producing the result shown in the image above.
Blend file included

The other half of the polar coordinates is the distance from the origin. This is simple to achieve as sqrt(x^2 + y^2) as follows :

Combining these into a nodegroup to allow it to be easily reused results in the following :

Using the nodegroup to build a procedural eye texture can produce the following :

Blend file included


text:
Restore vertex groups after live boolean modifier
I have several objects that I am combining with a boolean modifier, but I am not applying it as I want it to stay live as the objects move. After the boolean, I want to use other modifiers that need vertex groups, and subsurf that needs crease. The boolean wipes these both out.
I know that if I have a UV unwrap and apply the boolean, I can restore my original seams with the Seams from Islands command. But I am not applying the boolean.
I have tried using Data transfer from a non-booleaned version of the objects to transfer vertex groups and creases, but it does not seem to be working. Is there a specific combination of settings that will make it work, or some other option?

Can you upload a simple version of your file using https://blend-exchange.giantcowfilms.com/ so people can experiment using your exact setup?

@RayMairlot I cannot as it's part of a larger project. I'm looking for general info on how transferring this data works, if at all.

What modifiers, specifically are you using after the Boolean?

@ScottMilner I want to be able to use Smooth, Mask, and Displace with vertex groups, and have edge data for Crease on Subsurf.

Without knowing your specific setup, I'm going to show a basic example of how to use the Data Transfer modifier to restore either Crease data or Vertex Group data after they have been destroyed/modified by a Boolean modifier from a copy of the object.
Here we have a sphere with some creasing applied to some of the edges of a sphere that has a Subsurf modifier added to it:

And now above the Subsurf I add a displace modifier and set it to only use the bottom half of the sphere by specifying a vertex group:

So we now have vertex and crease data and we can test ways that the boolean modifier might destroy/modify that data and how to restore it.
Here I add a Boolean modifier at the top of the modifier stack (Subsurf disabled):

We can see that actually the vertex group of the Displace modifier has been preserved and is still working as only the bottom half of the sphere is displaced:

However, in the image above we can also see that the crease data has been removed by the Boolean; we no longer have the pinching effect shown in the previous images.
We can now restore this data from a copy of the object. The copied object has no modifiers on it, but it does have the same topology as the original sphere and it does have the creases marked on it.
I add a Data Transfer modifier above the Subsurf modifier, but below the other modifiers. The order is important because if the Subsurf is above the Data Transfer modifier the creases will already have been calculated, so restoring the crease data after that will have no effect. We must restore data then Subsurf so the Subsurf has access to the transferred data before it does any calculations. I choose the copy of the original sphere as the Source Object, choose Edge Data as the type of data I want to transfer and specify the Subsurf Crease option as the actual data I want:

We now see that the pinching is back indicating the crease data has been successfully transferred.
There is, however, one thing to note, and that is the Solver the Boolean modifier is set to use. It's an option on the modifier and by default it's set to BMesh when the modifier is added and is the Solver type I used in this example. However, if you remove the Data Transfer modifier and change the Solver to Carve you will see that the Boolean no longer destroys the edge data, but instead destroys the vertex data:

The displace modifer is now effecting the whole mesh, meaning the Vertex Group has been modified and the pinching the crease data was creating has not been effected, whereas before, the opposite was true. I'm not quite sure why this happens or whether it's intentional, but this allows you to instead preserve the crease data and restore the vertex groups, though this time the Data Transfer modifier has to be above both the Displace modifier and the Subsurf:

(This also means the copy of the object we are transferring from needs a copy of the vertex group instead of the same crease marks.)
There doesn't seem to be a disadvantage to using one type of Solver over the other, but it does allow you to use either Solver (in case you need to use a specific Solver for other purposes) and always preserve the data.
To summarise:

BMesh Boolean Solver destroys Crease data.
Carve Boolean Solver destroys Vertex Group data.
The Data Transfer modifier has to be above any modifier that needs to use the transferred data.

I have added the Blend file so you can see the exact setup I've used (the copy of the original object is on layer 2):

Something I noticed is that in order to transfer vertex groups properly, I had to hit Generate Data layers before they came through properly. Before that, it was acting like the group existed, but with a value of 0.


text:
Bake combined normal map in cycles?
Exactly as the title says I got a texture which came with a normal map. When I try to bake out the combined end result for use with a real-time engine such as Unity I get as you see in the image below nothing as far as normal details are concerned.
I experimented, and when I plug my normal node into the displacement socket I get some results, but it looks horrible and is not the desired "normal map" effect. Any help on this would be great!

Normal Pass is generated from Face's Normal Vector
When you bake the normal map, you are converting the XYZ component of each surface's point normal vector into the correspective RGB color (according to the type of calculation: object, tangent..).
Is something that is not related with textures or shading, just geometry.
The result is correct, every point of your surface has a normal pointing out (local Z axis). That's where the blueish color is coming from (XYZ=>RGB).

What you probably are trying to bake is the Color of the Normal Map. Maybe you have combined several maps or some of them are a procedural textures converted with the bump node... what you need is to bake the Emission Pass (one of the fastes to bake you'll need just 1 sample, as with SSS Color, Glossy Color, Diffuse Color...) of an Emission shader with Strenght=1 that has the color you want in imput:

Here's an example of baking the Normal from procedural textures:

Anyway it would be cool to have a baking pass that automatically takes in account all the mix shaders nodes and returns the "final", weighted normal maps color. For now you'll have to unplug all of them and than combine them on your own.

Could you post the blend file in relation to the post you made I'm trying as you recommended, and still having some issues. My exact issue if your wondering is after I bake the "Emit" the bake result is black.

I'll build another one, that was already thrown away... You need the first or the second example?

The first example please where you use a normal map already made not the procedural one.

If it bakes black 1) Check to have an Emission shader as output 2) Check to have color in imput... so that't you have not accidentally baked (or trying to) on the texture where the color cames from and not on a new texture.

I THINK I follow you, but probably not I've been trying to grasp this normal map thing for days. http://i.imgur.com/D5oiHH1.png This is my result.

Let us continue this discussion in chat.


text:
Really weird white highlights on mesh?
Okay I don't know what I did but my mesh with just a diffuse texture looks terrible now. I could use some advice on how to fix this.
Specifically these weird white highlights.

I don't see white highlight. I see black terminator artifacts. They are Cycles limitation. You need higher poly or render in different renderer.

I figured out the issue I was having. I was using the shader provided by Quixel in there Quixel to Blender three part video series. The output I received from the software was a diffuse, normal, roughness, specular, and reflection at normal. Plugging everything in works fine, but I was plugging things up wrong, and didn't have the y channel flipped for the normal (green channel).
So essentially I just flipped the Y channel on my normal by separating the RGB using a seperate RGB node than using an invert node (for the G) than used a combine RGB node to finish it all off. The intense white was because of the roughness at normal being set wrong (my fault).
I've included pictures to show what I mean and my outcome & to also show that things are showing up as they should now.

Hard to tell from the image alone, Looks like you turned on smooth shading in your mesh.
Try adding an Edge Split modifier to the object(s)

I think I may of figured it out. I'll probably delete this. The shader I'm using has a reflection at normal channel and I must of turned it up somehow, and that is what did it.


text:
render only composite
So this may be a noob question, but I've got a video set up with nodes, and I go to render, but blender makes 2 passes, one is the scene (which had been previously used for smoke simulation but doesn't have anything in it now) and then the compositor. It slows it down a lot, and I can't find anything online about how to only render one part of the blender project, wether it be the 3D scene, the node compositor, or the VSE. Help please?

Delete the renderlayer node from the node setup, and then blender won't render the 3D scene.
If there is anything in the VSE or the compositor,  by default blender will prioritize rendering it over rendering the scene unless you explicitly disable it in the render settings:

If use nodes is enabled, then blender will only render the 3D if it's needed for the composite. (i.e. there is a renderlayer node using the scene as input)

the scene that has the nodes? or the 3D scene?

I usually attach a Viewer Node into the node setup. Then in the UV/Image Editor, open the Viewer Node and then save the file using F3.

Please add more to your answer.

Thats great, for pictures, but its an animation.

Create a new render layer and uncheck the old one. In this layer, unselect everything.

authors: Мишел Максимиляно


text:
Animating masks to create multiple wipes
So... I'm making yet another video. And I want to recreate this effect:
https://www.youtube.com/watch?v=hDiJ17Xgaw8 (its in the first 15 seconds)
So I have kinda the general idea of how to do this, which may be complete reduntant.
My thought is to have 2 planes scaled out on the x axis and y axis, and animate their location, than to put the scene into VSE or MCE, and have video #1 be in the top left, video #2 in the top right, and so on. And I think if I could somehow parent a mask to an empty that is parented to the plane, that would work.
  So my question is how do I parent a mask point to an object?
Any help GREATLY appreciated!!!
EDIT: Ok, so I'm realizing that parenting masks to an object isn't really going to work. I'm going to use objects in the 3D scene and use the alpha layer to do the masking. But I don't know how to use just the alpha in the VSE. Help?

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

When linking video content you want to reproduce, skip to the part you want (copy the url at current time). Nobody has the time to watch a 13 minute video or skip through to find what you mean.

Its at the very beginning


text:
Change pivot point without moving the current position?
So I animated some objects rotating, and the pivot point is on top. but now I want to move the pivot point to the side a bit while still being on top, but the object positions are already animated. help please?

Yes, that solved my question

These are very different questions, and people who are at a beginner lever trying to move the pivot point and get thrown on the other question which involves constraints and animation, might find it hard to get


text:
transparency texture not showing other object?
So I have a video and I have the checker texture, and have set it up so that its black and white, and then I put the color into alpha of the output node, so that I have this white and transparent dotted line. BUT, the "transparent" part of the line goes THROUGH an object right behind it.

I'm using blender internal.
help?

Make sure you are not using mask transparency. Try Z transparency instead

Yep, it sure is, solved my question


text:
Movie Editor Masking Animate change?
So I have animated a mask for video editing, and then for whatever reason, the video changed to where the video had the same frame for 2 frames. So the mask is 1 frame offset in the middle of the animation. Is there a way to fix this? Or perhaps a way to change the mask animation in nla or something?

@cegaton Mask keyframes can be adjusted in the dope sheet by changing it's mode to 'Mask'.

Thanks to both of you guys for your amazing insights! It helped a lot!


text:
animate one object into another addon?
So a few months ago, I came across an addon that would give you the ability to animate the transformation of one object to another by taking apart the faces of the 1st object, morphing them, and then positioning them into the shape of the 2nd object. But I can't seem to find it again! Does anyone know what this addon is called? any help greatly appreciated!

Was it this? http://blenderartists.org/forum/showthread.php?263719-Particle-Morphing-Tools-%28First-Part-Updated%29

Yes, I believe so. Thank you! Is there any way to download it? the zip file link just brings be to a 404 page

Hm.. This thread seems to have some info: http://www.blenderartists.org/forum/showthread.php?263719-Particle-Morphing-Tools-%28First-Part-Updated%29/page5

At the end I only have found this custom build: http://blenderartists.org/forum/showthread.php?289299-Morph-Modifier, but I can't download it.

Oh well, maybe someday it will be redone.


text:
Mask out certain objects?
I have several objects in a scene. I have a plane that is the closest object to the camera, and I want it to mask out one object while leaving the other object alone. I was using the mask transparency until I came to this problem. Any help? If it makes a difference, the objects are all animated

Can you post the .blend file? Are you doing the masking in the compositor?

related: http://blender.stackexchange.com/questions/23287/how-to-subtract-alpha-channel-from-another-alpha-channel ?

Or this one, you can use object index or material index to get just the part you want masked.

You can do this with Render Layers using the Layer Mask option.
In my example below I've created 3 objects, a plane, a monkey, and a cube. The plane is in front of both. The plane is on Layer 1, the monkey on Layer 2 and the Cube on Layer 3. There is a Render Layer set up for each object. The crucial part is that the Render Layer for the monkey has Layer 2 enabled, and also Mask Layer 1 enabled, which makes the plane mask out the monkey on this layer.
You can see in the rendered layers in the top panel, that the monkey layer is masked out, and that the cube is not masked out.

Perfect! Thats exactly what I'm looking for!

But how does one render all the layers at once?

If you've set up the Render Layers as in the screenshot, and they are all checked, they will all get rendered as separate layers when you hit the render button.

Consider animating restrict render. As in View Visible, Select, Camera Render

I do actually use that a bit, but in this case I'm looking for something that lets me mask out a part of an object, instead of just the whole object


text:
blender python plugin error
Can some one help me with my blender ftp code, It runs fine in the text edit but when it turn it into a plugin and run it there is an error with initSceneProperties(bpy.context.scene) and I can not get to run at all.
bl_info = {
    "name": "FTP Download",
    "category": "Object",
}
from ftplib import FTP
import bpy
from bpy.props import *

def initSceneProperties(scn):
    bpy.types.Scene.Ip = StringProperty(
        name = "Ip")                      # IP
    scn['Ip'] = "000.00.000.000"

    bpy.types.Scene.Uname = StringProperty(
        name = "User Name")                # user name
    scn['Uname'] = "anonymous"

    bpy.types.Scene.Pword = StringProperty(
            name = "Password")              # password
    scn['Pword'] = ""

    bpy.types.Scene.SFN = StringProperty(
                name = "Server File Name")      # server file name          =   SFN
    scn['SFN'] = "File name"

    bpy.types.Scene.SFD = StringProperty(
                name = "Server File Directory")      # server file directory     =   SFD
    scn['SFD'] = "File directory"

    bpy.types.Scene.CFN = StringProperty(
                name = "Computer File Name")      # computer file name          =   CFN
    scn['CFN'] = "File name"

    bpy.types.Scene.CFD = StringProperty(
                name = "Computer File Directory")      # computer file directory     =   CFD
    scn['CFD'] = "File directory"
    return
initSceneProperties(bpy.context.scene)

class UIPanel(bpy.types.Panel):
    bl_label = "Property panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

    def draw(self, context):

        layout = self.layout
        scn = context.scene
        layout.prop(scn, 'Ip')
        layout.prop(scn, 'Uname')
        layout.prop(scn, 'Pword')
        layout.prop(scn, 'SFN')
        layout.prop(scn, 'SFD')
        layout.prop(scn, 'CFN')
        layout.prop(scn, 'CFD')
        layout.operator("ftp.download", text='Open', icon='FILE_FOLDER')
        layout.operator("ftp.upload", text='Save', icon='FILE_TICK')

class FTPDownload(bpy.types.Operator):
    bl_idname = "ftp.download"         # unique identifier for buttons and menu items to reference.
    bl_label = "FTP download"          # display name in the interface.

    def execute(self, context):
        scn = context.scene
        #------------------------------------#
        ip = scn['Ip']
        uname = scn['Uname']
        pword = scn['Pword']

        ftp = FTP(ip)                        # login
        print("Loging into", ip)             #
        print(ftp.login(uname,pword))#
        #------------------------------------#
        sfd = scn['SFD']
        ftp.cwd(sfd)                         # Path
        filename = scn['SFN']                # Filename
        parth = scn['CFD']                   # Destination parth
        new_name = scn['CFN']                # Destination name
        #------------------------------------#
        local_filename = os.path.join(parth, new_name)
        file = open(local_filename,'wb')
        ftp.retrbinary('RETR ' + filename, file.write)
        print("Receiving file")
        print(ftp.quit())
        file.close()
        return {'FINISHED'}

class FTPUpload(bpy.types.Operator):
    bl_idname = "ftp.upload"           # unique identifier for buttons and menu items to reference.
    bl_label = "FTP upload"            # display name in the interface.
    bl_options = {'REGISTER', 'UNDO'}  # enable undo for the operator.

    def execute(self, context):
        scn = context.scene
        #------------------------------------+
        ip = scn['Ip']
        uname = scn['Uname']
        pword = scn['Pword']
        ftp = FTP(ip)                        # login
        print("Loging into", ip)             #
        print(ftp.login(uname,pword))
        #------------------------------------+
        parth = scn['CFD']                   # Path
        filename = scn['CFN']                # Filename
        new_name = scn['SFN']
        sfd = scn['SFD']
        ftp.cwd(sfd)
        #------------------------------------+
        local_filename = os.path.join(parth, filename)
        ftp.storbinary('STOR ' +new_name, open(local_filename,'rb'))
        print("Receiving file")
        print(ftp.quit())
        return {'FINISHED'}

def register():
    bpy.utils.register_module(__name__)

def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
    register()

After you define initSceneProperties() you then call the function, you need to remove that, to call the function when the addon is enabled you can add it to register(). The error you are getting is because when the addon is enabled there is no context (you are trying to use bpy.context.scene), you cannot access any of blender's data during the register process.
It would appear that you want to set a default value after you add properties to the scene class, to do this you can set the default value for the property.
bpy.types.Scene.Ip = StringProperty(name = "Ip", default="000.00.000.000")

That would lead you to the following version of your script -
bl_info = {
    "name": "FTP Download",
    "description": "Transfer files to/from an ftp server",
    "author": "Ashlin",
    "version": (1, 0),
    "blender": (2, 73, 0),
    "location": "3D View > Properties panel",
    "warning": "",
    "wiki_url": "",
    "tracker_url": "",
    "category": "Object"}

from ftplib import FTP
import bpy
from bpy.props import *

def initSceneProperties():
    # server IP address
    bpy.types.Scene.Ip = StringProperty(
        name = "Ip", default="000.000.000.000")

    # ftp user name
    bpy.types.Scene.Uname = StringProperty(
        name = "User Name", default="anonymous")

    # password
    bpy.types.Scene.Pword = StringProperty(
        name = "Password", default="")

    # server file name
    bpy.types.Scene.SFN = StringProperty(
        name = "Server File Name", default="File name")

    # server file directory
    bpy.types.Scene.SFD = StringProperty(
        name = "Server File Directory", default="File directory")

    # local file name
    bpy.types.Scene.CFN = StringProperty(
        name = "Computer File Name", default="File name")

    # local file directory
    bpy.types.Scene.CFD = StringProperty(
        name = "Computer File Directory", default="File directory")

class UIPanel(bpy.types.Panel):
    bl_label = "FTP Downloader"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

    def draw(self, context):

        layout = self.layout
        scn = context.scene
        layout.prop(scn, 'Ip')
        layout.prop(scn, 'Uname')
        layout.prop(scn, 'Pword')
        layout.prop(scn, 'SFN')
        layout.prop(scn, 'SFD')
        layout.prop(scn, 'CFN')
        layout.prop(scn, 'CFD')
        layout.operator("ftp.download", text='Open', icon='FILE_FOLDER')
        layout.operator("ftp.upload", text='Save', icon='FILE_TICK')

class FTPDownload(bpy.types.Operator):
    bl_idname = "ftp.download"         # unique identifier for buttons and menu items to reference.
    bl_label = "FTP download"          # display name in the interface.

    def execute(self, context):
        scn = context.scene
        #------------------------------------#
        ip = scn['Ip']
        uname = scn['Uname']
        pword = scn['Pword']

        ftp = FTP(ip)                        # login
        print("Loging into", ip)             #
        print(ftp.login(uname,pword))#
        #------------------------------------#
        sfd = scn['SFD']
        ftp.cwd(sfd)                         # Path
        filename = scn['SFN']                # Filename
        parth = scn['CFD']                   # Destination parth
        new_name = scn['CFN']                # Destination name
        #------------------------------------#
        local_filename = os.path.join(parth, new_name)
        file = open(local_filename,'wb')
        ftp.retrbinary('RETR ' + filename, file.write)
        print("Receiving file")
        print(ftp.quit())
        file.close()
        return {'FINISHED'}

class FTPUpload(bpy.types.Operator):
    bl_idname = "ftp.upload"           # unique identifier for buttons and menu items to reference.
    bl_label = "FTP upload"            # display name in the interface.
    bl_options = {'REGISTER', 'UNDO'}  # enable undo for the operator.

    def execute(self, context):
        scn = context.scene
        #------------------------------------+
        ip = scn['Ip']
        uname = scn['Uname']
        pword = scn['Pword']
        ftp = FTP(ip)                        # login
        print("Loging into", ip)             #
        print(ftp.login(uname,pword))
        #------------------------------------+
        parth = scn['CFD']                   # Path
        filename = scn['CFN']                # Filename
        new_name = scn['SFN']
        sfd = scn['SFD']
        ftp.cwd(sfd)
        #------------------------------------+
        local_filename = os.path.join(parth, filename)
        ftp.storbinary('STOR ' +new_name, open(local_filename,'rb'))
        print("Receiving file")
        print(ftp.quit())
        return {'FINISHED'}

def register():
    bpy.utils.register_module(__name__)
    initSceneProperties()

def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
    register()

Near the bottom of your script you have def Register(): add initSceneProperties() after the next line - match the indentation.

I suggest you spend an hour or two on an introduction python tutorial so you at least understand why the spaces are at the start of most lines.

Thank you so much, it is so hard to find help with blender python stuff.         Thank you.


text:
how to open a timeline window
There is supposed to be a timeline, but when I made my first keyframe, the keyframe timeline didn't appear.
How can I make timeline appear?

Pull upward on the hatched corner to create a new area:
Then, click on the editor type selector and choose Timeline:
You now have a timeline in the new area.

The hatched corner is sometimes not in the bottom left, but in the top right corner of the "main content" part of the screen. So if you are like me looking for it on the bottom left, look for it on the top right !

If you by accident went into full screen mode (with Shift+Space) you can hit that again to bring it back to normal interface. I couldn't find those three bars in the corner to bring up the timeline but once I exited full screen mode, it showed up (2.79 Version).


text:
Reflection is quad dependent and looks non realistic
Im rendering varous objects with a Sharp glossy effect but the reflections are quad dependent on the object (image below), meaning they behave separately within every quad making it look 8bit-like. Can anyone tell me why this happens?. (Im pretty sure subdividing would fix it but I want to know why I cant have a low poly object reflecting normaly.
The object has 2 modifiers: Subdiv Surface and Solidify. (Perhaps the Subdiv is causing it?). Help me you Blender savys I dont have a powerful CPU to test and test within every render would take me hours and hours.
Image:

Do objects have smooth shading ?

My problem was fixed making normals consist and fixing a few errors on the mesh (2 extrudes on the same place).
Smoothing seems to be working perfectly fine after that!. Thanks guys I'll select smoothing as the right answer.

It all worked together with the Smoothing, after fixing my mesh it still looked odd and it was just perfect with the smoothing.


text:
Change Blender's Preferences Dynamically
I have a bit of a tricky request. I am trying to create a dynamic script that changes Blender's user preferences based on the current selection. Basically, I want to change the user preference option, "rotate around selection" when I don't have anything selected. This means I can dynamically change between selections as I work in the viewport. I have gotten the basic functionality down, but I ran into two problems.
The first issue is that it doesn't automatically run on start up. I have tried putting it into the registered function but to no avail so I have to activate it with a keypress.
The second issue is what I am really curious about. I have looked all around but it seems the only way to continually look for input is to use a modal operation. I don't want it to affect the speed of the viewport, but i would really like to take advantage of the events in the modal operations. I don't know if there is another way to handle this, but one of the issues i have found it that it stops the script refreshing command (F8). I can turn the script off with F8 and then press the F8 shortcut again but i would really not like to do that. I was wondering if after the process is killed with F8 it can automatically call the refresh script function. I am not entirely sure how to approach this and any help would be greatly appreciated!
import bpy

    class NewPreferenceOperator(bpy.types.Operator):
        bl_idname = "object.modal_timer_operator"
        bl_label = "Modal Timer Operator"

        _timer = None

        def modal(self, context, event):
            if event.type == 'F8':
                return {'CANCELLED'}

            if event.type == 'MIDDLEMOUSE':
                selected = bpy.context.selected_objects
                if not selected:
                    bpy.context.user_preferences.view.use_rotate_around_active = False
                else:
                    bpy.context.user_preferences.view.use_rotate_around_active = True
            return {'PASS_THROUGH'}

        def execute(self, context):
            self._timer = context.window_manager.event_timer_add(0.1, context.window)
            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}

        def cancel(self, context):
            context.window_manager.event_timer_remove(self._timer)

    def register():
        bpy.utils.register_module(__name__)
        wm = bpy.context.window_manager
        km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
        kmi = km.keymap_items.new(NewPreferenceOperator.bl_idname, 'Y', 'PRESS', ctrl=False, shift=False)
        pass

    def unregister():
        bpy.utils.unregister_module(__name__)
        pass

    if __name__ == '__main__':
        register()

When registered to run on startup, it has the name of the module, in the case below ui_panel.py is a registered text.
if __name__ in ["__main__", "ui_panel"]:
    print("Running ", __name__)  # see the diff between reg or run script
    register()

The refresh (aka reload) script operator is, which IIRC is the operator called by hitting F8
bpy.ops.script.reload()

Instead of cancelling with
return {'CANCELLED'}

use
return self.cancel(context)

then append the operator call to your cancel method, (ie after removing the timer),.
My preferred way of turning on and off modals is using the update method of a boolproperty
def start(self, context):
    if self.bgl_draw_speaker:
        bpy.ops.wm.draw_speaker_vis()

bpy.types.Scene.bgl_draw_speaker = BoolProperty(update=start,
                                                name="Draw Details",
                                                description="Show BGL Visualiser")

and have if not scene.bge_draw_speaker as a way to terminate the modal op.

Thanks a lot! The script reload command is just what I needed. I am sorry to be a pain, but I can’t get the cancel method to run in the modal operator. I put a print statement into the function and found it wasn't even running before. Do you know where I could be going wrong? Also I can’t get the  ”if name” statement to run either. It just won’t execute the print the statement in the function which is leading me to believe it is not running. The strange thing is that the entire script is working fine though. I’ll continue to see if I can find the problem.

oh sorry, didn't notice, rather than return {'CANCELLED'} use return self.cancel(context). Change ui_panel to match the name of your file in the text editor, must have a .py extension, you can also just have register() without the if, if you are going to use it exclusively as a registered text script.

You have been a wonderful help in my journey to understand how to use the modal operation. I tried to use the self.cancel as you suggested and it worked running after the modal finished. The issue however, was that I could not run the Script Reload because it said the modal was still running. I have probably been a bit of a pain and your knowledge of the area has been awesome. As I was trying some different methods, I found a way to bypass the Middle Mouse click and just active the "view3d.rotate" at the end of my function. Thanks for all the help and all the best!

authors: יאיר מרקובסקי