Editing Lamp Strength with Python I am trying to animate changing brightness of a point lamp using input data that I have. However, when I try to access the lamp's strength using

bpy.data.node_groups["Shader Nodetree"].nodes["Emission"].inputs[1].default_value

I get the error message:

Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
KeyError: 'bpy_prop_collection[key]: key "Shader Nodetree" not found

Is there another way I can/should access and change the lamp's strength via Python?

Yes, reach node_tree through lamp object bpy.data.lamps['lamp name'].node_tree.nodes.


Type coordinates for an object and move all other selected objects accordingly I have a scene with several objects connected to each other. I need to put one of the objects at position (0, 0, 0) and all other objects should follow it keeping the relative offsets. How can I do that?

Select all of your object while holding Shift. Make sure you select the object you want at the center last.

While all the objects are selected, press Ctrl + P and select "Object".

Now when you move the object that the others are parented to, the rest will move along with it.

Make sure your 3d cursor is in the center by pressing Shift + S, and then selecting "Cursor to center."

Now, select the object you want at the center, press Shift + S, and select object to Selection to Cursor."


Is there a way to change the emission number of a particle system, without affecting the emission number of the mesh it's separated from? I have a mesh with a particle system.

I then split the mesh (using P > "separate by selection") and have 2 objects with 2 particle systems.

However, I like each particle system to have a different emission number, so I select U > "Object & Data, Materials + Tex".

I can then remove the particle system from one mesh (and the other remains), but I can't alter the emission number of one without affecting the emission of its counterpart. Is there another way to separate data I don't know about?

Current Solution:

There is a workaround if I delete one system, then re-add it with the appropriate number, but I'm wondering if there's a better way already in place.

Your solution is really a solution; it's not a workaround.

The reason you can't change one without changing the other is because they are the same particle system, just used in two different places. This is just like when you use the same material in two different places; when you change the color of one, it changes in both places.

Deleting the particle system and making a new one with new settings is one way to "unlink" the two. Another way is to make the second particle system a "single user copy." Do this by clicking the number that's next to the name of the particle system. This will keep all of the original settings, but make it into a separate system so that you can change it's settings without affecting the other one.

I hope that helps!


Beizer circle messes up model I am new to using blender, and found something I wasn't able to solve.

I have a simple model like this:

With texture from the bottom:

I would like to curve this model like a bracelet, did it with a beizer circle + curve modifier.

But somehow it messes up my model, as you see here:

What could I do? I tried changing the resolution but not much has happened..

Looking at your 1st picture, your Curve is overlapping each other.

So your 3rd picture looks like having a double faces.

Better still, instead of using Bezier Curve + Curve Modifier, use your Bezier Curve to get the kind of Curve you are expecting from Curve Modifier and then Extrude.

After Extrude, you can do the thickness.


How to make curved windows using Archimesh? I'm on blender 2.83.1, and I'm using the archimesh panel window to model windows because its easy to just stick in.
However for the main bay window of my house (there's 6 windows), when I change the number of windows in archimesh, I have no option to make them in a semi circle like I need for my bay window.
Does anyone know how to use archimesh, because its super easy, and still be able to get my windows going in semi circle for the bay?

I suppose one to go about this is to simply use modifiers.
Position the window group about where it should be, and add a subdivision surface modifier set to simple (this will avoid unwanted deformation of the shape and allow the next modifier to work)), followed by simple deform. set to bend to the window object inside of the window group empty.

Adjust the angle of the simple deform, and adjust position as needed, and you should end up with something like this result:


Is there a way for particles on a curve guide to collide? I have a Icosphere linked to a Metaball, which is following a curve guide, and I would like for the particles to fill up the box in the image you're seeing, instead of vanishing.
Is there a way to do this?

To keep particles at the end of Curve Guide you can change Settings > Free to 0.300. But since particles Life Time is given to use this number of frames to get from start to end of curve (and has influence to its speed) it was quite confusing what is going on there.
Blender Manual says:

Free – Fraction of particle life time, that is not used for the curve.

You can also try Curve object and under Physics enable Force Field > type Curve

One of many tutorials.
Use Particles System > Physics > Fluid type to get volume in a pool.


export of multiple animated objects multiplies animations by objects count I have for example 3 animated objects, with 1 animation per object (so a total of 3 animations). But when exporting (FBX), I get 3x3=9 animations, Like if all animations were distribued to all objects (it don't know which animation is linked to wich object?). That causes undesirable data.

What I Want :

ObjectA + AnimA
ObjectB + AnimB
ObjectC + AnimC

But what I get :

ObjectA + AnimA + AnimB + AnimC
ObjectB + AnimA + AnimB + AnimC
ObjectC + AnimA + AnimB + AnimC

Why does it multiplies the number of animations by the number of objects?

I Tried FBX, Collada, all options checking/unchecking, with and without NLA Strips... I always have this unexpected result.

I tried with two add-ons : FBX Bundle & Unity Tools to batch them in separate FBX files, but as always, I have all my 3 animations on each object...

It is for a real-time non-interactive animation (motion design) so I don't want to have to animate separated files because timing is very important between all objects (and I have a plenty to animate on a long timeline), also a lot of parenting within each others, so I can't separate them in multiple .blend files because of hierarchical dependencies and complex timings.

How can I have the right amount of animations without all these duplicata ?

Thanks for your help!

Ok so apparently it is impossible to have multiple objects in the same FBX or DAE. I've seen demos that are cheating by merging all objects into an unique armature (so it's an illusion of multiple objects).

