How to create proper displacement for weld joints? I am looking for a way to create procedural weld joints in blender.

Here are some reference images showing what I am looking for:

https://www.flickr.com/photos/jimgrant/105352380

https://www.flickr.com/photos/7363531@N05/477075888

https://www.flickr.com/photos/fstorr/5440129655

The basic approach I have been taking is to create a base mesh then use a skin modifier fallowed by a subserf modifier with a bunch of displacements after that. However I am not happy with the result, I think that the displacement textures need to be different(in this case I am using two cloud textures). This is the result that I got so far:

One thing that you might notice in the reference pictures is that weld joints tend to have a beaded look to them due to how the individual drops of metal fell into the seam and overlapped each-other. I am not sure how best to replicate this with a displacement. I thought about using Metaballs but those are hard to work with and getting some kind of displacement or randomization on them would be very hard (not saying that they are not an option though).

What are you thoughts? Dose anybody know of a good way to quickly and easily create a procedural weld joint?

You said you wanted a to do this procedurally, but I personally would recommend using an image texture like this one.

This image was created by me, and is in the public domain. Use it however you want :) Click for larger size

This displacement map produced a result like this:


Animate a Bezier curve deforming a mesh, without the mesh awkwardly rotating I've successfully set up a mesh that's deformed by an animated Bezier curve, with the help of the Animation: AnimAll utility, with one caveat: the mesh rotates inelegantly about the curve as it animates, in all available "Twisting" options.  Ideally, I'd like to implement and distribute my own option with the following formula:

t = dot(v, axis)
v' = b(t) + rotationMatrixBetween(axis, b'(t)) * (v - b(t))

Where v and v' are input and output vertices, respectively, and b is the cubic Bezier curve function.  This has the effect of rotating every vertex by the same quantity that the associated Bezier tangent is rotated from the chosen axis, giving a relatively stable animation.

So the question is, is it possible to implement an additional Twisting Mode as an addon to Blender?  (Using the formula I described, ideally.)  Or, is there a better alternative to achieve what I want?  I'd like to export models consisting of simple shapes deformed by animated Bezier curves for the project I'm working on, and the formula I described is the one that I'm using.

Things I've checked or investigated:

Both the model's and curve's origin are at (0, 0, 0).
I've attempted all three twisting modes with every combination of "Bounds Clamp" and "Stretch", all with the same issue (understandably.)
Browsing the source included with the release distribution hasn't been terribly enlightening for my use case.  A full search reveals a twist_mode being set from the UI and in an import script, but not where it's used.
I could swap to a standard skinning approach as a last resort, but it's far more meticulous to create content with than what I'm wanting (which is, "ridiculously simple", Blender integration issues hopefully notwithstanding.)

UPDATE: Here's the packed blend file, as requested.

UPDATE AGAIN: browsing the actual source (now that I've found it) reveals an entirely C implementation of twisting that can't be extended without recompiling Blender (assuming bevel-handling code in curve.c handles all twisting, bevel or no.  I believe it is.)  I believe "Minimum Twist" without correction for the first point would work well enough for me, if I could change it!  Otherwise, maybe there's some way into tricking Blender to not correct for the first tangent in the curve?

It is doable as scripting, probably using to_track_quat way.

but an easier way is to use Animation Nodes ad on.
That is a visual / nodal scripting tool really.

There you have a set of spline tools to deal with bezier from creating  to extracting data in any way. More than usual Blender tools.

Specifically for this orient/twist situations, there is a Direction to rotation Node that turns 2 vectors into rotation. Unlike the Blender "Z up" to track quat , it provides a second "guide" direction that can be related to anything.
(I redesigned that node precisely for these problems)

In the example file, one orientation (Z) is the tangents, the other (Y) is controlled by the empty in the back.

-

Here's a file with a possible setup do do what you need.
spline deform AN

You need Animation Nodes to make it work.

A very basic setup, cause you can further combine or animate those too. Or, for example may deform only the points closer to spline, not the far away (as xy here) or vary the second rotation along the spline etc.


UI Update issue PropertyGroup UIList Item 'name' prop's update hook? This is hard to explain but I will try.

I have a panel UI that I use to generate a geometry but lets call it a parent group object.

I have a PropertyGroup List with a PropertyGroup for the Items so each generated object is stored in the list, so where you select the item in the list the UI in the same panel updates with the different objects properties and name that it's given. This name is the Geo's name in the Scene Property viewer as well as the name in the item in the list, which is the only thing I display there in the list.

When I rename the actual object not in my panel I have a complex solution where a watcher is monitoring for name changes and looking to update the panel.
I can simply update the item.name from the list to the new name and it is visually seen to update, but when it comes to the field that represents the name in the properties panel I can in theory update it but it doesn't change visually no update.
This is StringProperty that does not have an update function or anything like it but probably should I just don't know how to trigger it.

If I try to create a 'name' StringProperty in the List PropertyGroup it won't let me so I'm unable to assign an 'update' function.

If I create an extra property called geoName and assign an update function, then I can set it's value to the StringProperty via myProp = self.name.
I guess I'm looking for a way to assign an update function to the 'name' property that is part of a list via

listGroup = props.PointerProperty(type=ListGroup)

So the UI shows it this way

ro.template_list("ListGroup", "Group_List", listGroup, "items", listGroup, "idx")

That is a UIList that has a draw_item function

class ListGroup(bpy.types.PropertyGroup):
    idx = bpy.props.IntProperty(name="Index", description="Index for ListGroup", default=0, update=listItemSelected)
    items = bpy.props.CollectionProperty(type=ListGroupItem)
and this

class GenSourceItem(bpy.types.PropertyGroup):
    #items like StringProperty are here

is the set of properties where you can not seem to add the update function to the name property because it already exists so I can't set the field in the UI that is for creating them. The name field is also a way to edit it (which works and renames the geo and the list's name), but again if I edit the name of the object and the list updates it can't update the StringProperty in the panel without having an extra go between value I've assigned an update function to.

Said another way for clarity: since the UIList item has a 'name' and I can change/update it but I can't be notified it updated and reflect the change in the panel. How might I assign an update function to the List Items name property? or tell a StringProperty in a Panel to update. That parts wierd because I can update it somewhere in this watcher watching (continuously for what should be a geo name update event), and it seems to change it there, but I guess it must be out of the display context somehow (I guess because that geoObj name change is happening in the official Scene tree viewer)?

When defining a PropertyGroup one can define a StringProperty 'name', overwriting the internal name property.
Any interaction with the name will use this new Property.
This can be used in conjunction with a second StringProperty to create an update-hook like this:

import bpy

class Test(bpy.types.PropertyGroup):
    # there's allways "name" as a StringProperty.
    # we may overwrite it though, to add callbacks
    def _upd_name(self, context): # this will handle our update
        if self.name == self.old_name: return # abort: no change, no update
        print("changed name from '%s' to '%s'" % (self.old_name, self.name))
        for item in context.scene.test_collection:
            if item.ref == self.old_name:
                print("...updating ref in element:",item.name)
                item.ref = self.name
        self.old_name = self.name # update our old name
    # the _upd_name function must handle all callbacks.
    name : bpy.props.StringProperty(update=_upd_name) # our public name
    old_name : bpy.props.StringProperty() # helps us with our update
    # lets get a property to update
    ref : bpy.props.StringProperty()

def register():
    bpy.utils.register_class(Test) # register it and assign it
    bpy.types.Scene.test_collection = bpy.props.CollectionProperty(type=Test)
    # lets give it a test
    scn = bpy.context.scene
    A = scn.test_collection.add()
    A.old_name = A.name = "A" # setting both at the same time suppresses update.
    for n in "BCDEFGHI":
        item = scn.test_collection.add()
        item.old_name = item.name = n
        item.ref = A.name
    A.name = "A" # no real update
    A.name = "my-chosen-name" # update

if __name__=="__main__": register()

Note that this will lead to a second entry inside the rna_type.properties collection:

print(list(bpy.context.scene.test_collection[0].rna_type.properties.keys()))

Ideally we'd like to add the update function to the original item, but that seems to be impossible. Notice that you can not patch a hook to the name of objects either, as they are done internally. You'd only loose the ability to change the real name as your interface starts using the new name.


Can armature/bones be edited without edit mode? I was looking after some information about armature and bones, so I can continue my importer script. I found some nice info here; no BMesh, and simple enough for my needs as beginner, so just perfect. But while looking at the code I saw that it uses "edit mode" (line 120), what I wanted to avoid.

So my question is: can I programmatically add/manipulate bones, without edit mode? Is there any better way then in this code?

I also tried to use the "bones" collection, but I could not append/new/add items into them.

No, The armature must be in Edit mode for us to be allowed to add or remove bones. We can switch into and out of it, using bpy.ops.object.mode_set. An idiom I use a couple of times in my addon, is to store initial mode in a variable (prev_mode), then restore it when I'm finished:

prev_mode = armature.mode # save

bpy.ops.object.mode_set(mode='EDIT')
for bone in context.selected_bones:
    # do anything in edit mode
    hook_name = PRF_HOOK + bone.name
    hook = armature.data.edit_bones.new(hook_name)

bpy.ops.object.mode_set(mode='POSE')
for bone in context.selected_pose_bones:
    # do anything in pose mode
    hook = armature.pose.bones[PRF_HOOK + bone_name]
    ct_constraint = hook.constraints.new('COPY_TRANSFORMS')

bpy.ops.object.mode_set(mode=prev_mode) # restore

This way, we can access any editing mode, any number of times, without the user even notice when the script is finished.


How can i make a Glass material that doesn't need any light to shine? I'm trying to make a PNG Rain animation with Alpha Channel and then i need to import that into another software, the thing is that i created a glass material in order to give the water-drops a kind of transparent texture, and it works on the preview of the material, the thing is that it needs light (any lamp) to work, but on this case i do not want to add any light since i need it almost as a plain illumination, is it possible to make the material work without light? like an Emission material but with this glass material?

Image Reference (without the background)

Set the background material to white or light grey in enviroment.
Turn on ambient inclusion in enviroment settings.
Set film to transparent in render settings.

That said, without a directional light you won't get shadows or reflection that make it look like rain.  So you might want to add a light, use an image or movie in the background that the rain could reflect, or set up a light that only throws shadows and place it directly above your rain.

Andrew price did a great tutorial that included rain on the camera, if you have any other issues you might want to check it out on blenderguru.com