The solution I've taken is to have a root bone for each object at 0 0 0 (independant of the next ones) then a bone that's offseting object at right place in the scene. then copy-paste each armature/object in a new blend file. And a checking file that links all scenes of each object (I'm not enthusiast to merge all in a single gigantic armature, because animation in/out/loops are forced to be at same length, it gives no possiblity of independant looping, and no possiblity of re-use independant objects / animations).

It's the best solution I've found. If you have a better workflow for working with multiple animated objects that needs to be synced in a precise timing (like an object jumping onto another when the second one has finished it's apparition), that needs to be exported/readable/triggerable in FBX or DAE, don't hesitate to talk about it.


How to convert SpaceView3d.lens to field-of-view? I'm trying to export data of the User Perspective Camera to a LibGdx Camera. As far as I know there's no way to get the field-of-view of the User Perspective Camera directly.

Thanks to whoever can help me with this.

Edit:

@Jerryno:

Thanks for your reply. I tried your approach, using this code.

import bpy
import math
from bpy_extras import view3d_utils

def area_view_3d():
    areas = [a for a in bpy.context.screen.areas if a.type == "VIEW_3D"]
    if not areas:
        return
    return areas[0]

def camera_angle(a3d):
    region = [r for r in a3d.regions if r.type == "WINDOW"][0]
    r3d = a3d.spaces[0].region_3d
    if r3d.view_perspective == "ORTHO":
        return
    ray_vector = view3d_utils.region_2d_to_vector_3d(region, r3d, (0, 0))
    view_camera_loc = r3d.view_matrix.inverted().translation
    look_at = r3d.view_location
    view_local_z = look_at - view_camera_loc
    return math.degrees(view_local_z.angle(ray_vector))

a3d = area_view_3d()
if a3d:
    #a3d.spaces[0].lens = 16
    print(camera_angle(a3d))

To convert focal length to field of view you need to know the sensor size. The formula is as follows:

FOV = 2 * arctan(half_the_diagonal_of_sensor / focal_length)

See this in Blender's code.

So that means your field of view is dependent on the size and aspect ratio of the 3d View window.

Best way how you could approach this is to cast a ray into the scene from one 3d window corner and measure the angle to the ray that is in center of screen (basically to the local Z axis of viewport).

you get the 3d rays like this (snippet from a modal operator - you will have to overwrite context for your application):

import bpy
from bpy_extras import view3d_utils

region = bpy.context.region
rv3d = bpy.context.region_data
pixel_coords = (0,0)

ray_vector = view3d_utils.region_2d_to_vector_3d(region, rv3d, pixel_coords)

view_camera_loc = rv3d.view_matrix.inverted().translation
look_at = rv3d.view_location
view_local_z = look_at - view_camera_loc

you measure the angle between the ray_vector and view_local_z


Why does turning off Auto Smooth removes blotches? Often with imported OBJ meshes I noticed that some seemingly random vertices are surrounded in dark blotches and sometimes adjacent ones are pale. Yet all the readable characteristics are identical to a normal vert angle stats. So why when I was messing around I unchecked Auto Smooth did theses anomalies go away?

I sometimes had effects like this because custom split normals data was imported and got distorted somehow. AutoSmooth only seems to work reliably if this data is deleted, try the button in the Mesh Data section to clear custom split normals data:


How to scale a mesh without destroying the UV Map I was as you can see below, I placed a bump and a normal texture on a cylinder with UV mapping, but I need to scale the cylinder up to make it longer.

But it then ruins the UV mapping,
So I'll ask, Is there a way to scale a mesh without ruining the uv\texture?
The texture I used was...

]1

When you scale your object on Z axis in 3D viewport, you must be careful to adjust your geometry in UV Image Editor because it don't have Z axis and you have to adjust on both X and Y axis.

You must scale the UV Unwrapped Geometry like this:

See images and scale accordingly.

Default Mesh with texture.

Scaled on Z Axis with Texture

Can you see I have scaled the UV Map differently in both images.
Shortcuts are same for scaling in UV Image Editor that is S

  There are many free tutorials out their who covers Texture Mapping.

All the Best.


How to edit a photo for texture How can I custom crop an image in blender? I need to cut off edges of a photo before I can use it as a texture.

Check CGmatter tutorial on youtube :https://youtu.be/gz4qV5_zuMo
Or you can use gimp to crop the image


How do I do an internal curved corner? Sorry for the very dumb question. I just don't know how to do this. How can I make the side of this object follow the curve in my reference image in the background?

You could do it this way instead:

Extrude down:

Bevel:

Mirror, rework the topology with the knife (K) and some join (J):


Export/list the control points of a NURBS 30 minutes ago, I launched blender for the first time. I'm rather overwhelmed by the options, so I dare to ask this novice question.

I'd like to export the control points of a NURBS into a text file. If possible I'd prefer homogeneous coordinates.

For the start, I have created a path and modified it to look like a quadratic Bezier curve.
I've exported to different formats, but didn't find NURBS data in them (e.g. dae file contains lamp and camera, obj contains coordinates of the curve).

  How can I obtain the control points and knot vector?

I found this, but I'm not sure how to use it and if it could be helpful.

OBJ Format supports nurbs, but Blender writes them as edges by default (since many applications don't support them).

File -> Export -> Wavefront OBJ

Then in the options, enable Write Nurbs. This currently only supports Nurbs splines (not surfaces).

If for some reason you need to access different kinds of curve data, writing nurbs to a text file from Python isn't all that complicated.


Projected convex hull in plane Consider an object like this one:  Is it possible to, and if it is how, automatically generate a body that is convex for every cut along the xy-plane, without destroying the radial variation in along the z axis.

I realize that this can be tricky do on a general mesh, where the edge loops are not strictly planar. Instead I thought that following approach could work:

Manually add some horizontal edge loops to a new mesh, at chosen z coordinate
Use the shrinkwrap modifier, with the non-convex mesh as target
Scale each loop such that all vertices within one loop has the z coordinate

Instead of shrinkwraping and scaling, it should also be possible create new loops by intersecting radial edges with horizontal planes. Anyhow, we have created a set of horizontal edges, that encloses the geometry well.

Apply the convhull operator on the edge loops individually
Connect vertices to generate new faces

If I am not wrong, it should be possible to script steps 2-5. Here tips on appropriate python APIs is of interest. However, the procedure fails after step 4, since the convhull operator pollutes the mesh with new, coplanar and overlapping faces, that I do not want. Is it possible to remove that extra geometry automatically?

I solved the problem with the following algorithm

Create N horizontal planes of appropriate size
For each plane

Apply the boolean modifier (intersect the plane with the target object)
Extrude the plane in the z direction, giving it some height
Apply the convex hull operator
Remove the extra plane created in step 2
Remove any vertices inside triangles

Merge planes into one object
Bridge the edge loops
Remove interior faces (they were left from the convex hull operator)

Here is the Python script with room for some improvements: https://gist.github.com/milasudril/960f5c2c4c3735f3fdea566cfdc003d9


Why I don't have Toon Shader in blender2.91 I don't have Toon Shader. I use 2.91

The Toon shader is not available on Eevee.
Switch to the cycles render engine.


Weird shadows in arrayed floors in EEVEE When sun light is at particular angle.
These weird shadows appears between floors.
how can i fix this?
in cycle it doesn't happen.

You need to increase the quality of shadows in the Render Properties panel. Play with them until they look good. Also, try to make sure the surface area of your light is as small as possible if you want sharper shadows, the larger the surface area, the softer the shadows will be.


How to make original full-pass image from separate passes? I'm trying to create an image from separate passes. That is, I have a result image, which without altering the composite Combined RGBA buffer looks like following:

On this image you can see a cube standing on two planes - one that is opaque and receives shadow, and second, bigger one, which only receives shadow.

Now, what I want is to be able to work on the Combined Pass without: Shadow, Ambient and Environment Passes. So I've set up the render layer like that:

Now, in compositor I try to build the original image back, I'm doing with a following node setup:

But this fails to deliver the correct result, which is like that:

The comparison looks following:

So the question is how to combine the distinct passes back to the "full" image. I'm asking for clues at least, I mean, I've noticed that there is a weird outline caused by the Shadow Pass, you can see at the bottom of the image. The shading itself is also wrong - this perhaps because I don't know the order in which Blender combines these passes. For the Ambient Occlussion I did "multiply" in Mix node, as the AO is set up to "multiply" in World settings, and for the Envrionment Lighting node I did "add", as I guess, the environment light is adding to the end result.

Any clues that can push me forward are welcome.

First I encourage you to use image layer instead of render layer, because otherwise you will have to render the scene each time you open up Blender. It could be quite disappointing for very complex scenes. For doing so you need to save your image with all the passes by using the OpenEXR Multilayer

Now for the exact recipe (as illustrated on old the blender manual)

Finally, I don't see the Diffuse and the glossy passes (D/I/C). You should check them before rendering as shown on this image

I hope this is helpful and Good luck!


Mapping a textures z location from [0 to -40] to [0 - 1] for baking baking sound to f-curve First off, I am not sure if I'm asking the right question. I'm a modeler first and foremost. Its all I know :)
I make music visualizations.
Normally, to bake a sound to a value, I press "i" over a value to insert a keyframe and then go into the graph editor and bake sound to f-curve for that specific value. As far as I can tell, it only affects it in a positive direction.
What I'm used to doing...EX:

Using the "factor" in graph editor and baking sound to f-curve.
In this example, I'm using the frequency range of 0-120 to change the color of the object. Easy peasy. Goes from blue to red depending on how high the sound is.

The thing I can't figure out is how to do the same thing but with a materials z location mapping.

I've been told there is a Map Range node and I've done some research on it and understand the concept, but the implementation of it has stumped me.
Thanks for any and all help.

If I understand you correctly, you'd like to map the incoming 0->1 audio amplitude range from the baked f-curve, to a 0 -> -40 range for use inside a shader node-tree.
You can key the incoming audio range into an Input > Value  node, and map that to any other range you like with a Converter > Map Range node:

... here, mapping  0 -> 1 to 0 -> -40, influencing only the Z-component of the location of the texture space. The 'Clamp' checkbox causes the output to flatline at the min and max of the ranges. If unchecked, the mapping extrapolates.
Using a Value node is more flexible than keying, say, the 'Fac' of a color-ramp directly. The single 0 -> 1 audio input can be branched, and mapped to different ranges for different features of your tree.


Zoom Background Image in the VSE Blender 2.74: When "Use Backdrop" is checked in the VSE, we can see the video clips in the background of the VSE; the clips will adjust to the size of the VSE, they'll be "full frame". I'm trying to have the display of video clips smaller within the VSE. On this video: https://www.youtube.com/watch?v=QnM_UAsLHag&t=3m53s at 3'53, using Blender 2.73, with the shortcut V (background image zoom), he can reduce the size of the clip and move it anywhere he wishes. I haven't manage to select the background image and reduce it's size. Has this feature been removed in 2.74?

It's not possible at the moment. This "VSE Backdrop" feature has been introduced in the gooseberry branch with rB0717d:

  DESCRIPTION

  Gooseberry request: Backdrop for sequencer.

There has been another request rB9a934 for an "Overdrop" what is exactly what you saw in your Video which has zoom functionality and can be dragged around. But it differs from the Backdrop feature you asked for. Actualy it's an evolvement of it and got renamed.

But as it is in development with feature branches not everything that is being developed for an Open Movie project finally gets into the Master Branch of Blender. Not every feature is bug free or already polished enough and therefore this would take too much time to merge it back into master.

A detailled description what has been merged back from Gooseberry is in the Blog article Gooseberry in Blender Master and unfortunately for the Sequencer only

  A backdrop feature

has been mentioned there. Not the "Overdrop" feature. So your missing feature has not been removed, it just never made it into the "official" Blender development branch that results into the Version you can download from blender.org/download. You might ask the developers to merge this Overdrop feature back into Master as well.


Insert fcurve keyframe point whilst keeping curve shape I have 2 keyframe points on an fcurve with free bezier handles, and using Python I want to insert a point in between these keyframes whilst keeping the custom shape of the curve with the handles. I can insert a keyframe point no problem using

fCurve.keyframe_points.insert(frame, value)

but I'm not sure how to do so without affecting the shape of the fcurve. Is this possible?

Subdividing Bezier curves is normally done using De Casteljau's algorithm.  However, fcurves aren't pure Bezier curves.  It is not hard to make a bezier curve "run backwards" along the time axis.  Since this would create ambiguities in the animation system, blender prevents that by using modified handle coordinates whenever the handles could make the curve backtrack in the time axis.  Once we understand that math, we have what is needed to properly subdivide the fcurve.

The solution is already covered at https://blender.stackexchange.com/a/57453/660 .  It includes an excerpt from http://web.purplefrog.com/~thoth/blender/python-cookbook/subdivide-fcurve.html .  I got bored and added the logic needed to map from frame->t so it should now be a fairly complete solution.  I'm not copying the code over here, because keeping it up-to-date in both articles on stackexchange is tedious.


Change texture of an object but with fade i work in BGE and i would like change the texture or the material of an object.

For exemple if i click on a
pushbutton the texture of the transparent windows fade to texture of curtain.

Well, there might be different solutions - but here is one which worked for me. It involves Material nodes with three seperate materials. You need...

one for your initial material (window),
one for your second material (curtain) and
one which controls your fading.

The last one uses the objects color, which can be changed via Python.
Here is an my minimal example using a blue and red material as inputs and a shadeless one for fading:

When running it, the materials fade within 10 seconds, driven by the timer.


Am I limited to using primitive objects to create shapes in Blender or can I 'sketch' a freeform shape? I've recently discovered blender as a solution for my rendering and animation needs as an aspiring product designer since these tools in traditional pd software such as Fusion and Solidworks is very basic at best. However, I've noticed that forming shapes in blender seems to be done from primitives such as cubes, planes and spheres rather than a sketch as I am traditionally used to.
This method seems very roundabout for making something even relatively simple such as a table or chair which I would otherwise just sketch,extrude and modify.
I would like to know if this is just a matter of not being used to it, or whether I should stick to other software for modeling product and import it to blender for rendering and animation.
If so, the mesh seems to be very distorted when imported are there any addons I should look into for solving this problem.

How to (sort of) do a CAD sketch in blender:

Add a single vertex. This can be done by deleting all the other vertices in the default cube, or enable the "Extra Objects" addon an press ShiftA and choose "Single Vert".
With the vertice selected go into edit mode and orthographic view from the desired side.
Press E to extend into the shape you want. It will create a bunch of points in the shape you like.
When you want to close off a shape, select the two vertices you want to connect and press F to automatically join them, in this case with an edge.
Now fill in the shape. Select something to fill in and press F to automatically join them, this time with a face.
Now select everything (or something), and press E to extrude them into the desired height.


How to make a Particles Mountain I have attached a file. In that a sphere is on the top and a plan at bottom and to the right there is group of particles. The group of particles are coming down from the face of the sphere and dropping on the plane. I want to make a mountain of the particles which i have the group. But my particles are not stay on the plane. I have added add passive (rigid body) to the plane so that particles stay on it but its not working. I want the particles to be stay on the plane and not die and make a mountain shape. May i know what other settings i have to make so that particles stay on the plane and make the mountain shape.

To make particles collide on the plane, add Collision Physics to it and set the stickiness to 1. Perhaps also add some friction.

The particles will now stop on the plane, but they won't pile to a mountain as you want. That is because particles don't collide with each other. See here for particle self collision.

Instead of particles, you may also try rigid body physics or water simulation (with enorm viscosity, don't know if that one will work though).


What is the difference between the displace socket and a bump map? Aside from the fact that you can control the bump mapping per shader with a bump node, are there any differences between these materials?

As far  as I can tell, they are the same. Is the displacement socket just a convenience thing? Is there a performance advantage?

Theoretically they are meant for similar purposes and functionally there is overlap when used in simple cases.

However, when used for extreme bump mapping, the bump map node produces much better results:

Left: Texture plugged into displacement output Right: Bump map node plugged into shaders

The other difference is of course that the displacement output can be used for actual geometry displacement (when when using the experimental feature set):

Left: Bump displacement Right: True displacement

Both spheres use the same material with the texture plugged into the displacement output. The sphere on the left uses the default Bump displacement method, while the sphere on the right uses the True method:

Note that the sphere on the right has a Subsurf modifier on level 4 to give it enough geometry to displace. There is a Use Subdivision option in the displacement settings, but I found this causes some wireframe artefacts.

Finally, using the Bump node allows you to choose not to have a bump map for certain shaders. For example you may want the gloss on the material to appear like a glossy coat or varnish, while still having a bump map for the underlying diffuse shader:

Left: Same displacement for all shaders Right: Different displacement for each shader

For reference, here is the sphere with no bump or displacement


Why did my Denoising disappeared? Hello guys I need a little help, the Denoiser below Adaptive Sampling suddenly disappeared. How can I enable it back?

It's now placed in the View Layer Properties, see screenshot. But actually I would use the Denoise node in the Compositor, because the Denoising option slows down the render and the result is inferior to the Denoise node from my experience.

Just plug it inbetween your render and the composite output, the result is usually far better than the Denoising even if you don't use any additional Denoising Data in the Normal and Albedo inputs.


How do I add a sound to the start of my game? How do I add a sound to the start of my game so it only plays once?

I'm fairly new to the game engine, but I was able to work this out so I will add my solution.
 Add a sensor and set to always>once, and then add a controller. The controller will be be an and controller. Finally, an actuator, which will hold the sound file. Set it to Sound>sound and the mode should be Play stop.

This should work with a speaker or empty as well as a mesh object if you prefer, I tested on a uv sphere with the shortest sound I could find on my PC, and it works. It will play once only upon pressing P.

Your logic bricks will look something like this:


Use baked shadows on separate mesh? I have an architectural model with a shadow map on a separate mesh, that is positioned very close on top of the first one. The shadow map is only for two rooms of the interior and the uv layout is different, so i can't just put the texture on the first mesh. I tried setting it to "Ambient" in Blender Internal and went through different blend modes, but it doesn't work. How do i set this up correctly (Internal or Cycles)?

I have an idea, that you can use compositing to achieve this task:

I created 2 render layers, one for color (I make them solid using Emission node):

And this for the baked shadows (and objects with real shadows are holdout, to make a transparent on their place):

And multiply shadows with color in compositing nodes this way:


how to add circle to existing mesh by python script if i want one object with 10 circles inside it, i can create first one, then enter edit mode of it, then create remain 9 circles, which seems like design mode programming.

how can i do this at once something like:

mes = bpy.data.meshes.new(name+"Mes")
obj = bpy.data.objects.new(name+"Obj", mes)
bpy.context.scene.objects.link(obj)
for i in (range(1..10):
    mes.primitive_circle_add(...)       # <- will not work ???
mes.update()

is from_pydata only allowed function for mesh object or there is a way to draw circle in it.

Using bmesh

Suggest getting to know bmesh as soon as possible.   There are a number of create primitive operators in bmesh.ops including bmesh.ops.create_circle(..)

import bpy
import bmesh
context = bpy.context
scene = context.scene
me = bpy.data.meshes.new("Circles")
obj = bpy.data.objects.new("Circles", me)
bpy.context.scene.objects.link(obj)
#new bmesh
bm = bmesh.new()
# load in a mesh
bm.from_mesh(me)

for i in range(1, 10):
    # create circle
    geom = bmesh.ops.create_circle(bm,
                segments=16,
                diameter=1 / i)
    verts = geom["verts"]
    # translate verts
    for v in verts:
        v.co.z += i / 4

# write back to mesh
bm.to_mesh(me)
# make context
scene.objects.active = obj
obj.select = True
scene.update()

Note there is a more involved example on bmesh API re circles


Is there really no way to add edge loops with maintaining geometry? I often come into situations where I would need more geometry when modeling using subdivision surface. Maya has a tool for that. It works by adding edges by subdividing but still maintaining the form of the mesh. Here is a link showing how it works:
 https://www.youtube.com/watch?v=qVX_II7VQxI&t=130s

Here is a picture hopefully clearing my question:

I have not found any information on the web regarding that sort of tool in Blender therefore I conclude it does not exist. However I think the workaround might work in some situations depending on your needs. Here is what I used:

select your mesh
alt +c (convert to) -> mesh from curve/meta/subd/text
cleverly use the edges you need for your shape and remove the ones that does not affect it

Hope it helps.


Hotkey for toggling between vertex/edge/face select modes in Edit Mode? In Edit Mode, in the 3D View, is there a hotkey for toggling between vertex/edge/face editing?

I believe its Ctr + tab then choose from the menu that pops up.


The rendering process gets stuck, or sometimes I get a black screen I'm just following a tutorial on youtube, but when it comes to the end I cannot render the file, it always stucks and makes the screen black sometimes just showing nothing.

If anyone can help it would be appreciated. Thank you.

http://www.mediafire.com/download/vjvnaccxmyydmxn/lightsaber.blend1

The file renders fine. But you are needlessly taxing your machine with too many subdivisions on the subsurf modifier:

BE CAREFUL! In my experience going over 3 is not necessary and does have a huge impact on the computer's performance. Keep in mind that for every subdivision the number of polygons at render time increases exponentially.
Form the manual

Great levels of Subsurf demands more video memory, and a faster graphics card. Blender could potentially crash if your level of Subsurf surpasses your system memory.
Note about potential crashes: Be aware that the Subsurf Modifier will need more and more memory at higher levels of subsurf, and the more dense your base mesh, the more memory you will need. In 32 bit systems, Blender could potentially crash with malloc errors, when you surpass 2~3 GiB of memory used. This is not a Blender bug. Blender, when paired with a 64 bit system, could use 64 GiB of memory, thus reducing the chances of malloc() errors.

Same scene with 3 levels of subsurf

And with only 2

click on image to enlarge


Render Farms render blank image frames Hi I've tried rendering through both concierge redner and garageFarm.net but both farm are rendering blank frames,
I have an active camera, and when I hit ctrl f12 it works fine.
What's happening, files are packed.

the culprit is in the rendered layer settings;
(View Layer Properties tab)
you will need to use the "Use for Rendering setting".
The Render Single Layer setting is ignored in command line rendering, and it’s only used in rendering from Blender interface.
Once you use this setting, you should get the correct output rendered from the farm


Importing PNG series with Import Image as Plane is blurred and has artefacts I am using a series of .png images (from green screen footage) with alpha channels. However, when I try to import image(s) as plane(s) in a rendered scene, the image is blurry with anti-aliasing off. If I turn on anti-aliasing, then I get a frame artifact around the image plane.

Also, is there a way to setup the plane so objects behind transparent parts of the image can be seen? I am using Blender Internal and an AMD Radeon HD 5770 graphics card.

Nice default settings are to make sure you have Z Transparency as shown below in the Alpha Mode group.. also tick Shadeless as this makes them insensitive to light or shadow and will make them not appear blurry when rendered. You can enable this before or after importing the image(s).

The images come in clean with the alpha setup nicely. As you can see, they can also be layered etc, they might look a bit aliased in the 3d viewport but when rendered show very nicely.

I think the artefacts you might have seen is because they are intersecting with each other, try spacing them apart a bit on the Z axis etc..

These are the planes below in the 3d viewport after importing, the ones on the left have been spaced, while the ones on the right are in the default position.

This is how they look without Shadeless enabled when rendered.

And this is how they look with Shadeless enabled when rendered.


Change an Object's Material to another Material with Python [Pic Attached] I have an object named "Paper_obj"

After entering the Material tab, there are tons of materials within, "White Transmission", "Steel Mag", etc.

My main purpose is to change the "PaperTopYellow" to "PaperTopRed" by clicking on the drop down list. Can it be done with Python?

Since there are many other objects in the blend file, the hardest part for me is to first target that "Paper_obj" first and then change the "PaperTopYellow" to "PaperTopRed" within.

Thank you!

bpy.data.objects['Paper_obj'].data.materials[3] = bpy.data.materials['PaperTopRed']

The above should be the general answer.

However, what if I do not want to use the slot number but would like to target "PaperTopYellow" and replace it with "PaperTopRed"?

Sometimes, the slot number for "PaperTopYellow" may not be 3 but 2 instead.


How do you display a tool tip for a custom modal operator? I've got a modal operator in my add-on that allows the user to draw a gradient. I'd really like to show the user more information about an axis snap feature the operator has, but I'm not sure how best to do this. From looking at other operators, such as vertex slide, the Blender way is to show a tool tip in the bar at the bottom of the screen, as shown in this image.

How do I do this?

Area.header_text_set

A call to area.header_text_set(text) sets the header text to text No argument area.header_text_set() and  it returns header to usual mode (menus et al).

Code below from Scripting > Templates > Python > operator_modal_view3d.py

    if event.type == 'MOUSEMOVE':
        self.offset = (self._initial_mouse - Vector((event.mouse_x, event.mouse_y, 0.0))) * 0.02
        self.execute(context)
        context.area.header_text_set("Offset %.4f %.4f %.4f" % tuple(self.offset))

    elif event.type == 'LEFTMOUSE':
        context.area.header_text_set()
        return {'FINISHED'}


Control grease pencil keyframes with a slider, like a shape key? I guess a good example for what I want is almost like a south park character and their mouths.
If I had a sphere for a head, and I wanted to draw a mouth on it with grease pencil, I'd draw 5 difference mouth shapes across 5 keyframes with the grease pencil object. Is there a way to link this to a controller or slider, that I can move up and down, to move through the keyframes for lip syncing? That way I could just include it with the character rig instead of having to redraw the mouth in every shot.
Or if I had a plane of Cartman's head and I drew his different mouth shapes as a grease pencil object, then i give it to an animator so they can just use the slider to go through the mouth shapes and keyframe that slider.
Same could be done with eyes for example. Instead of making a layered rig with bones, if I could just draw the eye open, closed and maybe squinting and connect that to a controller that slides through each keyframe for each eye shape that would be what I want.
Hopefully that makes sense, I cant find anything related to this or it is  hard to find the right keywords to search. Do I need to write some python script for it?
-Jason

that is something you can do in Blender and it's the method we use.
Here's a quick tutorial,

Draw all your frames on a grease pencil object
In the modifiers tab add a time offset modifier and set it to Fixed Frame. The frame number will be the frame selected/shown on screen.
Use a driver to control which frame to show by right clicking the frame number and clicking add driver. Here you'll have to tweak settings dependent on your bone size and desired Active area. We generally use the distance operator ie, when the selector bone touches the smile bone it shows a smile.

Thanks
Matt


Convert rotation from sign switching to continuous in Animation Nodes Plane is simply rotating on Z axis around origin from 0 deg to infinity (linear interpolation), AN extracts this rotation from polygon. Extracted motion looks fine but it isn't calculated as cumulated/continuous value. Every 180 degrees it is switching sign from + to -.

Look at Z value here:

Can this rotation be recalculated to match input motion? I was planning to change some values inside material in [0-1] range using growing angle, but unable to do it with current behaviour.

This signed representation is called a Directed Angle. To convert that to a non-directed angle, simply add $2\pi$ if the result is negative as follows:

This is assuming you angles are in radians, if they are in degrees, you should be adding 360 instead.


Sharpen egdes using the SubSurf Modifier - floodlight I'm currently modelling a floodlight, but I'm stuck. The following image shows the front covering. In the middle, you see that the Subsurf modifier is smothing the three edges, but I want them to be sharp, so that the faces around it shape a frame.

What modifiers I've used:

What I've already tried:

I've selected the edges and marked them sharp (Ctrl + E --> Mark Sharp) and used this with the EdgeSplit modifier
I've tried the Auto Smooth option (Object Data --> Normals --> Auto Smooth)
I've tried using loop cuts but they don't work properly in my case
I've tried using Edge Crease (Shift + E)
I've tried changing the order of the modifiers

All these options didn't work for me, so I'm thankfull for all help ;)

It appears you already tried a Crease factor on those edges using shift-e

https://docs.blender.org/manual/en/dev/modeling/meshes/editing/edges.html

  This edge property, a value between (0.0 to 1.0), is used by the
  Subdivision Surface Modifier to control the sharpness of the edges in
  the subdivided mesh. This operator enters an interactive mode (a bit
  like transform tools), where by moving the mouse (or typing a value
  with the keyboard) you can set the (average) crease value of selected
  edges. A negative value will subtract from the actual crease value, if
  present. To clear the crease edge property, enter a value of -1.

It turns out creasing just the edges of the opening is not enough.  You also have to crease the diagonal edges that have a vertex on the opening:


Stucked in world texture panel I'm learning blender and I want to apply an uv map.

I'm blocked because my texture panel is blocked for the world but I have selected an other object (I'm in object mode)

You can see my panel below. The picture is the picture of my world outside.

Any idea?

My current panel

My wanted panel

You are in cycles render engine. The texture panel, and material panel are different in cycles than in Blender internal.

What you want, is the texture panel from Blender internal.

I'm sorry, but there's not way to get the Blender internal panel in cycles, and it would not be practical, as the renderers work in different ways. You could switch to Blender Internal, but Cycles has many superiorities, so if I were you, I would just use the new design, and get used to the way it works.

Keep in mind: You can switch which texture you are editing in Cycles, by clicking where it says "environment texture", and selecting another texture.


How to type in script editor window when mouse cursor is elsewhere? I'm very new to blender, using it for robotics, so primarily drawing using python very little hand-drawing.

When I am typing in the script editing window in Blender (2.76b in Ubuntu) and my mouse cursor drifts outside this window (worst is the viewport window), the ability to type into the editor window halts. I have to manually push my mouse cursor back in, even if the text cursor (|) is still in the editor window. Is there a way to change this default behavior?

It is particularly annoying if I accidentally type a hotkey (e.g., Z) that changes some basic behavior in the viewport, and I don't know what I did. This is becoming very frustrating and inefficient.

I assume this is also a feature, so you can go do some quick hotkey stuff in the viewport while working on scripting, but I would really like to let my mouse cursor and text editing cursor be in different places, while editing text. That is, I want the text cursor to take all my keyboard events, as is the default in all my other applications.

I have searched online for an answer, posted at blender forum and gotten no response yet:
https://blenderartists.org/forum/showthread.php?402785-How-to-type-in-script-editor-window-when-mouse-cursor-elsewhere

Well this is a workaround but if you Toggle Fullscreen Area AltF10, then you can type in the text editor with the mouse cursor outside of blender!

See my answer for other options for maximizing windows in blender.
However full screen area is the only one that works completely, simply maximizing the text editor the header and info bar still get in the way.


Cryptomatte - What Crypto00, Crypto01, Crypto02 means? Why Render Layer node use several outputs, like for object pass

CryptoObject00
CryptoObject02
CryptoObject04

and Cryptomatte node several inputs

Crypto00
Crypto01
Crypto02

What I tried, connecting just the first one "00" does the job.
How the others are used?

I see some connection between "CryptoObject00, 02, 04, 06, ..." and "Levels" in "Passes" section of "Layer Properties" window. Levels are described as "Sets how many unique objects can be distinguished per pixel." I can imagine something in theory, but I'm not sure how these output sockets of levels? really works. Why there is not only one output with level set in properties?

Why level "2" use socket numbered "00" (level "4" = output "02" etc.)? Why it does not start "02" for level 2 if it folllows even numbering of distinguished pixels?

Similar for Cryptomatte node inputs (Crypto00, ...) - what kind of job they do and how can be color next to it useful?

(I saw several videos and I red wiki, forums ... but no one is explaining or asking for that. Sorry if it is so obvious, I didn't catch it.)

In order to explain to sockets and their numbering I'll have to explain how Cryptomatte and some aspects of path tracing work.

The Idea
Cryptomatte generates ID mattes which try to preserve for each pixel of the rendered image what elements of the 3D scene contributed
to it. For instance in a render with motion blur, pixels where the moving object and background object blend into each other are
influenced by both objects. In order to understand how Cryptomatte identifies and stores this information, we have to take a look at
how the rendered image is created.
Rendering using a path tracer such as Cycles works roughly in the following way:
In order to create the rendered image we sample multiple paths per pixel at subpixel location from the camera into the scene. The sampling is
quasi-random using either the Sobol sequences or correlated multi-jitter. For each path we check if it intersects with an object, if it does,
we remember the hit point. Next we chose a random point on one of the light source and try to connect
it to the hit point. This is an optimization known as Next-event prediction. If a direct path from the hit point to a light source is
possible we can evaluate the shaders along the path to the camera and we receive an RGBA value. In case a connection to a light source isn't possible, we bounce with
a new path segment from the hit point in a quasi-random direction and repeat the process until we either hit a light source or exceeded the maximum
bounces. Cycles therefore uses Quasi-Monte-Carlo integration. In order to fuse the multiple samples per pixel in the camera plane into a final RGBA value
we use a pixel filter which weights and sums the subpixel samples. Cycles uses either a Blackman-Harris, Gaussian or Box filter.
This is a very simplified and shortened explanation, for a more detailed introduction I recommend watching Lukas Stockner's talk
from the Blender Conference 2019. The important part for Cryptomatte is that there are multiple samples per pixel,
that may hit different objects and which therefore contribute to the final pixel.
The idea behind Cryptomatte is that we can leverage the scene and path tracing information to create ID and coverage pairs per pixel,
where the ID references the element that contributed to the pixel and the coverage tells how much. This allows us later on to determine
which pixel and by what amount was caused by a certain object or material.
There are three elements Cryptomatte can store ID mattes for: Objects, materials and namespaces (hierarchical groups of objects, which is the Assets option in Blender).
IDs are generated by hashing the object/material/namespace's name and are stored per sample in so called arbitrary output variables (AOV).

Filtering and Encoding
Each pixel in the render is the result of the weighted sum of its samples, where each sample belongs to an ID.
The weights are given by the pixel filter, such as Blackman-Harris or Gaussian filter. There can be several samples per pixel
that belong to the same ID.
The weight of the samples that belong to the same ID are accumulated per pixel.
Normalizing the value gives the coverage of the ID-coverage pair for that pixel. For every pixel the pairs get ranked by their coverage,
rank 0 is for the highest coverage. They are then assigned to the corresponding pixel in the layer that contains said rank.
Note: Each rank is essentially a matrix that contains an ID-coverage pair for every pixel. Since the assignment of ID-coverage pairs to ranks is done per pixel, IDs for a specific object may be found across several ranks for different pixels.
Multi-layer OpenEXR files are used as data structure for storing the files. Each of the AOVs is stored in a separate file.
IDs and coverages are stored each in their own channel. Since
OpenEXR has RGBA channels there are two ranks per layer.
Layer 1

CryptoObject00.r - ID rank 0
CryptoObject00.g - Coverage for ID rank 0
CryptoObject00.b = ID rank 1
CryptoObject00.a = Coverage for ID rank 1

Layer 2

CryptoObject01.r - ID rank 2
CryptoObject01.g - Coverage for ID rank 2
CryptoObject01.b = ID rank 3
CryptoObject01.a = Coverage for ID rank 3

Layer 3

CryptoObject02.r - ID rank 4
CryptoObject02.g - Coverage for ID rank 4
CryptoObject02.b = ID rank 5
CryptoObject02.a = Coverage for ID rank 5

Metadata in the file stores the original name of the elements and the hash method used along other information.

Matte
Given a name of an object/material/namespace we can compute the ID using the hash function documented in the metadata.
All that is necessary to create the matte is to iterate through the ID coverage pairs and retrieve the coverage per pixel.
If a single matte for multiple IDs is requested the coverage of the IDs is summed.

Answering your questions
What are levels?
Levels are the number of ID-coverage pairs per pixel. Therefore the levels determine how many unique objects can be differentiated per pixel. It should be a multiple of two, since levels divided by two is the number of layers in the Multi-layer OpenEXR.

Why are there three input sockets on the Cryptomatte node?
The three sockets are for the recommended three layers to store the six ID-coverage pairs per pixel. You can add additional layers in the sidebar
in the Item tab in the Properties panel.

Why are the output sockets of the Render Layers named like that?
I believe this is an error, since they get properly named internally in BlenderSync::sync_render_passes() (blender_sync.cpp) however
register_passes() (engine.py) does an increment by two. This is correct in regards to the number of render passes, since there are two ranks per layer. However the names should still use consecutive numbers and match the ones of the Cryptomatte node.
I've created a post on DevTalk to discuss this with the developers.
Update: The numbering has been fixed by commit rB3f3d1ad4800c6d5e9d1a45912841b118cbac9f39

Why should I connect more than the first render pass and why does it work when only connecting the first?
It depends how many unique objects you'd like to differentiate per pixel. If you connect the first render pass, then the cryptomatte node can only create a matte which contains the coverage of two objects per pixel at most, since you pass two ranks into it. This will likely be enough for most simple compositing tasks. For more challenging scenes with multiple objects that have motion blur and cross paths which each other, you'll want to use the additional passes as well.

References
Cryptomatte Specification Version 1.2.0
Friedman, Jonah, and Andrew C. Jones. "Fully automatic id mattes with support for motion blur and transparency." ACM SIGGRAPH 2015 Posters. ACM, 2015.


Does the setting for domain size make a difference if the units are set to something other than None? I've been trouble-shooting a fluid simulation and something that kept sticking in my throat was that my Fluid World scene size was set to 0.5 meters when my domain was actually much larger than that.  It's my understanding that that domain size controls the displacements and iterations but the control was deactivated so I couldn't increase the setting.

I figured out that if I set the Scene units to NONE that I could go back and change the setting.  A test bake with units on NONE and the domain size set to 7.5 appeared similar to the one with the units set to Meters reporting a domain size of 0.5.  Do I need to manually set that value in order to get an accurate fluid simulation or is the size calculated automatically with the units set?

If you go into edit mode and press "n" look in the mesh display area and you'll see an option for displaying the lenths of the edges.  If you scale in object mode the values of the edges don't change. If you scale in edit mode they do. If you scale in object mode, hit Ctrl+A and accept the scale. Now your edge lengths reflects the new dimension. This may be why you see no change when you scale the domain. Just guessing, but I think it may help.


All my objects transforms are the same I've imported a model from an .obj file. It imports fine, and I can see all the separate mesh objects that make up the model. But when I look at their object properties, all the transforms are the same for each mesh. I'm not really sure how that happened or what's going on; I wouldn't mind, but I'm exporting it via fbx to import into a game and it's screwing that process up somehow. Is there some local/global coordinate distinction I'm missing somewhere?

Select all desired objects in 3d View (Object Mode) and go to Object > Set Orgin and choose Origin to Center of Mass (Volume):

You can also call the operator using the Search Menu:

Press F3
Search for Set Origin
Press Enter
Select Origin to Center of Mass(Volume)

Read more here: How to recenter an object's origin?


How can I keep my animation in Orthographic when doing a final animation? I've rendered all of my images in Orthographic PNG and have them synced up to a song,

but now all of my square orthographic images are being stretched to 1920 x 1080 when I load them to my video sequence editor.

Clicking the "Image Offset" button will make them square/orthographic once again, but I'm worried that this is reducing the picture to a thumbnail size (not to mention reducing the quality as well).

I've looked through the forums and read the blender manual on animating and Ortho-Cameras but can't seem to find anything detailing the Orthographic image mode when finalizing an animation.

Here's my render settings:

Any help is greatly appreciated. :) cheers.

I've figured it out thanks to @Hendriks3D's question.

My Original render settings are set above, but when opening a new window and loading my images, the camera render settings were moved back to 1920 x 1080 which changes the rendered images regardless of original render size.

I just changed them to my 1080 x 1000 and Tadaa!!! it's all correctly shaped again. Thanks @Hendriks3D for pointing me in the right direction.


Symmetry error, false center So if u can see the photo, my center at my symmetry was wrong, anybody can help me?

As mentioned in the comment by moonboots, the origin of your character might not be in the center of your object. The origin is indicated by the little orange dot in the viewport.
In Object Mode you can set the origin. Select Object → Set Origin → Origin to Geometry in the menu of the viewport to center it. This should fix it.


bpy.ops.mesh.fill() Warning: No edges selected I'm attempting to write a background script to process an obj file. It's a single mesh with a hole at both ends; I want to fill in those holes with triangles for rendering purposes.

The shape is along the Y axis, with holes at X=0 and X=[largest X]. I appear to be able to find and select those edges, but bpy.ops.mesh.fill() continues to give a "No edges selected" error. I've tried using bmesh, and also bpy.ops.mesh.loop_multi_select(ring=False) (in every combination!) but nothing seems to make any difference. I'm about to give up and write the fill manually. My code so far is as follows:

import sys
import bpy
import bmesh

argv = sys.argv
argv = argv[argv.index("--") + 1:]  # get all args after "--"
filename = argv[0]
filenameOut = argv[1]

#Delete the cube mesh
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.delete(type='VERT')

#Import object:
status = bpy.ops.import_scene.obj(filepath=filename)

#Deselect everything
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action="DESELECT")
bpy.ops.object.mode_set(mode='OBJECT')

mesh=bpy.data.objects[0].data
EPSILON = 1.0e-5

#Find the highest X coordinate
maxX=0
for vert in mesh.vertices:
    if vert.co[0]>maxX:
        maxX=vert.co[0]

print(maxX)

i=0
for edge in mesh.edges:
    v1=mesh.vertices[edge.vertices[0]]
    v2=mesh.vertices[edge.vertices[1]]
    if -EPSILON <= v1.co[0] <= EPSILON and -EPSILON <= v2.co[0] <= EPSILON:
        i=i+1
        edge.select = True
        v1.select = True
        v2.select = True
print(i)

i=0;
for edge in mesh.edges:
    v1=mesh.vertices[edge.vertices[0]]
    v2=mesh.vertices[edge.vertices[1]]
    if maxX-EPSILON <= v1.co[0] <= maxX+EPSILON and maxX-EPSILON <= v2.co[0] <= maxX+EPSILON:
        i=i+1
        edge.select = True
        v1.select = True
        v2.select = True
print(i)

bpy.ops.object.mode_set(mode='EDIT')

#Just checking...
i=0
for edge in mesh.edges:
    if edge.select:
        i=i+1
print(i)

print("a")
bpy.ops.mesh.fill()
print("b")

bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.merge()

bpy.ops.export_scene.obj(filepath=filenameOut)