Distorted .obj Export Whenever I export a mesh, wich is just a tiny bit complex from blender to an .obj file, some parts of the mesh are ending up wierdly distorted. The only solution I found is to check "triangulate faces" at the export options.
But shouldn't it work without that?

The mesh in blender:

The mesh in Marmoset Toolbag:

Here the .blend file:
https://www.mediafire.com/folder/b8xga0wnsmwew/blender

In other programs, the same.

Any help is appriciated
Nightfox3

The problem with your mesh are Ngons; Blender can process and show them correctly but once exported you get unexpected results because they are treated in a different way by another program.

This is what model looks like:

The reason why it worked with Triangulate faces checked is because there were no Ngons any more, all them were converted to tris. You can use this way, however you won't be able to control how it will triangulate faces.

Hence I suggest to start with changed topology of the model (note: it may be a bit complex to redo for all the model, however it will save time further on):


Copying a meshes intersecting outline from the top down view I have a sliced shape that I would like to copy it's outline as it's seen from the top down view (looking straight down on it).
Example:
I have an equation that is sliced by a plane using the Intersect option of the Boolean modifier.

I then want to copy just the outline / Intersection (the "warped" egg shape circled in red) that is created when looking at it from the top down view.

I was looking at the Knife project tool but I want the projection of top down view of a slice.
I feel like I'm over thinking it.  I'm willing to try a different solution.

Via a script.
A "conic section script".
Define a plane via its global location and normal.  For example add a plane named "Plane" aligned to cut
>>> C.object
bpy.data.objects['Plane']

plane_co  Global coordinate.
>>> C.object.matrix_world.translation
Vector((0.0, 0.0, 0.0))

plane_no  Global normal. (its rotation x z axis)
>>> C.object.matrix_world.to_3x3() @ Vector((0, 0, 1))
Vector((0.8242384195327759, -0.06781885027885437, 0.5621669292449951))

Running this script will bisect the context object (with modifiers and shapekeys applied) using the plane coordinates supplied and create a new segment object.
import bpy
import bmesh
from mathutils import Matrix
from bpy import context

# cutting plane coords and normal (global)

plane_co = (0, 0, 0)
plane_no = (1, 1, 1)
project_to_ground = True

ob = context.object
# object with modifiers shapekeys applied.
bm = bmesh.new()
bm.from_object(
        ob,
        context.evaluated_depsgraph_get()
        )

bm.transform(ob.matrix_world)

bmesh.ops.bisect_plane(
        bm,
        geom=sum((bm.verts[:], bm.edges[:], bm.faces[:]), []),
        plane_no=plane_no,
        plane_co=plane_co,
        clear_inner=True,
        clear_outer=True,
        )

me = bpy.data.meshes.new(f"{ob.name}_Section")
bm.to_mesh(me)
if project_to_ground:
    me.transform(Matrix.Scale(0, 4, (0, 0, 1)))
new_ob = bpy.data.objects.new(f"{ob.data.name}_Section", me)

context.collection.objects.link(new_ob)

Related
Planetary system simulation with real orbital datas
How to extract side-view outline (e.g. top view) of a 3D object to 2D surface?


Sculpting tool is not working at all The sculpting tool is not working at all – even on the default cube on a new project. I loaded factory settings, but it is still not working. It was working a while ago, but now it's not working anymore. I might have pressed some wrong shortcut or something? Any ideas?

System Information:

Operating system: macOS Catalina 10.15.1
Graphics card: Radeon pro Vega 48 8 GB
Blender Version

To effectively use Blender's sculpting tool, you must first subdivide the object you are trying to sculpt. Sculpting moves a certain section of vertices on an object where you use the tool, so if there are no vertices to move, you cannot sculpt the object. To subdivide, go to edit mode, press 'W', and set the amount of subdivisions to be about 60 for effective sculpting.


How can I copy or duplicate several objects in one step? I am building a tenement. After I have built one course of bricks I want to duplicate them to form an adjacent course, but with a negative scale, in the X axis.
When a story has been completed I want to duplicate this collection of courses and bricks, to create several stories.

I thought that parenting the first course of bricks to an empty would let me do this but it doesn’t.

How can I do it?

I was about to answer "Array modifier", but your case may be more complex. My way to accomplish this:

I make a separate scene just for one component (e.g. a window frame to be duplicated, or in your case, one full story), and model it there.
After I'm done, I group it as one component.
Lastly, in the main scene, I instanced the group (Shift-A -> Group Instance) as many as I
needed. Each instances are free to be transformed.

Here's an example from a building I modeled, the original repeatable objects are collected in a scene for easy measurement control:

What I like about this approach, is that we can always modify the base component in its own scene, and all instances in the main scene will be updated. And unlike linked-duplicates, we can add as many object to the group as needed.


Symmetrize Along Custom Transform Orientation Can one symmetrize (eg. -X to +X after making a selection in Edit mode and pressing W - pressing Symmetrize) along a custom transform orientation? I have selected my orientation Custom, but when I symmetrize it is done according to global transform orientation.

It works fine for me. I guess it's the matter of the proper placing of the object's origin point.

You may also try mirroring with Empty. In Edit Mode select the face you want to add a custom transformation to, press Shift+Alt+Spacebar to set it. Then press Shift+Num 7 to allign the face to view. Enter Object Mode, add an Empty and check the Align to View checkbox. Add a Mirror Modifier and set the Empty as a mirror object's target. Now translate the Empty or the object along your custom transformation.


Rendered object Blender 2.74 can't be moved I have rendered an object, but cannot move it around, rotate it to see all sides of the object. Is it possible to move it?

Rendering (in Cycles) is the process of taking the 3-dimentional scene and calculating the light paths (called rays) bouncing through the scene to the camera.  The end result is a 2-dimentional picture of your scene, so you can't really rotate it and look around.  Just like you can't rotate and look around a photograph you took in real life.

See my answer here for more on how Cycles works.

In order to be able to move and look around your model in perfect real time Cycles would have to perform a separate render from every possible position and angle of the camera, which is impossible.  Here a few ways to view your rendered object from multiple angles.

1. Viewport rendering

As gladys pointed out you can enable viewport rendering.  This basically re-renders the entire viewport every time you move the view.  Viewport rendering is mainly just for viewing material tweaks and the like in real time.

You can change the amount of samples used for viewport rendering in the properties panel under the render tab > sampling rollout > samples > preview.

2. Animating the object/camera

For a final output to showcase your object you may want to create an animation of either the camera moving around the object or the object itself moving.

Animation is done by setting keyframes.  A keyframe tells Blender the state you want an object to be in at a particular frame, Blender will then interpolate the object smoothly between keyframes.  To set a keyframe go to the frame you want to keyframe and hit I and choose the property you want to animate (i.e. location, rotation, scale, etc.).

Try checking out this tutorial.

3. Baking

Baking is a way of saving what the surface of a rendered object looks like to an image texture which you can then apply to the object as a shadeless shader to make the object look like it is rendered.

Unfortunately I don't have the space here to even dip into the world of texture baking but you can check out this tutorial for starters.

One thing to consider about baking is that things like gloss and transparency/refraction do not bake well as they are dependent on the viewing angle.


Using a linked camera from another file SO I linked an animated camera from another file, however when i press Numb0 or ctrl+Numb0 the results are weird, basically from what i can tell it just like a centered camera looking face down.

Is there a way to use a linked animated camera from another file ?

I got this to work if......

I created a group out of only the camera in the linked file ("A").

In my new file ("B"), I linked in the group from ("A").

In the outliner, I expanded (drilled down into) the linked group.

Then on the child group object:

Right Clicked.
Select >> Link Group Object To Scene.
Selected the camera object in the 3D view.
Ctrl+Numpad 0


Weight painting stuck in some kind of weird mode Weight painting looks like this and I dont know how to get out of it. Weight painting functions in general dont seem to be functioning properly while it looks like this.
https://i.gyazo.com/ed8f6939c8d1e735626d1db0359ce867.png

This is a mode called Paint Mask. While in Weight Paint mode, go up and look at the top left of your 3D View, and you'll see a button with a face icon on it. You will likely find that it is activated. Turn it off to go back to normal.

The way that this mode works is that whatever faces you select while in Edit Mode will be the only faces that can receive a brush effect while in Weight Paint mode. It's very handy in this regard. A good feature, to be sure. But it can be activated by accident, and lead to frustration. If you go into Edit Mode for the object you're trying to weight paint, you will probably see that the same face that is showing up blue in the pic you provided is already selected. Even if you unselect these faces, though, you'll still need to turn off the paint mask in Weight Paint mode. If no faces are selected in Edit Mode, and the paint mask is still on in Weight Paint mode, then you won't  see any weird blue faces, but you also won't be able to paint at all.


Get Image Position in Image Editor for drawing lines with bgl I am trying to draw some guide-lines on top of my image in my image-view using bgl.

But when I draw the coordinates of my shape/line is relative to the screen/view when I actually want what I draw to always be on top of my image in the image-view.

Is there any way to extract the image position to transform my shape to always be on my image or is there any other way to do this?

So I solved this, it appears that the image editor is also like a 3d coordinate system. So I followed a tut for 3D and then just changed the view to SpaceImageEditor and instead of drawing on 'POST_PIXEL' I drew to 'POST_VIEW'.
Code:

def __init__(self):
    self.draw_handle = None
    self.draw_event = None

    self.widgets = []

def invoke(self, context, event):

    self.create_batch()

    args = (self, context)
    self.register_handlers(args, context)

    context.window_manager.modal_handler_add(self)
    return {'RUNNING_MODAL'}

def register_handlers(self, args, context):
    self.draw_handle = bpy.types.SpaceImageEditor.draw_handler_add(self.draw_callback, args,'WINDOW', 'POST_VIEW')

    self.draw_event = context.window_manager.event_timer_add(0.1, window=context.window)

def unregister_handlers(self, context):
    context.window_manager.event_timer_remove(self.draw_event)

    bpy.types.SpaceImageEditor.draw_handler_remove(self.draw_handle, 'WINDOW')

    self.draw_handle = None
    self.draw_event = None

def modal(self, context, event):
    if context.area:
        context.area.tag_redraw()

    if event.type in {'ESC'}:
        self.unregister_handlers(context)
        return {'CANCELLED'}

    return {'PASS_THROUGH'}

def finish(self):
    self.unregister_handlers(context)
    return {'FINISHED'}

def create_batch(self):

    vertices = [(0, 0.5, 0), (1, 0.5, 0)]

    self.shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
    self.batch = batch_for_shader(self.shader, 'LINE_STRIP', {'pos': vertices})

def draw_callback(self, op, context):

    self.shader.bind()
    self.shader.uniform_float('color', (1,0,0,1))
    self.batch.draw(self.shader)


Why does the apply_pose operater not work when invoked from a script? When the bpy.ops.poselib.apply_pose operator is applied from the UI it works fine, all selected bone groups get the pose applied.

Doing the same from the console or script seems to have no effect:

bpy.ops.poselib.apply_pose(0)
{'FINISHED'}

bpy.ops.poselib.apply_pose(2)
{'FINISHED'}

The full script:
It should read a control file "pose.txt" and apply poses to selected bone groups for each defined frame

import bpy

# http://www.blender.org/documentation/blender_python_api_2_69_9/bpy.ops.pose.html

target_map = { "Root" : 0,
 "Spine" : 1,
 "ArmFK.L" : 3,
 "LegIK.L" : 4,
 "Fingers.L" : 6,
 "Links.L" : 7,
 "ArmFK.R" : 20,
 "LegIK.R" : 21,
 "Fingers.R" :23,
 "Links.R" : 24 }

def get_pose_index(obj, pose_name ):
    idx = 0
    for pm in obj.pose_library.pose_markers:
        if pose_name == pm.name:
            return idx
        idx += 1
    return None

def build_layers(targets):
    layers = []
    for i in range (0, 32):
        layers.append(False)
    for t in targets:
        idx = target_map[ t ]
        if idx is not None:
            layers[idx] = True
    layers = tuple( layers )
    return layers

def apply( obj, targets, pose_name):
    idx = get_pose_index( obj, pose_name )
    if idx is None:
        print("pose %s not found." % pose_name )
    sel_layers = build_layers( targets )
    print(sel_layers)
    bpy.ops.pose.armature_layers(layers=sel_layers)
    bpy.ops.pose.select_all(action='SELECT')
    print(idx)

    bpy.ops.anim.keyframe_insert(type='BUILTIN_KSI_LocRot')

txt = bpy.data.texts["pose.txt"].as_string()
for line in txt.splitlines():
    if line.find(" ") != -1 and line.find("#") == -1:
        sframe,rig_and_poses= line.split(" ")
        rest=rig_and_poses.split(":")
        print("frame :%s" % sframe )
        obj_name=rest[0]
        poses=rest[1]
        pose_list=poses.split(",")
        bpy.context.scene.frame_set( int( sframe ))
        for assignment in pose_list:
            targets = []

            bone_group_name,pose_name=assignment.split("=")
            if bone_group_name.startswith("Hand.L"):
                targets.append("Fingers.L")
                targets.append("Links.L")
            elif bone_group_name.startswith("Hand.R"):
                targets.append("Fingers.R")
                targets.append("Links.R")
            else:
                targets.append( bone_group_name )

            obj = bpy.data.objects.get(obj_name)
            if obj == None:
                print("obj name=" + obj_name + " not found.")
                break
            print("assign obj:%s bone_group:%s, pose:%s" % (obj, bone_group_name, pose_name))
            apply(  obj, targets, pose_name)

.blend file

Updated .blend file

If an operator is called from the UI it is implicitly given a context which depends on the area the operator has been called from and contains specific information about that area.

In your case you are calling an operator from the text area which is supposed to be called from the properties area. It is given the wrong context and can not retrieve the information it needs from it.

See

How to override a context
An overview of the different contexts and their contents
Gotcha Operators

In the text context
there is only edit_text available. The global context does not contain information about the active object and the selected pose bones, neither. But the screen context does.

However here is an example how to override the context in this case:

import bpy
#get your armature
obj = bpy.data.objects['Armature']
selected_bones = [pose_bone for pose_bone in obj.pose.bones if pose_bone.bone.select]

context = {}
context['scene'] = bpy.context.scene
context['active_object'] = obj
context['selected_pose_bones'] = selected_bones

bpy.ops.poselib.apply_pose(context, pose_index=1)

This is the minimal content which is required to run the operator. It still gives warnings. Messages about window, screen, area, region not being found often can be ignored. You might pass None for these entrys to suppress the warnings.

Example: How to refer to an area in the same screen where the operator is being run from

context['window'] = context.window
context['screen'] = context.screen
for area in context.screen.areas:
    if area.type == 'PROPERTIES':
         break
context['area'] = area
context['region'] = area.regions[1]
context['space_data'] = area.spaces[0]


Quick Smoke Causing Grainy Renders I was messing around a bit with Blender 2.79, and what i found was when i was doing smoke simulations, the renders turned out really grainy with a lot of noise (kind of like scattered pixels around the smoke) in the simulation its self. I never really came across this problem till now, maybe there's something that I'm missing? I attached an image below, I hope you know what I'm talking about. :)

Thanks

Okay, so i found the problem i had if anyone interested... it had to do with my lighting. i guess for smoke simulations you cant use planes with a emmision node property. i had to use actual lamps or sun lights to avoid noise, but i still cant get it around my head how that works.

Thanks.


Build Modifier Start Delay Driven by Completion of Another Layer's Build Modifier? Is there a way to drive the start delay of a build modifier on one grease pencil layer with the completion of a build modifier on another layer?  That is, I'm looking for a method to time the start of a build modifier that is not hard coded, so that if I make timing adjustments on one layer, the start of the other layer's build will change accordingly.

You can use the length of the first layer's build modifier to drive the start delay of the second layer's build modifier.
Setup your two modifiers and their layer accordingly.

Right click into the "Frames" field of the first one, choose "Copy as New Driver", right click into the "Start Delay" field of the second one, choose "Paste Driver".
When you scrub along the time line, the second layer should start building right when the first one ends. If you change the length of the first build, the second one will get offset by the same amount.

If you want to add another offset to the second layer's build start, right click into the "Start Delay" field, choose "Edit Driver", change the driver evaluation to "Expression" instead of "Average" and write length + 10 in the field for instance if you want a delay of 10 frames.


Messed up model, quads? I think I messed up my model. I read that you have to work with quads but somewhere along the way I messed up and now I have a triangle. Is there anyway to make this triangle a quad or have I messed up my model?

The shading is messed up in the quad right next to the triangle. Is that because of the triangle?

While Lemon's answer about the shading sounds correct, and use of triangles is a subject that can be debated for hours, I thought I would add some suggestions for adjusting the topology you have.

I see two ways to quickly get rid of the triangle you have highlighted.

Add an edge loop ⎈ CtrlR that will terminate at the triangle. This adds a fourth vertex to the triangle turning it into a quad.

Split the mesh that connects the triangles on each side and add in an extra face loop which adds another triangle that you can merge into a quad. With the vertices selected press V to rip the selected vertices. You can also use ⎇ AltV to rip and fill in one step.


Add menu entry to generic right-click menu? I can't find a way to append/prepend an operator to blenders generic "right-click" menu. When looking into the source of interface_handlers.c it seems the operators of the menu itself are hard coded, furthermore I can not find any draw method in /scripts/startup/bl_ui/ folder so I guess the menu is not exposed to the API, correct?

Q: Is there any way to add an entry to the menu and ideally assign a custom value to the active property under the mouse cursor?

As of this commit, thanks to @p2or and @brecht, the bpy.ops.ui.copy_data_path_button() operator now allows to copy the full data-path of the active property under the mouse cursor to the clipboard  which can be used to assign custom values to the active property (only available in latest versions).

Simplified version of the provided example in the patch (integers only):

import bpy

class MouseCursorPropertyOperator(bpy.types.Operator):
    bl_idname = "screen.active_int_property_add"
    bl_label = "Adjust active mouse cursor integer property"
    bl_options = {'REGISTER', 'UNDO'}

    my_int = bpy.props.IntProperty(default=100)

    @classmethod
    def poll(cls, context):
        return bpy.ops.ui.copy_data_path_button.poll()

    def execute(self, context):

        # get the data path
        bpy.ops.ui.copy_data_path_button()
        path = context.window_manager.clipboard

        # get full data path
        bpy.ops.ui.copy_data_path_button(full_path=True)
        full_path = context.window_manager.clipboard

        # split path in class and property
        rna, prop = context.window_manager.clipboard.rsplit('.', 1)

        # set attribute if type is integer
        if type(eval(full_path)) is int:
            rna_eval = (eval(rna))
            value = getattr(rna_eval, prop)
            setattr(rna_eval, prop, value + self.my_int)
            self.report({"INFO"}, "{} set to {}".format(prop, value + self.my_int))
        else:
            print (type(eval(full_path)))
            self.report({"INFO"}, "{} is not an integer property".format(prop))

        return {'FINISHED'}

addon_keymaps = []

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

    # handle the keymap
    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon
    if kc:
        km = wm.keyconfigs.addon.keymaps.new(name='Screen')
        kmi = km.keymap_items.new(MouseCursorPropertyOperator.bl_idname, type='Q', value='PRESS', shift=True)
        addon_keymaps.append((km, kmi))

def unregister():

    for km, kmi in addon_keymaps:
        km.keymap_items.remove(kmi)
    addon_keymaps.clear()

    bpy.utils.unregister_class(MouseCursorPropertyOperator)

if __name__ == "__main__":
    register()

And as of this commit, thanks to @plasmasolutions you can now add an operator to the menu:

Provided example of the patch:

import bpy
from bpy.types import Header, Menu, Panel

def dump(obj, text):
    print('-'*40, text, '-'*40)
    for attr in dir(obj):
        if hasattr( obj, attr ):
            print( "obj.%s = %s" % (attr, getattr(obj, attr)))

class TestOp(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.test_op"
    bl_label = "Execute a custom action"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        if hasattr(context, 'button_pointer'):
            btn = context.button_pointer
            dump(btn, 'button_pointer')

        if hasattr(context, 'button_prop'):
            prop = context.button_prop
            dump(prop, 'button_prop')

        if hasattr(context, 'button_operator'):
            op = context.button_operator
            dump(op, 'button_operator')

        return {'FINISHED'}

# This class has to be exactly named like that to insert an entry in the right click menu
class WM_MT_button_context(Menu):
    bl_label = "Add Viddyoze Tag"

    def draw(self, context):
        pass

def menu_func(self, context):
    layout = self.layout
    layout.separator()
    layout.operator(TestOp.bl_idname)

def register():
    bpy.types.WM_MT_button_context.append(menu_func)

def unregister():
    bpy.types.WM_MT_button_context.remove(menu_func)

classes = (
    TestOp,
    WM_MT_button_context,
)

if __name__ == "__main__":
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)
    register()