Output is as follows:

[importing file OK]
1.587500810623169
164
164
328
a
Warning: No edges selected
Warning: No edges selected
b
[exporting file]

Uh. What?
I could give the bmesh code as well, but it too seems to successfully select edges... only for the fill() to  give the same error.

I believe it's because I hadn't marked the object as active. I added

scn = bpy.context.scene
scn.objects.active = bpy.data.objects[0]

before doing the fill, and that seemed to fix the error. Of course, the fill was completely ... not what I'd expected so I'm persevering with a manual one for now!


How to assign vertex color to vertex color shader node? Hello I just recently learn about scripting in blender and I have problem attaching materials using script.

This is my code so far :

face = bpy.data.objects[nama]
face.scale =(0.00001,0.00001,0.00001)
face.rotation_euler.x = pi/2
face.location.z = 3.23

face.material.new(name = 'Skin')
bpy.data.materials["Skin"].node_tree.nodes["Vertex Color"].layer_name = "skin"

I try to copy the script from info when I do it via GUI and fail to do it on script.

The results that I want is like this, where the Base color change from default value into vertex color and select Col and then if possible named it into skin

Lemon's answer is almost correct but it has red label on vertex color and it makes my end result become dark

face.material.new(name = 'Skin')

'face' has no material property. And as the material is new, there is no vertex color in its node tree (and no node tree as it is).