Custom Render Stamp, Principled BDSF values I am trying to do a material study, and I would like to print the Principled BDSF values onto the render.

Previously I had found this:
How to show render-stamp for arbitrary values?

It had worked, but the data path I get when I right click the roughness parameter for the Principled BDSF is:
nodes["Principled BSDF"].inputs[7].default_value

That doesn't seem to work the same way.

here is the script:

import bpy

def stamp_set(scene):
    note  =   "Samples: "                     + str(scene.cycles.samples)
    note += ", Bounces, Max: "                + str(scene.cycles.max_bounces)
    note += ", roughness: "                + str(nodes["Principled BSDF"].inputs[7].default_value)
    note += ", Version: "                     + bpy.app.version_string
    scene.render.stamp_note_text = note

bpy.app.handlers.render_pre.append(stamp_set)

I also tried, cycles.nodes["Principled BSDF"].inputs[7].default_value

and

scene.nodes["Principled BSDF"].inputs[7].default_value

I get an error in the terminal that these are undefined (I think).

SO, how would I go about doing this?

thanks,

eh five

I found a solution with various references.  The big thing that helped was finding how to enter the value for a Principled BSDF parameter in the console;

bpy.data.materials['Material'].node_tree.nodes["Principled BSDF"].inputs[1].default_value = 3

Mostly from here:

Change value of material emission strength from Python console or script

The final script looks like this (input 7 is Roughness):

import bpy

def stamp_set(scene):
    note  =   "Samples: "                     + str(scene.cycles.samples)
    note += ", Bounces, Max: "                + str(scene.cycles.max_bounces)
    note += ", Roughness: "                + str(round(bpy.data.materials['Material'].node_tree.nodes["Principled BSDF"].inputs[7].default_value, 3))
    note += ", Version: "                     + bpy.app.version_string
    scene.render.stamp_note_text = note

bpy.app.handlers.render_pre.append(stamp_set)

ref:

Editing Lamp Strength with Python

Change value of sun light emission strength from Python console or script

decreasing excess precision:

How to show render-stamp for arbitrary values?

-snaok


Cycles Rendering Engine is only rendering a black screen I'm having an issue where the whole scene is set up, with maybe a few tweaks left. I have Cycles selected to render the scene. When the render is processing, instead of processing the image, it renders a black screen.

Here's the .blend file

Your ground object is set to be hidden for render.
To fix this, open an outliner window:

then click the greyed camera icon.


Poll Error -Finding the Right Context (2.8VSE) The script below is meant to add an effect like "Cross" to the active strip in the VSE..However,after adding 2 colorstrips ,selecting them (alternatively and  both together)and  on running the script,it gives the following error -

RuntimeError: Operator bpy.ops.sequencer.effect_strip_add.poll() failed, context is incorrectError:

On using the Bruteforce method here,to override the context the terminal throws new error's. TypeError: bpy_struct: item.attr = val: enum "TIMELINE" not found in (, 'VIEW_3D', 'IMAGE_EDITOR', 'NODE_EDITOR', 'SEQUENCE_EDITOR', 'CLIP_EDITOR', 'DOPESHEET_EDITOR', 'GRAPH_EDITOR', 'NLA_EDITOR', 'TEXT_EDITOR', 'CONSOLE', 'INFO', 'OUTLINER', 'PROPERTIES', 'FILE_BROWSER', 'PREFERENCES')

However ,on running the following command ,the 'TIMELINE' window opens ,as expected -

bpy.context.area.ui_type ="TIMELINE"

Please let me know, how to overide this Poll error .

import bpy

#check poll data
#all the area types except 'EMPTY' from blender.org/api/blender_python_api_current/bpy.types.Area.html#bpy.types.Area.type
types = {'VIEW_3D', 'TIMELINE', 'GRAPH_EDITOR', 'DOPESHEET_EDITOR', 'NLA_EDITOR', 'IMAGE_EDITOR', 'SEQUENCE_EDITOR', 'CLIP_EDITOR', 'TEXT_EDITOR', 'NODE_EDITOR', 'LOGIC_EDITOR', 'PROPERTIES', 'OUTLINER', 'USER_PREFERENCES', 'INFO', 'FILE_BROWSER', 'CONSOLE'}
#save the current area
area = bpy.context.area.type

#try each type
for type in types:
    #set the context
    bpy.context.area.type = type

    #print out context where operator works (change the ops below to check a different operator)
    if bpy.ops.sequencer.duplicate.poll():
        print(type)

#leave the context where it was
bpy.context.area.type = area

#Script to apply a Cross effect at the end of the selected strip
activeStrip = bpy.context.scene.sequence_editor.active_strip

aEnd =  activeStrip.frame_final_end

bpy.ops.sequencer.effect_strip_add(frame_start= aEnd, frame_end=aEnd +10, channel=1, replace_sel=True, overlap=False, type='CROSS', color=(0.0, 0.0, 0.0))

Use API Methods

Similarly to https://blender.stackexchange.com/a/101129/15543 ditch the operator completely here and use API methods.  Sequences.new_effect()

import bpy

context = bpy.context
scene = context.scene
sed = scene.sequence_editor
sequences = sed.sequences
active_strip = sed.active_strip
if active_strip:

    color_strip = sequences.new_effect("Color", 'COLOR',
           active_strip.channel - 1,
           frame_start=active_strip.frame_start,
           frame_end=active_strip.frame_final_end)

    color_strip.color = (1, 0, 0)

    cross_strip = sequences.new_effect("Cross", 'CROSS',
           active_strip.channel + 1,
           frame_start=active_strip.frame_start,
           frame_end=active_strip.frame_final_end,
           seq1=active_strip,
           seq2=color_strip)
    cross_strip.blend_type = 'CROSS'
    cross_strip.blend_alpha = 0.5


Improving AA in Cycles / Removing jaggies I am noticing quite some jaggy edges in my renders. I don't see AA options when using Cycles. Increasing the samples only seems to reduce noise.
The images show the problem areas marked. They are using different sample settings, but the edges are exactly the same.
You might have to download and zoom in to see better.
With "samples" i am referring to the samples in the properties window of the render tab (properties->render->sampling). First picture was using 24 with "square samples" checked, second one was using 300 samples.

Here is a zoomed version, 200%

Here's an example of a similar problem I'm facing at the moment.

Here the ribbed feature of the can happens to be on the boundary of pixels for every rib, this means cycles won't know which colour to make most important (that would require spatial antialiasing), it doesn't have contextual information that our brains have. This is the Moiré effect, it almost looks transparent.

But if I zoom in and render just the can at higher resolution it's obvious that the geometry is fine.

I may be wrong, but I think this is an edge case which directly relates the feature size being so close to pixels and that causes the jaggie pattern to emerge. As for extra AA, cycles does AA implicitly I think it's part of the algorithm, if it's getting it wrong there's little that can be done (without changing the geometry a little)

This may seem like a lazy answer, but it's normal to render at higher resolution than the final needed render, and sample down in post-processing to help the AA. In the case where you have features which are about the same size as a pixel (or in a pattern of every 2nd pixel), this becomes important. It's easier to sample down once you have all the right pixels than it is for Cycles to perform AA with insufficient information.

Other helpful ways to reduce jaggies are:

bevels to make the surface edges less abrupt (help guide the light)

but make sure the bevels are finer grained than the pixels used to represent them, so go for a multi-cut fillet if you can spare the geometry.

add imperfections (most surfaces are not flawless..it all contributes to realism and helps break up unwanted patterns)
softer lighting, more bounces.
The post processing tab has a Dither option to help avoid banding, worth seeing if that tames the effect a bit.
reduce the glossyness, or specular effect, it will be most noticable at the corners. that means the difference between:

and


KeenTools FaceBuilder for Blender Mac I am having trouble installing KeenTools FaceBuilder Beta for Blender on my Mac.
I am curious if anyone has been successful installing the Mac version yet?
I have installed the windows version without any issue at all and it works great.

https://keentools.io/download/facebuilder-for-blender

https://keentools.io/download/core

Thanks,
Jon

I think Blender needs either a *.py or *.zip file for add-ons. I downloaded the *.dmg, decompressed it and then I zipped it. Then i was able to install the add-on.


Prompt for saving modified images Is there a way of seeing which modified images are unsaved?
I modified one image, packed it and saved it, and it's still warning me about saving one modified image. I'd like to know which image is supposedly unsaved and if it's the one I packed (and which doesn't have an asterisk), then why is that?
Edit: I might have saved it and then packed it so that's my bad, but I'd still like to know whether I can see a list of unsaved images somewhere.

Images created in blender are not saved by default, nor are they packed in the file if they don't exist in a drive somewhere in your computer, you have to save them manually.
Unsaved images will show an asterisk on the top of the image viewer (or the UV editor)

To find unsaved images you can use the outliner.
Set it to Data API mode.

Expand the section for images.
If the image has not been saved the File Name section will be empty:

Saved images will show the path:

I'm sure that someone intelligent with coding skills, can come up with a script to automate finding which images lack a path and list them or save them...


How to get keyframe data from python? I am looking for help on how to export armatures and their animations in a custom export script.

I wish to have an animation format similar to BVH, i.e. a bunch of [Xposition Yposition Zposition] Xrotation Yrotation Zrotation for each bone for each keyframe.

Given the model (which exports fine using the bvh exporter), how does one get the keyframe data?  A long time searching the object tree of bpy has left me somewhat baffled.

A common way to get the animation data is to loop over the scene's frame range and read the matrices for every single frame. This is okay most of the time, and way easier to do than reading the F-Curve data directly (which won't include F-Curve modifiers and Drivers AFAIK).

Assume the Armature object is currently active:

import bpy

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

for f in range(sce.frame_start, sce.frame_end+1):
    sce.frame_set(f)
    print("Frame %i" % f)

    for pbone in ob.pose.bones:
        print(pbone.name, pbone.matrix) # bone in object space

bpy.types.PoseBone.matrix

You may use the utility function convert_space to avoid fancy matrix math.


After improving my animation, render time has increased drastically So I was doing the doughnut with cup of coffee scene from BlenderGuru's tutorials, when I tried rendering the animation (which was basically copied from what he did), it only took an hour maybe, but after some dedicated improvements that were made by myself, it takes half an hour to render one frame out of 160...

Of course I looked for solutions over the internet, I've tried changing sub samples and sampling options, messing around with tile rendering sizes, light paths and so on. These only saved me a couple of minutes, but it's just a simple scene or is this how it is with the life of rendering?

Just in case, when I added my own things, I wasn't even able to render anything properly, because Blender would just freeze my laptop and forced me to reboot it. So I fixed it by going to registry editor and increasing decimals for something. Maybe this is related with my slow rendering somehow?

My specifications:

Processor - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz 260GHz;
RAM - 8.00 GB (during rendering, it only uses ~500 MB);
The program is installed on SSD disc;
Windows 10 Home 64 bit (version 1809);
GPU - NVIDIA GeForce GTX 1650 6 GB.

My render image:

here you can find a way to check what area of the screen takes more to render:
https://blenderartists.org/t/any-way-to-generate-a-render-time-heatmap/1161497

Render layers node is used in combination with Color ramp to show the longer pixels to render.

Another way to check what is slowing down your render is to disable all objects and re-enable one by one and check render time (and eventually crashed too).


What is the best Blender Python API reference? I keep happening across information that seems blatantly wrong, and it makes me wonder if error messages are terrible or if it's the documentation.  Here's an example:

However, while the script runs you may want to access the updated values.
This can be done by calling bpy.types.Scene.update after modifying values which recalculates all data that is tagged to be updated.

This is quoted from the "Gotchas" page.
Upon following that advice...

AttributeError: type object 'Scene' has no attribute 'update'

Just to be clear, the documentation authors seem pretty convinced that it does.
Most of the bad information I've found so far comes from forum posts some place where a user just guessed at how to do something off the top of their head.  However, the official docs aren't really helpful for practical tasks, and seem to have bad information lurking about as well.

The types module is only used for documentation.
See this page for tips on finding actual datapaths.

Make sure you are using the latest API documentation too, see Where can the latest API documentation be found?


Archipack autohole not working with Archipack walls? As per title: I'm placing a door in a wall, and the hole is not being generated.
I've read there should be a "autohole" option, but I can't find it anywhere.
Blender 2.91.1.

The door hasn't been created the right way.
There is a panel CREATE under the ARCHIPACK tab on the TOOL panel. One must create doors and windows using that tab, not by adding an Archipack mesh as a mesh.


Cycling through colours over time In blender is there any way to cycle through colours in an image. For example here is an image with 4 distinct sections of different colours.

How could a setup be made so that it recognises red in the top left? Now the red is at 0% on the color ramp so over 10 seconds it would cycle through the colour ramp until it got to 100%. Then in the next section, it would recognise the green is roughly at 66% of the way through the colour ramp. So over 10 seconds it would cycle from 66% to 100% and then from 0% to 66% of the colour ramp so it returns to its initial colour at the end of the animation. And so on for the other sections.

Also, as the white and black have the values rgb(255, 255, 255) and rgb(0, 0, 0) they should not be affected.

I tried using RGB curves connected to the picture and keyframes to achieve this effect, however, it proved unsuccessful.

You can animate the hue. Here's a setup I used some time ago. The hue is cyclic, and often represented by 0° to 360° on a circle, but in Blender it is represented by a value between 0 and 1. Greyscale values, including black and white, will not change by this, because they are completely desaturated.
Further explanations of HSL and HSV on Wikipedia

The Separate HSV and Combine HSV nodes separates a colour into Hue, Saturation and Value and combines Hue, Saturation and Value into a colour. They are located under Converter in the Add menu.

Modulo makes sure the hue never goes above 1. It's a Math node, also located under Converter. However, it doesn't prevent values from becoming negative (specifically, it keeps the value between -1 and 1). The Less Than node (also a Math node) followed by the Add node take care of that, by adding 1 if the value gets below 0. The reason I do not simply select Clamp in the first Add node, is that that would make the cycling stop at 0 if the value became negative and at 1 if the value became greater than one.

Now, animate the value marked with a red rectangle.

Here's a .blend, but I stripped it of the texture I used for the gif above.

UPDATE: The above will make the cycling linear in the positive direction on the hue circle. To make it go the other way, change the first Add node to Subtract. And below is a setup to get more control, for example to make the cycling go back and forth or non-linearly.

The Value node is the one to animate in this case. It's available under Input in the Add menu. The RGB to BW node (available under Converter) isn't strictly necessary; I just added it for clarity, though plugging an RGB into a single value socket, does this conversion automatically.

The output from the ColorRamp node is what gets added to or subtracted from the hue, so by tweaking it, you can make the cycling happen virtually any way you please.

Updated .blend


How to make a logo cycle (or loop) on top of a clip in movie editing mode? I would like to create in the movie editing layout a cyclic moving logo over a video, for instance a spinning globe.

I know how to make a static logo:

check the dimensions of the movie clip
create an empty image with same dimensions with transparent background in gimp, add a logo and export as png file.
add movie clip and image with logo onto different channels in movie editing mode of Blender with the image being on top of the movie clip.
choose "back drop" in the properties window of the image to the right.
expand the image to the length of the movie-clip

How to change the steps in order to achieve a cyclic moving logo ?

Seems like there is no option to make an image sequence loop in within the VSE.

A workaround is loading your image sequence in the compositor, making sure you have the cyclic option enabled:
(in this example is an image sequence of 11 frames with alpha channel)

Then add a Scene strip to the VSE, make it alpha over, and disable OpenGL preview in the Scene Preview/Render, so you get the image sequence from the compositor. The 11 frames will play repeatedly the duration of the scene strip.


How do you keep another object's outline visible at all times while working on another object's mesh that is directly above the other objects mesh? As the title and pictures explain. How would we do this? :)
Thanks

go in the filter at the top of the window and create a selection restriction and then restrict the object you don't want to select and then you can see the outlines of both the objects but you can select only the objects that have the selection unrestricted |
the filter option -


merge objects for 3d printing I have several objects (see the attached picture) I want to merge, so that I finally get one uniformly mesh.

In the end I want to 3d print this object but the slicer software for the printer can´t handle these several loose objects. It preferes one single, clean mesh without non manifold edges.

I already tried using the Boolean modifier to join the objects but it ended in a mess with lots of non manifold edges.

Here a link to the .blend file i created.

Does someone have expierience with joining mulitiple objects into one single? Slowly I´m really annoyed from this problem and would be really pleased if someone could help me out with an solution for this.

Typing Ctrl+J should work. It is a shortcut that joins meshes. If there are any modifiers that are not applied yet, apply them then hit Ctrl+J.


Dissolve lonely vertices. Blender 2.8 I want to dissolve every vertex which does not connected with another vertex ( vertex which has no connection with any vertex ). How can i do that.

In edit mode Select all of the geometry a. Choose Mesh > Clean Up > Delete Loose


Selecting all objects that have been specified in Modifiers Could anyone help in making a script for selecting all objects that are specified in the different modifiers that an object has stacked? For example if my object has a Boolean modifier and an Array modifier, which both refer to an empty or another object (in the Array modifier there is for example an Object offset you can specify). Would it be possible to select all those object with one click? Thanks.

Using the bl_rna.properties collection.  This gives the name, type and other properties of the properties of the modifier. If the property is an object it is most likely, both a PointerProperty (prop.type == 'POINTER') and points to a prop.fixed_type of bpy.types.Object.  If so getattr(modifier, propertyname) will be either the object if set, or None if not.
import bpy
context = bpy.context
obj = context.object
for m in obj.modifiers:
    print("modifier (%s): %s" % (m.type, m.name))
    for k, v in m.bl_rna.properties.items():
        if v.type == 'POINTER' and v.fixed_type.name == "Object":
            print("\t", k, getattr(m, k))
            # select mod obj if not None
            ob = getattr(m, k, None)
            if ob is not None:
                ob.select_set(True)


Save file inside an operator I have written a simple operator to save the current blender file, but when the operator reaches the save function I get an error. I used the bpy.ops.save_as_mainfile() function for saving a scene, but I don't know if it's the right one to choose.

The console outputs this error:

TypeError: 'BPyOpsSubMod' object is not callable
location: /opt/blender/2.70/scripts/modules/bpy/ops.py:188

Does that mean I cannot call functions from bpy.ops?

My script is the the following:

import bpy
class SaveOperator(bpy.types.Operator):
    bl_idname = "object.save_op"
    bl_label = "Save scene"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):

        # build file name stuff
        # ...

        bpy.ops.save_as_mainfile('~/' + new_file_name)

        return {'FINISHED'}

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

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

if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.save_op()

You have to pass your parameters as keyword arguments. See api docs

The correct call should be bpy.ops.wm.save_as_mainfile(filepath=your_path)


How to make a perforated plate? I've been using blender for a few months now, but I'm new to this community. I need to design a circular plate with a pattern of round holes. Here is the plate I need to make, and the pattern.

I made a bunch of Bezier Circles and tried to Knife Project them into the plate, but that obviously didn't work (blender kept freezing and crashing). So, is there any way I can do that?

For best results you can either combine curve circles in 2D mode, then keep it as a curve object and extrude/bevel as needed OR you can create a mesh plate circle and a group of mesh cylinders and use the boolean modifier. You won't get subsurf on the inner holes this way but it's better if the plate has to be a mesh.

Option 1 - Joined Curves in 2D Mode

Create the small holes as bezier curves as well as the large plate circle. Make sure all are in 2D mode, and then select all, including the large cirlce and press CTRL J to combine them all into one Curve object. Because you are in 2D mode the inner circles will cut out the the outer plate circle. Then you can extrude the curve and add a bevel. Keeping it in Curve mode will give you the best smoothness on the inside of the hole cutouts. If you convert back to mesh, you won't have the same level of smoothness, and adding subsurf will introduce shading errors.

Option 2 - Cylinder Group with Boolean Modifier