You can:

mat = bpy.data.materials.new(name = "Skin")
mat.use_nodes = True #Make so it has a node tree

#Add the vertex color node
vc = mat.node_tree.nodes.new('ShaderNodeVertexColor')
#Assign its layer
vc.layer_name = "skin"

Now to link the vertex color output to the default principled shader:

#Get the shader
bsdf = mat.node_tree.nodes["Principled BSDF"]
#Link the vertex color to the shader
mat.node_tree.links.new( vc.outputs[0], bsdf.inputs[0] )

Additionnaly, if you want to add it to the 'face' object:

face.data.materials.append(mat)


How to change location, rotation, scale and dimensions of more objects at the same time? I'm trying to change the location, rotation, scale and dimensions of many objects at the same time. It's about 80 planes mapped with different textures. I've imported these planes using the addon "image sequence as planes". After having selected every plane,I see that I can change the value of only one plane. Is there another way to do this ?

If I understand it correctly and you just need to set the same value for multiple objects at once, there is simple trick for this purpose:

Select all the objects
Click the input field while holding Alt
Enter the value

In the default behaviour, new value is set only for the active object (the last selected one).


Can I use the timeline to erase keyframes? Is it possible to use the green bar in the Timeline to erase keyframes?

Is there someway to do something like erasing keyframes by scrolling over them instead of removing them one by one?

For 2.8 and newer:

This is now possible. Keys are shown as diamonds, like in the dope sheet. Mark them and hit X to delete them.

For 2.79 and earlier:

No; not in the timeline.
This is done in the Dope Sheet.

Hit B to select with a rectangle (or any other selection
method).
Hit X to delete selected keyframes.


Adding Edge Loops Around Airplane Window I would like to add an edge loop around each one of these windows and are not 100% sure on the best way to do it even after watching some videos.

If someone could point me in the right direction that would be great. Thanks.

Avoid NGons, and avoid Boolean operations, you topology is not quad-dominant and you wont be able to easily add edgeloops anywhere with ngons like those around the windows. in fact you will likely have a hard time doing anything at all with your current model.

Ideally your mesh should be made primarily of faces with four sides, use Ctrl+R to add edge loops, use Ctrl+B to bevel, use E to extrude, and abuse of modifiers.

In your case I am guessing a Mirror modifier would help with symmetry, a Subdivision Surface would help with smoothing/curving, and an array might help with multiple windows.