Create a Mesh Circle for the plate. You can extrude/bevel/subsurf it to get it looking right.
Then take your group of bezier circles, join them together into one object (we'll call it "Tubes").
Reduce the curve resolution (Preview and Render) to the lowest possible while still maintaining a circular shape (2 or 3 usually works, we need lowest geometry possible and will regain our smooth curve with subsurf later on)
Make sure the Tubes curve object is in 3D mode (this is to avoid creating caps in the mesh cylinders) and then convert the Tubes object to mesh with ALTC
In Edit Mode extrude the circles vertically so that they will be greater than the thickness of your plate mesh.
Add a Boolean modifier to the Plate mesh and select the Tubes object as the target object. Select Difference as the mode. Then set viewport and render visiblitiy of  the Tubes object to off in the Outline. You'll see perfectly cut holes in your plate object. (Note: you control the smoothness of the holes with subsurf on the Tubes object)
In order to hide some viewport surface errors, select the Plate object, go to Object Data toolset, in the Normals panel, check the Autosmooth options, and change the Angle to 30 degrees.  You should now have perfectly smooth surface with smooth holes cut through.


fill in hole following curve I have made a panel for my car dash to 3d print. The problem is at some point I cut out a large hole with a boolean operation so I could test the part easier and save time and plastic.

The file is located at

https://dl.dropboxusercontent.com/u/189370/problem.blend

and the image is

Is there any way to fill this hole keep the front contour of the part ?

Thanks

If I got what you ask, in this particular case should be easy:

After activating vertex snapping, select the side profile (which still has the right vertical curvature), and extrude that vertex edge snapping to horizontal edge (which still has horizontal curvature), and in the end you'll cover the entire missing panel.

Like this:

If you still have original shapes, though, you could also use booleans twice: the first as you did, as "difference", to cut the hole, and another one as "intersect", to get the cut panel as indipendent shape.

edit:

Since you like learning new tricks, I'll add another one here below, although I couldn't use it in your specific case, probably due to the specific topology you had in that file.

Here's the trick: if you have a "missing" surface, similar to what you had:

you can sometimes "reconstruct" it using the "grid fill" tool, like this:

which is way more elegant than manually reconstruct it... good to know, I think.


Camera flips 180 degrees following the path I am new to blender and I tried to animate a camera path following this tutorial:
https://www.youtube.com/watch?v=vasfFsxCsAE
The author creates a NurbsPath for camera to follow and an empty to specify the focal point. However, things don't go to plan for me. First, after inserting the path and making the camera follow it, I use Ctrl + A to apply location, rot and scale, as recommended at 6:33, but I get a "Objects have no data to transform" message. I don't know which effect it will have on the animation, but it doesn't seem good.
Also, during the animation the camera is often diagonal to the ground, I also tried to use Twisting->Z-up for the NurbsPath as suggested at 5:50, which doesn't have the effect I expected, the camera still stays diagonal. Then I tried to add "Limit rotation" constraint to the camera. Now it stays parallel to ground plane, but instead flips 180 half way through the path and then flips back.
Additionally, when I add an empty, move it to the point I want and do Ctrl + A to apply the location as suggested at 7:07 my empty actually moves to a different location, which doesn't happen in the video. So it looks like something is wrong with my coordinate system.
Could anyone help me to resolve these issues?
The file is here, I got the model from blendswap.com, it is made by aXel.

Nice car, that's my favourite one... so applying scale of the curve doesn't helps.

That was just a guess, I already thought that my idea wont work....

So well, your curve flows like that: sometimes the curve is over the handles and sometimes under them. On the place were the cam switches, the curve is at two places over the handles (so like Adrian Monk would Say it's not perfectly symmetric...) I checked with the fishbones the directions of your curve, but it looked okay...

Sometimes I'm a bit confusing, sorry for that!


Where is the rendering mode in 2.8? I can't find the option where you can see the 3dviewport as the rendered version. Here's the mode I mean: https://ibb.co/GQtHM9L, the left side of the screen.

Shortcut from 2.7x was changed from Shift+Z to switch between Rendered <> Current mode.

In 2.80 press Z on your keyboard to bring Shading Pie Menu and choose desired mode.


Set dimensions of a mesh I've set "Meters" as the unit I want to use, with a 1.0000 scale, which means that every square on the grid is 1 meter, right?
Now, I want to set a cube to be exactly 1.5m tall (for example), how do I do that?

I tried to set the scale in the "scale" section in the object tab, but there's a problem.

This is with scale set to 1 on every direction:

You see, it takes up 2 squares on the grid for each side. I mean, look at the top side, it takes up 2 squares. If every square is 1 meter, it means that the top side is 2 meters long, right?
If I want it to be 1 meter long I have to se the scale to 0.5, like this:

The point is... I've set the scale to 1.0000, as I said, so 1 should be 1 meter...
Did I miss something or this is right?

That's correct.

The scale is an arbitrary number which is used to offset the size of the mesh from it's original state. It doesn't refer to the actual size of the mesh, just how much bigger or smaller it is.

I think you are looking for the dimensions values in the properties region:

Setting the dimensions will set the scale values to the appropriate value to make the mesh a certain size, e.g. 2.5m tall:


I pressed something, and my object went curved I was modeling an object, using the Maya keyboard layout, and as I was pressing Alt+2 to move the camera, my finger slipped, and the object went... strange. I've observed this effect before, but I can't remember what it's called or how to (un)do it. The shape deformed, rounded off, and really annoying. What did I do, and how can I fix this?

Before:

After:

You most likely added a sub-surface modifier on your object. You can do this by pressing

Ctrl+1 throughCtrl+5, adding a sub-division surface with the respective amount of divisions.

Because you were pressing Alt+2 before it happened, your finger probably landed on Ctrl when it slipped.

In your second screenshot, you do not have your object selected, so the modifier would not display. in the modifiers panel

You can remove it by going to the modifiers panel and deleting the modifier.


Scaling a Soft Body object I've seen abstract animations around the internet, in which bubbles grow in size within a closed area and get squished against each other and the walls in a realistic way.

At 11 and 15 seconds there are similar examples of what I'm trying to achieve.

Trying to get familiar with Soft Bodies, I decided to try to reproduce this as a little exercise, however, I cannot seem to keyframe the Scale on a soft body: when I try to keyframe a scale on the objects it doesn't do anything.

It doesn't matter whether they fall or not during the animation (as long as they stay within the box), I was trying to get them to inflate and get squished with the other objects in the scene.

Here's the file:

Unless you're using the soft body 'goal', changes to the original mesh will not affect the soft body simulation. Many of the other potentially useful parameters (such as Edge Length) are 'locked in' at the start of the simulation and changes similarly do not affect the simulation.

However, one way of achieving the desired effect is to use the Self Collision settings to exert a force within each 'bubble' to push it outwards, causing it to expand.

To achieve this, enable Self Collision and set the Ball Size to a suitably high value. This will simulate a collision ball around each vertex of the specified size, pushing each other vertex away. Set the Stiffness to a low value - this is the 'force' that each vertex is pushed away from its close neighbors. Reduce the Edge Pull to remove any force opposing the Self Collision 'push' and increase the Bending spring if necessary to prevent the bubble from collapsing. You should now find that each bubble expands to fit the available space.

Don't forget to add Collision to each bubble to prevent it from intersecting with the other bubbles and also set the Error Limit to a small value to improve the simulation.

This can produce the following result :


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.

[

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


I get single image instead of animation I have a simple scene in Blender 2.8 where there is only one object moving. It's a .png file with default rigid body settings. I'm trying to save this as a video but when I select AVI JPG as an output format:

instead of getting multiple frames rendered and saved I get the same result as if I had .png as an output format - only one frame is rendered and then nothing happens...

Does anyone know what settings should I change to save it as a video?


Make eevee shadows darker? Ok I’m trying to get darker, noticeable shadows in eevee, yet I’m barely getting anything, even with contact shadows on:

What can I change?

You can actually darken the shadow using a light path node.With or without HDRI lights..
You can adjust the darkness by increasing or decreasing the brightness value.... I don't know is there any better way to do this,but this will do the job!


How to keep two separate UV maps when merging two objects into one? I wondered how to keep two UV separate UV maps when merging two objects into one (CRTL+J)?
Currently I have blender 2.80.
I have two separate objects (in this case a turtle and a catapult from a game).
I would like to merge them both and let each keep it's own UV map.
In blender this seems alright before merging. However, after merging they
are converted into 1 wrong UV map. The turtle's UV map is degraded into a single pixel in the lower left of the UV map, resulting in a mono-colored animal.
The catapult has it's texture from in game, so I cannot supply it (but you can see it in the object).
Link for Blender file with objects:
https://www.dropbox.com/s/jvj2oafghnmll57/CataToSend.blend?dl=0
Link for JPEG turtle texture: https://www.dropbox.com/s/9a5yiftua1v1jek/20446_Sea_Turtle_diff.jpg.001.jpg?dl=0

On each object, prior to merging, give it an additional UV map with the name of the other object's UV map.  After merging the objects, it will merge these individual UV maps.  Although note that when you create an additional UV map, it will have the same UV values as the selected UV map, so you might want to do whatever you want to these-- there's no such thing as being unmapped in some map, that just means UV 0,0.


How to write Bangla in Blender? I was trying to write something in Blender in Bangla(Local Language in Bangladesh) but unable to write bangla.. Then I googled the problem and found that a similar post has been posted almost 7/8 years ago but it was about writing arabic but that technique didn't worked out for me. I also tried importing bangla font in Blender thinking it might help fix the issue but it didn't fixed the issue..
Is there anyone who knows how to write Bangla or if not is there any way I can tell the Blender Devs to fix this issue.. If you're Blender Dev and reading this post Please fix this issue.

Actually, it's possible to use Bangla characters but, alas, not all of them. If you don't need যুক্ত বর্ণ। you add text go to edit mode and delete. Then you copy the text you want to use and paste it into the blender and, at the fonts tab, add a custom Bangla font. You will see it is working. You will see what you want to see...


Get smooth and slow 25fps video from 50fps footage I have shot a few clips using a Panasonic LX100 at 50p Full HD.

I created a project in Blender 2.77 and am trying to slow down some of these strips to get a dramatic, smooth and stable effect, so I applied a speed control effect strip (speed factor: 1, multiply speed: 0.5) to them and the slowdown is previewed fine in the viewport (it seems to me, although my computer is not powerful enough to preview all frames).

When I render the project however (with an output frame rate of 25fps and "100 old / 100 new" time remapping settings), I can distinctly see that the playback of the strips I slowed down is jagged, ie. I see the distinct frames coming up, no smooth playback. The speed is fine but playback fps seem to be half of 25 fps.

How can I achieve a smooth slow-motion effect? I have double the needed frames (source footage 50p) so it should work to output slow and smooth 25fps video, right?

After some research, and the help of the people who commented and answered my question, I now understand that Blender handles output frame rates differently to the way it is done in commercial video editing programs (ie. Power Direcotr, Adobe Premiere Elements).

When the output frame rate does not match (ie. is smaller or higher) the footage's input rate, the result is either a slowed down or a sped up video.

It might seem obvious to Blender aficionados but wasn't to me as a newcomer, who was used to video editing programs that preserved the original speed of the video, whatever the chosen output frame rate.

So there are two ways to slow down a video: simply lower the output frame rate or skip frames with the frame step (thanks @Edgel3D). Both work but I recommend using the frame rate as it results in an exact frame rate (using frame step resulted in a video with 25.0499 fps). However both also affect the entire video, and individual sequences thus need to be adjusted singly using a speed effect.

In my case, I was already unknowingly slowing down the video as my output frame rate was halved (I had muted audio), and additionally slowing it down with the 0.5x speed effect, resulting in a jerky output video.


Setting exact scale/dimension on multiple objects as a whole Is it possible to select multiple objects and apply an exact uniform scaling on them using the Numbers panel? Alternatively, is it possible to set the transform location and dimensions of the selected objects as a whole without having to combine them?

For the first part of your questions, it is possible to set transforms on multiple objects: Select the objects, and hold down the Alt key when clicking on a channel in the transforms panel. Enter your desired value. As soon as you hit Enter this value gets applied on all selected objects. You'll need to repeat this channel by channel. This by the way works in many areas of Blender already, not only on transform channels.

To set the origin of all objects to one specific location you can set the Cursor to the desired location first, and then use Ctrl+Shift+Alt+C, which gives you this menu here:

Setting the dimensions as a whole: I assume you want to define the size of the 'bounding box' of a bunch of selected objects, so the selection kind of fits into a box which dimensions you want to define numerically. This is afaik only possible if you really join the meshes together. The dirty hack would be to drop in a cube, set its dimensions to your desired target values, set the 3D cursor as the scaling center, align the bottom of this cube to the bottom of your objects to scale, snap the cursor to the center of one of the cube's faces, and scale the selection up manually until it fills the volume. Not really fast, but doable.


Physically correct water material I'm making some water effects currently, but I'm running into a persistent question—what exactly would be the material setups, index of refraction, etc., to get truly physically correct water—be it fresh, salty, or otherwise polluted?

That's a big question. I don't have a complete answer, but I can answer for some parameters. I've made this answer a Community Wiki, so maybe others can fill in more.

Index of Refraction

The index of refraction (IOR) of Water doesn't vary much. It's approximately 1.333. This scubageek article references a table from "L. W. Tilton and J. K. Taylor, J. Res. Nat. Bur. Stand., 20, 419 (RP1085) 1938.":

Table 1: Index of refraction of water as a
function of wave length and water temperature.
----------------------------------------------
  Wave Length
   (Angstroms)   T=10 C   T=20 C   T=30 C

      7065      1.3307   1.3300   1.3290
      5893      1.3337   1.3330   1.3319
      5016      1.3371   1.3364   1.3353
      4047      1.3435   1.3427   1.3417

It also references a table from "E. Dorsey, "Properties of Ordinary Water-Substance", (Reinhold Publishing Corporation 1940)." to show that the Index of Refraction doesn't change too much based on salinity. In the table below, they refer to the index of refraction as n(w):

Table 2. Changes in index of refraction due to salinity
--------------------------------------------------------
salinity
(gm/kg)     increase in n(w)          example
--------------------------------------------------------
   5            0.00097           northern Baltic Sea
  10            0.00194
  15            0.00290
  20            0.00386           bight of Biafra
  25            0.00482
  30            0.00577
  35            0.00673           Atlantic surface
  40            0.00769           northern Red Sea

Since our base value is ~1.33, an increase of 0.007 is a relatively small change. I suspect it would be noticeable if high-salinity water was in the process of mixing with low-salinity water, but it's probably too small to notice a difference if all the water has the same salinity.

Scattering

The appearance of an underwater environment is significantly affected by how light reflects off tiny particles in the water. Light tends to hit these particles and scatter off in different directions. If light scattered evenly in all directions, that would be referred to as isotropic scattering. However, light in water doesn't scatter evenly in all directions, so the term for that is anisotropic scattering.

Principled Volume Shaders, added in Blender 2.80, use Henyey-Greenstein scattering anisotropy. The Henyey-Greenstein function basically describes what proportion of light goes in each direction. It gives you a parameter you can adjust to make it kinda match different materials. -1 would be back-scattering, 0 would be isotropic scattering, and 1 would be forward scattering. As oceanoptics describes, the Henyey-Greenstein is an imperfect approximation for water scattering, especially at very large or very small angles, but a value of 0.924 looks reasonable.

This does vary based on what's in the water. There's also a question as to what color this should be.

Absorption

I'm not sure how to translate this into density / color, but this graph from p.454 of "Optical propagation in linear media: atmospheric gases and particles, solid-state components, and water" (2006) by Michael E. Thomas on light penetration of seawater illustrates the absorption of various wavelengths of light. It can be handy to view with a map of wavelength to color beside it, so I grabbed a copy of the Linear Visible Spectrum from Wikipedia.


Strange black shading. Cannot fully light mesh. (Cycles) Here is the viewport in material view.  The node setup is just a PNG texture into a diffuse shader.

And this is in rendered view.  I've tried using environmental lighting as well as a directional light, and while the lit parts become brighter/washed out, the darker parts stay dark.

Normals are correct and there is no z-fighting.  Ambient Occlusion is not enabled.  Changing to Flat shading makes it worse.

Here's the .blend

Update:  Any modifier that alters the mesh (bevel, subdivide, etc) make the problem go away instantly.

You have Custom Split Normals Data added to the geometry, to fix this, while selecting the object, go to Data Tab in Properties Panel, scroll to find Geometry Data, and click Clear Custom Split Normals Data.

More information about this issue Here


Indent an object using an image I want to make a custom dice set with the theme Darksiders

This is the image I would like to be on the d20 dice on the 20 side. however I do not know how to put the mark into the d20 Model.
I know how to put in numbers into the dice and I tried to make a dent in it with a smaller simple cube and it worked fine but not when I try with this Darksider mark. i even tried a more simpler version of the image but not even that worked. the result was either nothing, or a wierd and inconsistent texture into the dice model
I would be really happy if someone could help me with this.
thank you in advance!

You need to use the DISPLACE modifier on the plane you want the SHAPE of the image.
You'll mesh will need a lot of geometry to be able to show the shape of your image.

For a detailed explanation on the setup read:
Displace Modifier on an object


Where is that new retopo feature? I heard/saw there is a retopo engine in blender now. Is this true? I cannot seem to find it, and the google results I get are either old stuff (I'm already using magnet/snap) or a marketed plugin.

Did I miss something?

Several options available. You can take a look at the Instant Field Aligned Meshes for remeshing (http://igl.ethz.ch/projects/instant-meshes/), Mira and Mifth Tools (http://blenderartists.org/forum/showthread.php?366107-MiraTools) and there is the Iceking Tools.

I have the paid addon that you are referring to, retopoflow, and it is worth it - but if you search online you will find the github page as well anyway since it is GPL if you want to try that, too.


How to use drivers in order to allow a rotation of an object in the x axis to be mirrored as a rotation in the y axis? Is there anyway to make an object rotate for the same value in the z axis when the y axis rotation is changed. It is to rotate the door as attached, as it needs to rotate at an angle.

Hover on the y rot value, right click and choose "copy as new driver", then hover on the z rot value and right click "paste driver".
Then you can choose "edit driver" to change the math if needed.
Remember that thoose values ar local, and it's a good habit to apply (Ctrl A) rot and scale to any object before starting animations and simulations.


What are the advantages of turning on "cache BVH"? What are the advantages of turning on cache BVH for a cycles render?

Not sure how to elaborate. I'm not necessarily looking for a technical description, just a better idea for when to use it, and when it's not worth the disk space.

From the 2.62 release notes -

  For renders where only the camera or materials are changing, while meshes stay fixed, it is now possible to skip the sometimes slow BVH step, by enabling BVH Cache in the Performance panel. This will store the BVH on disk for subsequent (animation) renders of the same scene. Note that if the scene does change in the animation, enabling this option will make rendering somewhat slower.

Times when it will help -

Test rendering one frame while you adjust materials.
A camera flying through a static scene

Times when it will not help -

Any mesh changes during an animation (shapekeys or armature)
Any object movement during an animation


How to view image in solid mode in 2.8 Hello I have an image I am trying to use as a reference, but it only appears as a solid color in solid mode and only shows the actual image in render or lookdev. How do I make the image visible in solid mode where I do all of the modeling?

I already have it in front and have tried dragging the clip threshold up and down to no avail so I'm stuck.

I actually just figured it out. Go to the shading dropdown to the right of all the shaders then select texture as the color.


Set matrix rotation value (not add to it) The below code will rotate a selection of objects around an arbitrary location (using the active object's location here) by the chosen angle (45 in this example). I cobbled this code together from a few places but I don't fully understand how to manipulate matrices very well yet.

If you create a few objects and press run script you'll see 45 degrees is added to the objects while transforming them around the active object. This is almost exactly what I need minus one issue. I need this code to set the rotation value to 45 (or whatever arbitrary value) when the script is run not add 45 degrees to the selection of object's matrices.

import bpy
from math import radians
from mathutils import Matrix

ob = bpy.context.object
rot_point = ob.location
rot_angle = 45
rot_axis = 'Y'

mat = (Matrix.Translation(rot_point) *
       Matrix.Rotation(radians(rot_angle), 4, rot_axis) *
       Matrix.Translation(-rot_point))

for obj in bpy.context.selected_objects:
    obj.matrix_world = mat * obj.matrix_world

EDIT: If you create a few random objects, select them and then run the script, each time you run the script 45 degrees (45 degrees is an arbitrary value, it means nothing, just a random input value for this example) will be added to the object rotation values (as displayed in the clip below). This is good, and I need the objects to move like they're moving. Ultimately the value controlled by rot_angle will be fed into from mouse coordinates in a modal though, so I don't need the code to add the rot_angle value to these object's values, I need to be able to set them. Ultimately, the code should rotate the objects around whatever chosen rot_point in the manner displayed below, however once rotated, pressing run script shouldn't do anything. As the code stands, when fed into a modal it breaks everything because the code continually adds to the values with the mouse movement instead of setting them.

UPDATE: The below code sort of does what I want. The problem is it starts breaking down once the object gets rotated in to many ways. If I could subtract the rotation matrix values to get the same results for the rotation angle difference (ra_dif) instead of comparing against the Euler rotation value of the object, I'm guessing it would work better. How could I do that? Or does someone see a better (less dense) way of accomplishing what I'm trying to do here?

import bpy
from math import radians,degrees
from mathutils import Matrix

ob = bpy.context.object
rot_point = bpy.context.scene.cursor_location
rot_angle = 45
rot_axis = 'Y'

ra_dif = rot_angle - round(degrees(ob.rotation_euler.y))

mat = (Matrix.Translation(rot_point) *
       Matrix.Rotation(radians(ra_dif), 4, rot_axis) *
       Matrix.Translation(-rot_point))

for obj in bpy.context.selected_objects:
    obj.matrix_world = mat * obj.matrix_world

UPDATE 2: The code posted by batFINGER works great with one issue. Seems to be some strange sliding going on when objects have been rotated by a few odd degrees. If you open up the following file, press Run Script, then press space and access "Custom Rotate" then immediately press Z to enter global rotation, you'll notice the selected objects will slide if you pull the mouse in towards the pivot point of the rotation. What could be causing this? How could it be corrected?

Similarly to the answer to Convert mouse movement into rotation value (not in bge), customized to make the all selected objects rotate about the active object.

Need to subtract the pivot point of the rotation, which gives the "pivot arm" vector for the rotation.  In the previous answer, where just the active object was being rotated it had been hard coded to (0, 0, 0), since that is the result of subtracting an objects global location from itself.

import bpy, math
from bpy_extras.view3d_utils import (
        location_3d_to_region_2d,
        region_2d_to_vector_3d)

from mathutils import Matrix, Vector

class CustomRotate(bpy.types.Operator):
    bl_idname = "transform.custom_rotate"
    bl_label = "Custom Rotate"
    pivot_point = Vector((0, 0))
    v2d = Vector((0, 0))
    axis = Vector((1, 0, 0))
    mw = Matrix()

    def modal(self, context, event):
        ob = context.object
        if event.type in ['LEFTMOUSE','ENTER']:
            print('finished')
            return{'FINISHED'}

        if event.type in ['ESC','RIGHTMOUSE']:
            ob.matrix_world = self.mw
            return {'CANCELLED'}

        if event.value == 'PRESS' and event.type == self.axis:
            # two times make it local
            axis = Vector([int(c == event.type) for c in 'XYZ'])
            self.axis = ob.matrix_world * axis  - ob.matrix_world * Vector()
            return {'RUNNING_MODAL'}
        elif event.value == 'PRESS' and event.type in "XYZ":
            # to rotate about global axes
            self.axis = event.type
            # local
            return {'RUNNING_MODAL'}

        v2d = Vector((event.mouse_region_x, event.mouse_region_y)) - self.pivot_point
        if not v2d.length:
            return {'PASS_THROUGH'}
        #Get rotation angle and update object rotation
        a = self.v2d.angle_signed(v2d)
        rot_mat = Matrix.Rotation(a, 4, self.axis)
        t = ob.matrix_world.translation.copy()
        #Print angle in degrees to help with testing...
        #print('alpha angle:',math.degrees(a))
        for o in context.selected_objects:
            mw = o.matrix_world
            mw.translation -=  t
            mw = rot_mat * mw
            mw.translation  += t
            o.matrix_world = mw

        self.v2d = v2d

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        region = context.region
        rv3d = context.region_data

        ob = context.object
        self.pivot_point = location_3d_to_region_2d(region, rv3d, ob.matrix_world.translation)
        self.v2d = Vector((event.mouse_region_x, event.mouse_region_y)) - self.pivot_point
        z_axis = Vector((0, 0, -1))

        self.axis = rv3d.view_matrix.transposed().to_3x3() * z_axis
        self.mw = ob.matrix_world.copy()
        context.window_manager.modal_handler_add(self)

        return {'RUNNING_MODAL'}

def register():
    bpy.utils.register_class(CustomRotate)
def unregister():
    bpy.utils.unregister_class(CustomRotate)

if __name__ == "__main__":
    register()


How to make texture appear only in dark spots? I'm trying to make a realistic earth but now comes the problem of the lights.
Since I'd like to make an animation I want the night lights(which are just a texture with an emission shader) to "appear" only where the light does not hit the earth.

I really think I just have to plug something into that fac input but I don't know what.

When I'll make the earth rotate I want the lights to stay only where the light does not hit the sphere.
Please Help me out here, I tried everything.

Because the planet is a sphere, with no irregular self-shadowing, you can use a simple mask, in another object's space.

In this example, the planet is at the global origin, rotating about Z. Its diameter is 2 units. The sun is down positive X.

Add an Empty at the center of the planet. (Its local positive X points toward the sun). It will not rotate, while the planet does, and the mask between emissive and invisible lights will be in the empty's Object Space, not moving.

The lights texture is in the planet's Object Space, and turns with the planet.

A simple Black/White transition is made by a Color Ramp, down the X of the empty, and centered on it, to make the mask.  Dimensions may have to be changed, depending on your model.

So the tree is something like this:

(You will obviously be using your own textures, not procedural lights, as shown here, so those nodes don't matter)

With this sort of result:

If you're animating the planet going round the sun, you could parent the Empty to the sun, and the mask will stay pointing in the right direction..

or, in other circumstances, you could constrain the Empty to point its X at the sun in another way.


Set Simple Motion jump height limit I have a player (sphere) with Dynamic Physics and can move around with W, A, S, D. The space bar can make it jump. I have a Sensor, keyboard, that detects the spacebar press. I have two Actuators, one is a Simple Motion, and the other is a Constraint. The simple motion has a Linear Velocity Z value of .5, With the L and AD checked. The constraint is a Location constraint, and it's supposed to limt the height of the player jumping. It's along the Z axis, and has a min of 0 and max of .5. Damping is 13.

Whenever the space bar is pressed, the player jumps and continues to go up, ignoring the limit. Once the space bar is released, it gets some sort of boost and flies higher up and faster.

What do I need to fix in order to get an efficient jump mechanism?
Or is there a better way to do this? I would like to be able to change the jump speed and height.

The constraint actuator dumping seems to only affect the aceleration of the object not the location as it says.

As your object physic is dynamic give it more mass than 1 and apply force over it with a keyboard sensor with tap option.


Proper inheritance rotation Just curious, is it possible to make a proper rotation without tweaking after?

From

Too

You need to shear the vertices / edge loops.

Select the edges/vertices in edit mode.

Press CtrlShiftAltS to go into the shear operation.During the operation you can press X or Y to constrain it to the respective axes. In my example I enter the number -1:

CtrlShiftAltS, Y, 1, -

After that simply extrude in the X direction then scale it to zero along the x axis.


Boolean union of multiple objects I have 5 cubes and I want to make boolean union.

How to do it in one go ?

Now, I know only know how to make union one step at the time.

For every boolean, i use the add-on BoolTool, go to user preferences > Add-ons > search Bool Tool :

Then i create 5 cubes with crossing areas :

Select all your cubes with Ctrl+A, then use the Bool Tool Union operator :
- Go to object > Bool Tool Operators > Union
Or
- Ctrl+Shift+C > Union

You should get this result :


Fluid is not generated Following few videos on youtube, I try to create a very simple fluid animation:

Creating a cube for domain
Creating a circle and change Fill Type to Triangle fan.
Placing circle inside the cube
In physics tab while circle selected creating Inflow fluid
In physics tab while cube is selected creating Domain fluid

Clicking on Bake button and as result nothing happens. I see progress bar working up to 100% without giving any error but there is no fluid simulation.
If I change circle to other type of geometry - it work. I want to use the circle to generate a water flow as it is coming from pipe.

I am using 2.78c version

I have had a similar problem. My fix was to make the pipe after I simulated the fluid. This works pretty realistically. Hope this works for you!


'Material' option does not exist in the 'Select Similar' menu Why is there no Material option in the Select Similar (Shift+G) menu?

When I try with a script, I get this error message:

Vertices don't have material data connected to them, Faces do. So you need to change to Face select mode in the 3D View header and then press Shift+G:


why is the foot skin still kinda sticking on the ground? is this happening because of the rig or something else? and how can i fix

It's your Weight Painting.

Select the mesh, key Ctrl + Tab to enter Weight Painting mode, and key T to toggle open/close the Toolshelf. Go to the 3D Viewport > Toolshelf > Brush > Weight: value and enter 1. Drag the brush over the problem spots. They should change from blue to red and rejoin (jump to) the rest of the mesh (foot).


Shape key is affecting the normals of faces its not attached to It did this after I created a bottom lid blink.
the weird part for me is that the top lid blink was never attached to these vertices but it is affecting the shadows and causes them to go crazy when the value of the bottom lid shape key is changed

I was able to solve this problem by selecting the vertex group associated with the bottom lid blink shape key and separating by selection by pressing 'P' then rejoining the objects by selecting the bottom lid and the face in object mode then pressing ' CTRL + J' to join the objects.
No more jittering.


How to make UV loft like 3ds Max in Blender using curves? I am try to make a car Body using the technique like UV loft in 3ds Max.

How to apply this technique in  Blender using curves or closer to this technique? I have seen this technique in a Blender tutorial, but I forgot about it.

In Blender 2.68 which will be released soon. has this built-in (but as a mesh tool).

Any recent testing build will have this available.

Access from the Face Menu: Grid Fill


bpy data out of sync with the actual scene My python command line shows names for objects that are not on the scene anymore when I try to autocomplete on

bpy.data.meshes

like

bpy.data.meshes['Cube']

is a valid reference even though there is no object named Cube on the scene anymore and no error or warning is issued, my script just goes on and does nothing .

I'm supposed to keep the Python API in sync with the scene manually - and in this case, how ? - or I'm missing something ?

bpy.data.meshes is all of the meshes in the all of the scenes. Meshes are different from objects, a mesh would be like the vertex positions while an object is made of a mesh, and contains the modifiers, materials, etc.

If you have an object selected you can see the name of the mesh by going to: Properties Panel > Data here you will see the name of the object's mesh, you can also get a list of all the meshes in the scene.

I am guessing that you have a cube, or an object that at one point was a cube and that is why the mesh name is Cube.

If you want to get rid of meshes that aren't currently being used then you can do something like this

import bpy
for mesh in bpy.data.meshes:
    if mesh.users == 0:
        bpy.data.meshes.remove(mesh)