Shadow isn't casted on object I'm making an animation of Solar system and shadows of all planets are shown, except Saturns rings which have no shadows¸, although there's no light from the Sun coming to the certain parts of the rings. For Saturns rings I used torus.

But when I position the torus at a certain angle, it's completely dark.

This is torus' node tree.

And this is the node tree for every other planet.

My render engine is Cycles.

What could be the cause?

Thank you!

I made a similair setup and it seems to work for me.

As you can see, I also made use of a light source and put this inside the Sun sphere. There Are several things you need to check.

1) First of all you need to ensure if your light source has shadows enabled. You can check that out in the next image. Select your light source.

2) If you also decide to have the light source inside your Sun, you need to make sure the shadow of the Sun sphere is disabled as seen in the next image. Select your Sun.

3) Third thing to make sure is that you planet is casting the shadows on the rings. See here:

I've added a copy of the blend file:

Hope this helps!


Strange lines displayed in Edit mode after importing SVGs into blender I have a simple SVG file (plain, not Inkscape). I have imported it and scaled it up 2 or 3 times. When I switch from Object to Edit mode it seems like I have a ton of scattered points.

Object mode:

Edit mode:

Is this due to the image quality or my settings?

The lines, that you see are "normals" and shows radius, twisting and direction of curve.

You can do following:

1) change radius. For example if you press Ctrl+A in object mode(radius multiplied by object scale), when A(to select all), W -> Set curve radius in edit mode, it will reset radius to 1. Or change radius of selected points in  N-panel:

2) Also you can turn off displaying normals, or make them small. You can find this settings in N-panel (in edit mode):

3) Also, 2D-curve doesn't show normals. You can switch the type in curve settings


Proportional Editing - Vertices moving for no reason I have an arm mesh. When I try to rotate some vertices with proportional editing some vertices move with it for no reason.

This doesn't happen with all vertices.

blend file

You have turned on 'X Mirror' for edit mode. This is a a tool which will mirror changes in edit mode across the object's local X axis.

In edit mode you can turn this off by going to the 'Options' tab in the 3D view toolbar (T) and turning off 'X Mirror'.


Unbend object bent with simple deform modifier Basically, if I bend a subdivided plane on the Z axis 180 degrees with the Simple Deform modifier and I've applied the modifier, is there any way to undo that bend? I have a mesh that looks like A, is there any way to deform it into mesh B?
I've been trying to achieve that with another Simple Deform Modifier, playing with the origin, the angle and so on, but I've been completely unsuccessful in getting back to the original shape.

You can try this way:

Let's say you have object A (your half cylinder). Create a plane (object B), give it a Simple Deform/Bend modifier, bend it 180°:

Overlap the 2 objects (scale object B if necessary), give to object A a Surface Deform modifier with object B as Target, click on Bind:

Bring back object B to  an angle of 0°, object A will follow:


Separate joined objects I'm trying to make a small animation for chemistry, and I'm wondering if you could separate once joined spheres (as a molecule) again. Or is there another way handling this problem?

To separate the joined objects, go to edit mode and select all the vertices of object you want to separate. Then, hit p and click, "selection."


Using Blender for plotting graphs? While gnuplot is serviceable and matplotlib is a popular choice for Python developers, I wanted to use Python for plotting some simple graphs (matplotlib had some issues installing on my system, with one of its dependencies).

While I could spend time to fix the issues with matplotlib, my needs are quite basic and something Blender could be made to do without much trouble.

Are there some existing solutions to setup Blender for real-time, graph plotting?(which could be interesting to adjust input variables with real-time feedback for example).

Since asking this question, I've made a small (single script) plotting utility.

This could be made into an add-on however I find it useful as-is.

Usage:

Paste this script into a text-block named blend_plot.py and press "Run Script".
Running the script will create a blend_plot_func.py text-block containing an initial plotting template (if you don't have one already). eg:

def plot(x, **kw):
    return x

You could change this to, for example:

def plot(x, **kw):
    return 1 - ((1 - x) ** 2)

Playback animation (a curve object will be automatically created if you don't have one active already).
You can duplicate the object and move it around, only visible objects are handled, so hiding or moving to disabled layers can avoid extra computations.
If you want to change blend_plot.py (curve resolution for eg). Simply edit the values and run the script again.
You may want to turn your scene's FPS down, anywhere from 5 to 15 FPS (to reduce CPU usage).

Some benefits of this method:

Easy to view and change parameters for multiple plots at once (overlay or side-by-side, objects can be moved around since the script only updates object-data).
Easy drag values with real-time updates as well as using Blender's animation system.

Other details can be found in the code header.

# All in one plotting utility.
#
# - Uses a frame-change handler
#  (play back animation for real-time updates as you type)
# - Expects module `blend_plot_func.py`, to have a function called `plot`
#   which takes and returns a float and keyword arguments,
#   which are taken from custom properties.
# - Will update all objects in the scene
#   (supports multiple plots at the same time).
# - Scene and Object custom properties,
#   are passed to the plot function as keyword arguments.
#   (Scene properties are like `global` variables,
#   Object properties can be different for every object).

# Curve resolution
RESOLUTION = 320
# Range to show
RANGE = -1.0, 2.0
# RANGE = 0.0, 1.0

# Framing
MIN = 0.0, 0.0
MAX = 1.0, 1.0

PLOT_MODULE = "blend_plot_func"
PLOT_TEMPLATE = """
# Plot module template
from math import *

def plot(x, **kw):
    return x
"""

# End constants
# -------------

import bpy
from importlib import reload
from math import isfinite

def reinit_curve(context, curve):
    """ Initialize or re-initialize curve data.
    """
    curve.splines.clear()

    curve.fill_mode = 'NONE'

    # plot spline
    spline = curve.splines.new(type='POLY')
    spline.points.add(RESOLUTION)

    # frame spline
    spline = curve.splines.new(type='POLY')
    spline.points.add(3)
    spline.points[0].co.xy = MIN[0], MIN[1]
    spline.points[1].co.xy = MIN[0], MAX[1]
    spline.points[2].co.xy = MAX[0], MAX[1]
    spline.points[3].co.xy = MAX[0], MIN[1]
    spline.use_cyclic_u = True

def init_object(context):
    """ Call when we have no active plot-curve.
    """
    curve = bpy.data.curves.new(name="Plot Curve", type='CURVE')
    reinit_curve(context, curve)

    obj = bpy.data.objects.new(name="Plot Curve", object_data=curve)
    context.scene.objects.link(obj)
    context.scene.objects.active = obj
    obj.select = True

    return obj

def plot_callback_object(scene, obj, plot_cb, kw):
    from bpy import context

    curve = obj.data
    points = curve.splines[0].points if curve.splines else ()

    # re-initialize curve if we change settings
    if len(points) != RESOLUTION:
        reinit_curve(context, curve)
        points = curve.splines[0].points
    # print(kw)

    i_last = float(RESOLUTION - 1)

    span = RANGE[1] - RANGE[0]

    for i, p in enumerate(points):
        x = i / i_last
        x = (x * span + RANGE[0])
        try:
            y = plot_cb(x, **kw)
            if not isfinite(y):
                y = -1.0
        except Exception as ex:
            print(str(ex))
            y = -1.0

        p.co.xy = x, y

def plot_callback(scene):
    """ Runs on frame change, updates all objects in the scene.
    """
    try:
        plot_module = __import__(PLOT_MODULE)
    except ImportError as ex:
        # Create a new text block if this is the first execution.
        text_name = PLOT_MODULE + ".py"
        text = bpy.data.texts.get(text_name)
        if text is None:
            text = bpy.data.texts.new(name=text_name)
            text.from_string(PLOT_TEMPLATE)
        else:
            raise ex

    reload(plot_module)
    plot_cb = plot_module.plot

    from bpy import context
    obj = context.active_object
    if obj is None:
        obj = init_object(context)

    # use my keywords for all!
    kw_global = dict(scene.items())

    for obj in context.visible_objects:
        if obj.type == 'CURVE':
            kw_local = dict(obj.items())
            kw_copy = kw_global.copy()
            kw_copy.update(kw_local)
            plot_callback_object(context, obj, plot_cb, kw_copy)

bpy.app.handlers.frame_change_pre[:] = [plot_callback]


Is there a way to find out the last user operation using Python? I'm currently working on addon and need to replace Render and Render Animation user operations with addon operations. The perfect way would be to re-link Blender original UI buttons and shortcuts directly to addon operations while addon is enabled, but I'm not sure if it is even possible without changing Blender source code. Of course the most obvious way would be to add Render and Render Animation buttons in addon UI, but I really want to avoid this to keep everything user-friendly and familiar.

The only way I've found is to use a handler with a function which aborts original Blender render operation and replaces it with addon operations, e.g.:

bpy.app.handlers.render_pre(my_render_replace_function)

The problem is that my algorithms for rendering a single frame and animation are a bit different, so the addon have to know exactly what command user have used. And unfortunately there's no handler in blender like:

bpy.app.handlers.render_animation_pre()

I thought it would be possible to access Undo History somehow to get the last undo item and use it for choosing the correct algorithm. There is a method which gives an access to perform direct operations over the Undo History:

bpy.ops.ed.undo_history(item=0)

Writing a function which would search for the last item's number is also no problem using preferences settings to get maximum number of undo steps in the scene

bpy.context.preferences.edit.undo_steps

and, in case it haven't been reached yet, using "for" loop to check smaller numbers until that method returns something different from '{CANCELLED}'

The only thing I can not find is the way to find exact undo item's meaning or even type, because bpy.ops.ed.undo_history doesn't have such methods. So is there another way to access undo history to get exact item, not just its number? Or maybe another way to define what was the last operation and tell it to Python?

Actually if anyone could suggest any solution without using undo history at all, it would be even more appreciated, because we all know that the whole undo system in Blender currently is not the thing you want to deal with and it can be replaced with new one in any new build.

The solution for this particular task may be in using render_pre handler to change a global variable. The first frame has to be rendered anyway, so this is not a very elegant solution, but it will do for my purposes. This particular code has to be executed before every render to reset global variable.

import bpy

render_count = 0 # global variable

def execute_for_single():
    print('executing single frame')
    pass

def execute_for_animation():
    print('executing animation')
    pass

def check_for_animation(context, dummy): # needs 2 arguments to be used in handlers
    global render_count # use global variable
    render_count += 1 # change global variable
    if render_count <= 1: # 1 or less frame is being rendered
        execute_for_single()
    else: # more than 1 frame is being rendered
        execute_for_animation()
        render_count = 0 # reset global variable
        bpy.app.handlers.render_pre.clear() # reset handler

bpy.app.handlers.render_pre.clear() # just a cleanup before the start
bpy.app.handlers.render_pre.append(check_for_animation)

Also I found this:

bpy.context.active_operator

It returns the last executed operator, but needs the correct context, which I didn't manage to determine for render operators, even using the context override. But I guess for the most other operators it may be helpful.


Set up blender for printing/rendering to A4, A3, A2, A1, A0 paper sizes I want to create 3D art to print onto international paper sizes A4, A3, A2 etc.

How do I set up blender (cycles render) to render images at a resolution of 300 pixels/inch which will fit perfectly to the above paper sizes (without stretching)?

http://www.papersizes.org/a-paper-sizes.htm

Simple math:

1.) Get paper size from link above... e.g. A4 = 8.27" x 11.7"

2.) Multiply the dimensions by 300... e.g. A4 = 2481 x 3510

3.) Plug values into the Properties >> Dimensions >> Resolution and set scale to 100%

NOTE: You will need a printer that is capable of edge to edge printing.


duplicated object when rendering i'm almost through a tutorial by " Andrew Price " and after i finished the modeling and texturing

But when i rendered the Design i found out that the third small rail got duplicated i don't know why !

Look in the Outliner, you probably have an object whose visibility is disabled for the viewport (eye icon) but enabled for rendering (camera icon)

Or you have a duplicated object in a layer that is not visible on the 3D viewport but is renderable.


Need help installing addon on mac I can't figure out how to install addon from blender 2.73 onto my imac.
I go into addons in user pref. I enable addons.
I select /users/me/library/applicationsupport/blender/2.73/scripts/addons/
and then click install from file.
And I get:

  error! source file is in the addon search path: '/users/moi/library/application support/blender/2.73/scripts/addons/'

Blender searches for addons in three places, one of which is /Users/{user}/Library/Application Support/Blender/2.72/. If your addon is already there, then it is "installed".
The install from file button in the user preferences essentially just copies files into this directory.

If you don't see the addon listed in the user preferences, then there may be something wrong with the addon. Try starting blender from a terminal and see if there are any error messages.


Why can't I sculpt on a plane when using Subdivision Surface? When I add Subdivision Surface I just simply can't sculpt anymore, but...it works with multiresolution...any ideas why is that?

Thanks

Subdivision Surface modifier (or Subsurf) isn't designed to work with sculpting. Subdivisions added with it are accessible for sculpting only once the modifieir's applied. Multiresolution is the one which is designed for that, allowing to edit subdivided surface with sculpt brushes. There doesn't seem to be any real reason to sculpt with Subsurf.


Vector image as background I am making a video using chroma key effect. The foreground would be a movie file and the background would be a vector image created with "pdflatex" (initially the image is a pdf), so it is a pdf file.

In the compositing context of blender, I add a node "image" so that I could import my pdf background. However I can't import such file.

A pdf file contains both raster and vector elements so I tried to raster the file with inkscape as mentionned here or here  but it doesn't work and I find this method a bit messy (I have a lot of pdf files).

I try to change the compilation of my latex document to a format compatible with blender.... on-going

Thanks for your help

The compositor only imports bitmapped images like OpenEXR tiff png jpeg etc. Perhaps you could open the pdf in a pdf app then export it or try screen grabbing it. To use svg files you can try importing them as an object in the 3d view then film that with the 3D camera. This can be added to the compositor as a "Scene" node.


How would I go about creating a spiralled dome? Is there some elegant way I could go about creating the "twisted spiral" surfaced dome as you see in the iconic "St. Basil's Cathedral" in Red-Square in Moscow?

As usual, it looks as if this is simple enough to model, but the devil is in the details. Look closely at the flat space between each section, and notice how the twist is not entirely uniform either.

And I feel a non-destructive approach would be best, so that other variants of onion domes can be constructed fast.

My rendition:

start with a curve. I used the "extra objects-->Curves Galore, and used the flower:

I made some adjustments to the overall curve, and added a second circle in the same object while in edit mode (later I adjusted to this final version - it is hard to predict the exact shape at this stage):

Then I added a straight bezier profile curve, and subdivided this curve (W menu) about 5~7 times to get the resolution required for the lattice deformer at a later stage.:

Next, simple deformers are added to create a base twist and tapering (which makes it much easier to control when applying the lattice later). A taper, and a twist:

Create a lattice object. I used W:8 divisions.

apply the lattice deformer to the curve object, and start tinkering around with the size. Key ingredient: rotate each lattice sub division to control the twisting precisely.
This offers much more control than the simple twist deformer, allowing for a visually more correct twist like the one seen in the original onion domes.
Mine is a bit messy, because I was a bit in a hurry:

Done! Completely non-destructive onion dome, with a lot of control over the final result.

It literally take 20 seconds to change the profile curve, and generate quite complex bizarre looking domes:

Download the example blend here:

Addendum: adding small circles in the base curve object creates very pronounced "ridges" as seen in the original:


Object inner is black with clipping camera for cutaway view - add inner lighting? I am using cutaway view with camera clipping, and managed to show the cut area by geometry node, looks soo good, but see the image there is a cube with room inside,
it is black because no light can pass through...

you agree - it looks awful ;)

If I uncheck "Ray Visibility" of the object with Shadow or Diffuse it also doesn't look so good because shadows of the objects are missing in general.

Is there a node trick to bring light into the darkness...?

As a solution I also could add a pointlight into the geometry...
but is there anyting better ?

This is because the geometry is still there, even though it's not visible to the camera. Rays bouncing through the scene will still interact with such geometry.

Instead try something like in my answer here.


Python, How to Roll a Pose Bone along a Vector in PoseMode? I'm stuck, Trying to roll a pose bone while staying in the Head and Tail vector. When I use axis angle or any other rotation, it doesn't stay in place and it goes off its vector.
Vector shouldn't change and rolling angle is the variable.

Rolling a pose bone.
Using python, how do you get the "roll" of a pose_bone?
IMO this is simply a case of rotating the bone around any pivot point that is on a line parallel to  y axis vector passing thru points head and tail.
Matrix math to translate, rotate, scale with respect to a pivot point in Object mode
import bpy
from mathutils import Matrix

def rollposebone(pb, roll):
    R = (
         Matrix.Translation(pb.head) @
         Matrix.Rotation(roll, 4, pb.y_axis) @
         Matrix.Translation(-pb.head)
         )
    pb.matrix = R @ pb.matrix

# test call, roll 3 degrees.
from math import radians
context = bpy.context

rollposebone(context.active_pose_bone, radians(3))

Please also note that blender  natively uses radians, as does math and numpy. Recommend using as above, ie if you wish to pass a value like 90 degrees pass via radians(90) rather than converting to and fro in code.  If making a UI give any angle property a `unit = 'ROTATION`` and it will be displayed in the chosen rotation unit, which is by default degrees.


Align plane to ground I'm sorry, I'm sure this is a very easy function, but I'm having a hell of a time.

I have a bunch of 2 and 3 poly planes that I need to align to the xy floor. As is, they are floating in space, with random rotations. I made a plane to align to, thinking that might be the easiest way, but I can't seem to get the rotation, it aligns origins, even though I have normal selected in the transform orientations.

Create an empty and turn on face-snapping with influence on move and rotate before snapping it to your rotated plane(empty is aligned):

parent the rotated plane to the empty and finally set the rotation of the empty as 0, 0, 0 before clearing the parent-relation:

explanation: the problem with the snapping without the empty is that there are no object rotations in Edit Mode, but only single vertices and their locations. If your rotation in Object Mode is applied (0,0,0) or not represented in the Edit Mode transformation of your rotated plane, then there is no difference to align to an other object also having 0,0,0 rotation in Object Mode. Only the transformation of the of the new empty (0, 0, 0) to the normal of your plane allows to rotate the plane in relation to this newly formed difference.


I'd like to draw a mesh on a Nurbs surface I am getting started on Blender so this might be a little too basic but I searched for it in both the manual and the forum and I couldn't figure it out. The thing is that I drew some intersecting Nurbs surfaces:

The point is that I would like them to have a mesh or a grid on them so the limit of each surface is more visible. The alternative would be to draw a mesh/grid and shape it this way but I'd like to know if this can be done (easily if possible).
Thank you!

If all you want to do is visualize the surface as a mesh, you can turn on Wireframe in the Viewport Overlays menu


How do I know if Blender is making use of CUDA to render? I am using Blender 2.69 from the Linux Mint Software Manager on a system with a GTX 950, just checking to see if it will recognize CUDA. After some work, I've gotten the CUDA drivers from Nvidia installed and now there is an option to use CUDA as the compute device in the user preferences. I also selected GPU compute in the properties panel. I rendered a short, one minute clip of video using Cycles Render and monitored my GPU usage in Nvidia X Server settings. It didn't seem like the GPU was being used much (hovering 5-10%) but the video did render a little quicker than I expected.

How can I know for sure if Blender is using my GPU to the fullest to render?

If you have properly set up CUDA and selected GPU Compute in the Render Properties panel then Blender should be using your GPU.  (Though I have seen instances where having two different Blender files open separately and both rendering switches the GPU one to CPU mid-render.)

Probably the easiest way to make sure that Blender is utilizing your GPU is to use some sort of monitoring program.

My Favorite is NZXT CAM, it's pretty sleek and works very well.  CAM monitors and gives graphs of CPU and GPU load, temperature, voltage draws, and fan speeds.  It also shows which programs are using the most load.

HW Monitor is another very popular choice, it doesn't have all the options that CAM has though.  It basically just shows you the current values, minimum, and maximum of each spec.


How to render a background image correctly? I have followed this tutorial:https://www.youtube.com/watch?v=ua7K4HvbfzA

And everything looks great in rendered view. But when I rendered image, it rendered the object first but put the background image in front of the object in the end. So what I could see after rendered image was the background image. Does anyone know what I ignored or what happened?

My guess would be that You missed to check the "transparent" checkbox under "film" in the "render" tab. Furthermore, You, perhaps, have switched the inputs in the "alpha over" node. See image to find critical settings marked with red circles.


Transforming Blender Render Textures to Cycles Textures I am having some really tough trouble translating my blender materials to my cycles rig. Normally I manage to work it out by looking at YouTube videos, but I am moderately new to Blender. I want to transform my project to Cycles because I was getting to much noise in the render, is there a good way to eliminate noise in a Blender Render?

In the Blender Render project I assigned a texture to the material now when I do this in Cycles, the rig texture comes out really fuzzy. I have disabled mipmaps in user preferences and the texture has a FELINE filter, but it still comes out blurry.

Please help if you can.

Thanks.

I'm not sure what you mean by eliminating noise in Blender Render if you are moving to cycles, but if you are looking to remove noise in cycles, there is already several answers in Blender StackExchange FAQ: Frequently Asked Questions on Blender Stack Exchange

BlenderGuru made also a great article about the topic: https://www.blenderguru.com/articles/7-ways-get-rid-fireflies/

For the second question, by looking at your texture I assume you want pixelated look. Answer is very simple, you can turn back your mips and get rid of the filter. All you need to do is set Sampling, the second field under the image name field currently have set as Linear to Closest.


Rigid Body Problem, Active objects stay rigid, its not working Gravity seem off in the world. I made a big cube and a lot of little balls(50) at the top inside. I want them to fall to the floor, but things are off in my blender rigid body World. The balls are the active ones, and the cube the passive one. both have collider added with default settings.
When I tried to do a bake with the balls together in a collection and the cube  a constraints, things do not go the way I thought they would. A large portion of the balls stay rigid, and a few fly off in all directions but not to the floor. Any Ideas as to what setting i may have forgotten or what i did wrong?

The little balls are inside the big cube? That's not going to work with default settings. You either need to model the floor, walls and ceiling as separate objects, or set the cube's rigid body shape to mesh. While you're at it, set the balls' shape to sphere and choose good values for mass and bounciness.


How can I create dynamic brick/tile-like geometry? I want to create something like this:

The key requirements are:

Must be actual geometry. I'm going to be 3d printing this, so I don't think using materials will help me here.
Would like to be able to adjust the width of the gap/grout
Would like to be able to control the number of/density of bricks to some degree
Bonus points: would love to be able to add a bit of noise/random rotation to the bricks as a last step

So far what I've been doing is slicing up planes with the knife tool, insetting the faces, extruding them, and then using a boolean to cut them all into individual bricks. But the manual slicing is tedious (especially if I want to make 100 different versions of this), and I can't really go back and modify any of the parameters after I'm done. Again, I will be 3D printing this... so I'd like to be able to create the mesh, print it, check for printing problems, and then go back and tune/adjust the mesh easily.

The Wall Factory is a step in the right direction, and it's already included in blender.

To activate, go to User Preferences (Ctrl + Alt + U). Then go to the Add-ons tab and enable Add Mesh: Extra Objects.

To add a new wall, press Shift + A and then go to Mesh > Extras > Wall Factory

However, it doesn't look like I can go back and modify things like brick size or grout width after I've created the wall.


Copy object from hidden layer with Python Is there a way to duplicate object located on inactive layer? bpy.ops.object.duplicate() doesn't do anything.

>>> D.objects
<bpy_collection[3], BlendDataObjects>

>>> C.object.layers[10] = True
>>> C.object.layers[0] = False
>>> C.object.select
True

>>> bpy.ops.object.duplicate()
{'FINISHED'}

>>> D.objects
<bpy_collection[3], BlendDataObjects>

Just use copy()  then link to the scene:

obj = bpy.data.objects['Cube'] #object you want to copy
dupe = obj.copy() # copy object
bpy.context.scene.objects.link(dupe) #links the copy yo the scene


How to import from subdirectories? I try to import from the file "boolean_2d_union" the function but fail to be able to get this right.

I have the following structure

add-on folder:
   __init__.py
   addons (folder)
       boolean_2d_union.py

Here is the script of my ini file.

   bl_info = {
    "name": "Fullscreen Modeling Pie Menus",
    "author": "Claas Kuhnen",
    "version": (1, 0),
    "blender": (2, 75, 0),
    "location": "View3D > Pie Menus",
    "description": "Pie Menus for Modeling and Object Properties",
    "warning": "Beta - Concepy Study",
    "category": "User Interface",
}
import math
import bmesh
import bpy, os
from bpy.types import Menu, Header, Panel, UIList
from bpy.props import IntProperty, FloatProperty, BoolProperty,EnumProperty,StringProperty
from mathutils import *

from boolean_2d_union import Boolean2DUnion

class PieTest(Menu):
    bl_idname = "pie.test"
    bl_label = "Pie Test"

    def draw(self, context):
        layout = self.layout
        pie = layout.menu_pie()
        #4
        pie.operator("bpt.boolean_2d_union", text="Import Test")

addon_keymaps = []

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

    wm = bpy.context.window_manager

    if wm.keyconfigs.addon:

        #Viewport Shade
        km = wm.keyconfigs.addon.keymaps.new(name = 'Object Non-modal')
        kmi = km.keymap_items.new('wm.call_menu_pie', "RIGHTMOUSE", "PRESS", shift=True, ctrl=True)
        kmi.properties.name = "pie.test"

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

    wm = bpy.context.window_manager

    if wm.keyconfigs.addon:
        for km in addon_keymaps:
            for kmi in km.keymap_items:
                km.keymap_items.remove(kmi)

            wm.keyconfigs.addon.keymaps.remove(km)

    # clear the list
    del addon_keymaps[:]

if __name__ == "__main__":
    register()

I always get a syntax error:

I added a link to the add-on zip file URL

Inside the file boolean_2d_union.py this is the following code:

class Boolean2DUnion(bpy.types.Operator):
    bl_idname = "bpt.boolean_2d_union"
    bl_label = "Boolean 2D Union"
    bl_options = {'REGISTER', 'UNDO'}

To learn more about importing from subdirs, you should be reading Stackoverflow and googling stuff like 'how to import from sub directories in Python` : python-import-a-file-from-a-subdirectory , this is a general Python question and has many good answers and links.

I'll answer the Blender specifics (reduced version) of this code. no pie, no keymaps. We can test if a class/Operator was correctly imported and registered by using the spacebar menu and search for the operator's bl_label ( here Boolean 2D Union ) , and launch it from there.

That operator has a poll to test if at least two faces are selected before showing up in the menu or spacebar search. Here you can see we successfully imported that class and registered it.

Importing from sub directories

I've prepared a small zip at this repostory : https://github.com/zeffii/some_test_addon , which you can Install from File.

if your add-on's folder structure is like this.

addon_name     <-- avoid spaces in the add-on folder names
|
+ __init__.py
+ included_addons   <-- avoid folders named just 'addons'
  |
  + __init__.py   <---  (often empty) tells Python that this folder is a module.
  + boolean_2d_union.py

it should work this way, from the top level __init__.py

bl_info = {
    "name": "Some Test Addon",
    "author": "----",
    "version": (0, 1),
    "blender": (2, 76, 0),
    "category": "User Interface",
}

import bpy

from .included_addons import boolean_2d_union

def register():
    # this line will throw an exception if you press F8 and don't
    # have any classes defined in this __init__.py file, but usually
    # this file has at least some classes either for a property collection
    # or addon preferences.. or a menu drawing function.
    bpy.utils.register_module(__name__)

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

Registration

When boolean_2d_union.py is imported, Boolean2DUnion is registered for you by bpy.utils.register_module(__name__).

There are many subtleties attached to multi-file addons regarding reload code and I think this is outside of the scope of your question, but further reading is suggested.

See more information about the reload event here: Blender ignores changes to python scripts
See the mesh_tinyCAD add-on's structure for a multi-file example with load / reload code that I think you can get your head around.

some insight

Does this work if I hit F8 (accidentally or intentionally). You might temporarily add some print events into __init__.py to get a sense of what's happening during that reload event, and get an idea of what has been loaded when.

bl_info = {
    "name": "Some Test Addon",
    "author": "----",
    "version": (0, 1),
    "blender": (2, 76, 0),
    "category": "User Interface",
}

import bpy

if 'boolean_2d_union' in locals():
    print('1 -- RELOAD EVENT (f8)')
    print("don't need to reload an unchanged file")
else:
    from .included_addons import boolean_2d_union
    print('2')

def register():
    print('3')
    bpy.utils.register_module(__name__)
    if 'bpt' in dir(bpy.ops):
        print(dir(bpy.ops.bpt))  # will show   ['boolean_2d_union']
        print('4')
    print('5')

def unregister():
    print('6')
    bpy.utils.unregister_module(__name__)

Read the source of any of the multifile add-ons to see how they deal (or don't deal) with the F8 reload event. As a developer it's handy to have reload handling code so you don't have to keep closing/reopening Blender. Sometimes it is inevitable to have to close/reload, but get F8 working first and then if the reload didn't pick up your changes

either fix the reload to take new files into account
or restart


Light Path node works weirdly for Background For some reason, LightPath node doesn't work expectedly. When I plug in 'Is Diffuse Ray' output, I want to exclude all Diffuse rays but they stay. It works for Glossy ray and Camera ray, but why don't work for diffuse rays

Here I have added more explanation for my question above
For Glossy shader, all work exactly how expected: for Cycles engine and HDRI background I can exclude Glossy surfaces from the scene (make a mask)

But for Diffuse shader, when I use Cycle engine and HDRI I can exclude diffuse surfaces, for some reason, it doesn't work how it works for Glossy shader shown above

But when I try to use a flat colour background for Cycles, It becomes possible to exclude diffuse surfaces

or with HDRI but switch to Eevee it also works well

Okay, in the end, my simple question is why when I am using HDRI background and Cycle I can exclude Diffuse surfaces how it works well  for Glossy surfaces for instance

Using a Mix Shader node and 2 background nodes will give you better results and more flexibility than multiplying the strength of the entire world. you can also sorta "mask" it out and add whatever youd like on the 2nd background node and show one thing in the sky but for diffuse light bounces to react to another thing.

but if you absolutely need to use the node's strength, then doing it without any sort of multiply works, if u need to multiply it, then add a multiply node and/or an invert node to change the background's strength, with shouldnt be a problem with my method since the strength socket is available
EDIT: with what u said in comments, that would need to be done in the compositing of the scene. you would need to enable diffuse layers for indirect diffuse, then use that as a mask/factor for the other ndoes

this will take all light bounces coming from diffuse surfaces to the camera and use them as a factor, take note this will also affect other diffuse indirect bounces though. or, you can play around with materials and use the light path node on them and experiment a little