text:
How to fill a corner in
I'm trying to fill in this corner to be precisely square (see the image below). There are several ways I've come up with, but they're all terribly time-consuming and inefficient. I'm new to Blender, and I'm 100% sure there is a better way. I'll save us some time and not explain the methods I came up with.
How would you fill it in?

The red lines I added to the image is in paint as to visually represent what I'm asking.

Tab into edit mode

Enable the 'magnet icon' which is the snapping tool.This is used to snap an edge,vertex,face,volume etc.

Next, enable the other icon which has 'two dots in the corner and a line connecting it'.This is the 'Auto merge' option.It is very useful and it automatically merges overlapping faces vertices or edges. But Auto merge doesn't remove internal faces

Now with all these tools enabled select your face and press 'E' to extrude.

Hover over the edge in which you want the extrusion to stop. Now left click to finish.

And viola!! you have filled your mesh!

The tools used here:(just in case you have trouble understanding)

Name: Snapping/Snap tool

Modes
Object, Edit, and Pose Mode

Shortcut
Shift+Tab

The ability to snap objects and mesh elements to various types of scene elements during a transformation is available by toggling the magnet icon in the 3D Viewport’s header buttons.

Vertex
Snap to vertices of mesh objects.

Increment
Snap to grid points. When in Orthographic view, the snapping increment changes depending on zoom level.

Edge
Snap to edges of mesh objects.

Face
Snaps to the surfaces of faces in mesh objects; This is useful for retopologizing.

Volume
Snaps to regions within the volume of the first object found below the mouse cursor. Unlike the other options, this one controls the depth (i.e. Z coordinates in current view space) of the transformed element. By toggling the button that appears to the right of the snap target menu (see below), target objects will be considered as a whole when determining the volume center.

Edge Center
Snaps to the middle of an edge. This snap element only pertains to mesh objects.

Edge Perpendicular
Snaps to the nearest vertex in an edge that makes a perpendicular angle. This snap element only pertains to mesh objects.

NOTE
Multiple snapping modes can be enabled at once by Shift-LMB the different snapping elements.

Auto Merge

Mode:   Edit Mode

Menu:   Sidebar ‣ Options ‣ Tool ‣ Auto Merge

When the Auto Merge option is enabled, as soon as a vertex moves closer to another one than the Threshold setting, they are automatically merged. This option affects interactive operations only. If the exact spot where a vertex is moved contains more than one vertex, then the merge will be performed between the moved vertex and one of those.

Nice execution. Though Auto merge doesn't remove internal faces, so you'll need to remove that one manually :)

oops  thanks for that Jachym,I'll edit my answer :)

This is an awesome answer! I would have been wasting time doing it some dumb way for weeks probably. The other answers were good enough for me, but this is even better; thank you! Also, I'm glad you guys here didn't chew me out, because my question wasn't perfect, like they do on programming forms.

Really happy to hear!!! :D

@Abrobot If you see someone being rude or unkind to you (anywhere on Stack Exchange), press the little flag icon next to their message, and then pick an option (probably Unfriendly or Unkind if they are being rude), and someone will take care of it. Also, Stack Exchange has a Be Nice policy, so being rude is not tolerated anywhere on Stack Exhcange and the moderators will deal with it when comments get flagged.

Assuming this is a right angle, I would:

Turn Snap -> Vertex on.
Select one of the narrow faces that is inside the corner.
Extrude, and snap to the far edge of the other narrow face (the corner is now filled, but we’re not done).
Select all.
Merge -> By distance.
Select none.
Navigate your view to inside the geometry, and select the two narrow faces (there may be only the unextruded one left, though).
Delete -> only faces.
Select all.
Delete -> Limited dissolve (optional).

I thought of something similar, although I didn't know about the snap vertices thing, so that's why it failed when I tried, but is that really the best way? Seems like they would
have something built-in for something so simple.

@Abrobot well… it’s actually not that simple. It is simple if the assumed case is made up of all right angles, but that’s getting really “special use”-ish, and general purpose tools would be much more flexible while being only a bit more complicated to use.

Here's what I would do.

Here's a replica of your mesh.

Select the bottom vertex in Edit Mode as shown. Hit N on the keyboard to bring up the properties menu and click on the Global. Copy the Z of the vertex.

Select the bottom left two vertices and extrude them along the Z Axis by pressing E and Z consecutively. The location is irrelevant.

Don't select any other vertices. Go to the Z in properties menu and paste the copied Z value from step 2.

Now, fill in the faces by selecting the corresponding vertices and pressing F. Repeat this for the underneath and back of the mesh.

And that's it. You may want to delete the residue vertices from before, but that's completely opinion based. I wouldn't, so that I have more control over the mesh.

As with Ribbit12's answer, the resulting geometry is non-manifold due to 2 internal faces (edges connected to those 2 internal faces are connected to 3 faces, while in manifold geometry each edge is connected to exactly 2 faces). Not that it makes it wrong, but many tools like subdivision give weird results (and spawn questions here on BSE) due to non-manifold geometry. Of course removing those faces is a trivial task, you can select them in wireframe/x-ray mode and remove.

You can make walls without thickness and then add the Solidify modifier with the Even Thickness option checked:

I actually thought of this, but in this case, I wanted the corners for later. Also, I just wanted to know the answer to learn how, but that's for the comment. besides that, how did you know the exact shape of my building?

It's less time consuming to cut corners with knife tool with angle snap and cut-through enabled from top orthographic view after applying the solidify modifier.

Cool, ill keep that in mind; thank you!


text:
How exactly does the coordinate system work in Blender shader?
I am trying to understand how the Blender coordinate system works in shader.
So I create a plane with this simple shader:

I tried to move the coordinate origin point with a vector math node to the right, and this what happened:

I thought it would go to the right.
What exactly happened?
Another thing:
What will happen to the origin point when I use noise texture instead of one value?

You are not moving the object in this case, but the center for the mapping, which is why it is shown to you this way. But please try to ask only one question per post, so that a clear answer can be given. One question, one answer. Thank you!

The origin… Of the confusion
I wanted to say how everyone else is wrong, but that would be way too pedantic, maybe even misleading, like saying a hole doesn't exist, because it's not made of matter – and yet you can still fall into it.
Or another analogy: some people claim you can exceed the speed of light, because you can point a laser at one side of the Moon, and suddenly move it to the other side:
See how to break the “cosmic speed limit” of light by using a laser
The moving dot is only an illusion, though.
Let's come back to Earth: in Blender there's a common misconception that you somehow operate macroscopically on data, like moving the entire coordinate system, or brightening an entire image. Meanwhile this is not what actually happens; your node tree is compiled into a program, and this program is run for each sample of a ray. So, pedantically speaking, those statements are actually false:

❌ You are […] moving the […] center for the mapping

❌ what you do with your node setup is moving the origin of your texture coordinate system to the right.

❌ The texture itself is placed

❌ the texture moved to the left

❌ the average effect will be to move the whole coordinate field

I can't stress this enough; all above statements are also true on some level. The problems appear when you overinterpret those statements and take them too literally. Like when a biologist uses words "purpose" and "goal", and creationists quote it as a confirmation of a designer, while those terms are only figures of speech describing how an organism changes due to a gene, benefits from it, and therefore the gene outcompetes other genes.
What actually happens
You design your node tree. Blender parses it, and compiles it into a shader code – roughly speaking (I'm not that fluent on Blender source), each node becomes a function, and links between nodes represent which function's returned value is passed to which function as an argument (input). Then the code is uploaded to the GPU, and then when the camera shoots rays, the code is run for each sample.
One of the GPU cores will be tasked to render the x=50, y=100 pixel of a 200×200 px render. A ray is shot from ${(50, 100)\over(200, 200)} = ({1\over4}, {1\over2})$ to figure out the color of the pixel on ¼ of the middle line:

The shader program is run, with all necessary input data passed to it—here it's just the ray hit position in the object (local) space:
pos.xyz = -0.5, 0, 0
pos is then passed as the surface color, and xyz components are interpreted as rgb; negative values are clamped to 0, so it's just a black color.
What if you add $0.7$ to your x component?
$$(-0.5, 0, 0)\\+(0.7, 0, 0)\\=(0.2, 0, 0)$$
pos += 0.7, 0, 0
So now the pos variable represents this spot:

But here's an important thing: the code on GPU still runs processing the pixel x=50, y=100. You didn't move; you simply changed a variable. If you reinterpret it as RGB, this time you end up with a dim red color…
And what happens when you sample a texture?
If you used Generated coordinate space, the same camera pixel will have an input of:
pos = 0.25, 0.5, 0
And the sampled color will be some shade of red:

But if you add 0.25 to the x coordinate, you will sample a different point on the texture:

Remember, you're not actually changing which camera pixel you're processing. You can only change which texture pixel you're sampling. So you're not moving 0.25 to the right, you're moving something being 0.25 to the right of you, to self (to the currently processed pixel). Repeat it for all pixels and [it looks like] the texture moved:

simply ... wonderful ... puts everything in the shade ... this is how you correct scraps of words when you have a clue about the subject matter

Thanks @Peter Mortensen! The "EVERYONE ELSE IS WRONG" part was supposed to capture an OCD character of pedantism ;) I'm going to study the links given in edit summary…  quellenform thanks for kind words, perhaps too kind ;)

Thank you very much. This is the answer I was looking for.

Concerning your first question: what you do with your node setup is moving the origin of your texture coordinate system to the right. The texture itself is placed such that the texture's origin is placed at the origin of your object. As the object's origin stays fixed (at 0,0,0) the texture moved to the left when you move its origin to the right. You get even more control if you use the "Vector -> Mapping" node, which allows translation, rotation and scaling.
You get a more intuitive result of your texture mapping if you switch the mapping type from default "Point" to "Texture". Then the texture coordinate will move to the right if you translate in the positive x-direction.
Concerning your second question: I believe (didn't look into the code of the "Noise" texture" node) the texture coordinate is calculated in a random way for every point on your plane, depending on the noise settings like granularity, detail, etc.

Noise Texture -> Color outputs a random positive value between 0 and 1 on each color channel for every point on a mesh surface.  So the average effect will be to move the whole coordinate field in the positive direction by (0.5, 0.5, 0.5) while producing good local randomization.

source: Stack Exchange

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

sort: votes


text:
How can I calculate the distance from the 3D cursor to a 3D object?
I want to determine the distance from the cursor to the surface of the grey object following the y-direction. I tried to do this with ray_cast, but this doesn’t give any solutions. How should I handle this problem using Python?

Hello, could you add a little more information about what you tried with the raycast method and where it failed ?

@Gorgious I first changed the coordinates of the cursor to the object space of the grey object using matrix_world.inverted. To raycast I tried: greyobject.ray_cast(cursor_in_object_space, (0,1,0)) This gives as a result: (False, Vector((0.0, 0.0, 0.0)), Vector((0.0, 0.0, 0.0)), -1) Even if I try this ray_cast method with a simple cube I get this as a result.

Do any of the code in answers work for you with default cube, If not what is your blender version?

@batFINGER the scene.ray_cast works, but the object.ray_cast not

To clarify, this is with code from answer, not  a modified version of it, then ... Shrugs, added test run results of simplistic raycast from origin to inside  of default cube and get the  expected  hit in both instances.  If it is modified code that does not work edit it into question.

Since pretty much all raycast Q&As are deprecated because the method takes in the depsgraph and not the view layer since a recent patch and I couldn't find an exact duplicate, here's how to do it :
Make sure to hide any objects between the origin of the ray and the target or else it will fire a false positive.
import bpy

C = bpy.context

# Get evaluated Dependency Graph :
dg = C.evaluated_depsgraph_get()
# Set the ray Begin to the cursor location (in world coords by default)
ray_begin = C.scene.cursor.location
# Set the ray direction
ray_direction = (0, 1, 0)

# By default the ray will be fired with a near infinite length.
# If the script stutters consider adding distance=100 for instance as a parameter
cast = C.scene.ray_cast(dg, ray_begin, ray_direction)

if cast[0]:
    print(f"Hit '{cast[4].name}' at a distance of {cast[1][1]} along Y axis")

Result :

Thanks for the answer!

Closest point on mesh.
Ooops on re-reading the question looking for a ray direction, this instead returns the closest point on the mesh to the cursor
Similarly to Getting a closest point to 3d cursor gives a wrong result each blender object has a closest point on mesh function.
Example code closest point on context object (mesh) to scene cursor.
import bpy

context = bpy.context

scene = context.scene
ob = context.object
mw = ob.matrix_world
mwi = mw.inverted()

hit, loc, n, idx  = ob.closest_point_on_mesh(
        mwi @ scene.cursor.location,
        depsgraph=context.evaluated_depsgraph_get(),
        )
if hit:
    # global distance to hit
    print("HIT distance:", (mw @ loc - scene.cursor.location).length)

Test run on default file. .. Cube is
HIT distance: 0.9999996423721118

from default cursor location.
Object ray cast.
Similarly to scene raycast, beautifully  illustrated by @Gorgeous, there is Object.ray_cast which like closest point on mesh uses local coordinates.
As well as using local coordinates, the object's ray cast method is only interested in itself, and hence forth wont hit any other objects that may be in the path.  (Would need to hide them first)
Script above, same as above, except casting from scene cursor in a direction based on the local coordinate space. (local x direction of context object in this case)
import bpy

context = bpy.context

local_ray_dir = (1, 1. 1)
scene = context.scene
ob = context.object
mw = ob.matrix_world
mwi = mw.inverted()

hit, loc, n, idx  = ob.ray_cast(
        mwi @ scene.cursor.location,
        local_ray_dir,
        depsgraph=context.evaluated_depsgraph_get(),
        )
if hit:
    # global distance to hit
    print("HIT distance:", (mw @ loc - scene.cursor.location).length)
    # add empty as child at local hit location to test.
    bpy.ops.object.empty_add(
        location=loc,
        )
    context.object.parent = ob

Result on default file, (1, 1, 1) corner of default cube hit $\sqrt3$ from origin
HIT distance: 1.7320499816624955

Shrinkwrap
Another method to look at would be adding a small mesh and projecting it onto the target via shrinkwrap.

Result, some hit some miss given initial location
Proof of concept script. below, without:, but If a better choice of object, with a vertex group  some verts left out, the y dimension of the modified object will be the distance from object of interest, if any find the target.
import bpy

context = bpy.context
scene = context.scene
target = context.object

bpy.ops.mesh.primitive_ico_sphere_add(
        radius=0.1,
        location=scene.cursor.location
        )
ob = context.object
sw = ob.modifiers.new("Shrinkwrap", 'SHRINKWRAP')
sw.target = target
sw.wrap_method = 'PROJECT'
sw.use_project_y = True
#sw.use_negative_direction = True
sw.use_positive_direction = True

Oh, right it makes sense to use the object ray cast there (no need to worry about obstructing objects) ! I never catched that it's used to test one mesh against rays coming TO it, not FROM it. There is something about matrices that make me want to try any other possible solution which doesn't involve them if possible x)

Surely you mean nodes, lol.  If and when matrices "click" you never look  back.

Thank you for the useful answer!

Cheers, given your comment under question, that I also missed, speculate the issue is space related, , is there any rotation on object of interest?

No the object of interest is not rotated.

The object.ray_cast still does not hit, while it should when looking at my 3d viewport. Can it be a problem with the way I imported my object? I used bpy.ops.import_mesh.stl and then I did ob = bpy.context.selected_objects[0]

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


text:
Can you make an ID map for scattered objects?
Basically I have assets that are scattered across a map (with the scatter add-on) and my programmers need an ID map to identify each asset separately. I'm new to Blender, but the way I would approach this in maya would probably be to do a "separate object" command and then to automatically generate my ID map. What would be the process on Blender and how can I execute it?
Thank you!


text:
Any way to separate objects with the scatter add-on?
Are there any way to separate each objects generated from the scatter add-on?
I'm new to blender so maybe the answer is very obvious, but I've seen no one talk about this online

Select one of the scattered objects and press ⎈ CtrlA to open the Apply menu, and hit Make Instances Real. And if you would like to put them all in a collection, right away you press M to call the Move to Collection operator and select the collection desired.

Thank you so much!

@LisaItsame while commenting thanks on an answer is always appreciated, an even better thing to do on this website is to  upvote the post that helped you. If you feel it completely solved your issue consider marking it as accepted. This rewards the authors with points and helps better referencing the answer for anyone trying to find it.


text:
Artifacts when rendering volumetrics
When making a scene with volumetrics in cycles (blender 4.2.3)I've run into an unexpected problem.
Almost every time I render (or almost every frame when I want to render an animation) I get these weird horizontal lines spreading from one end of the picture to the other. From what I understand, they appear pretty randomly: random place, random time, random sample when rendering.
I have done quite a lot to try to resolve the issue: updated the gpu drivers, tried changing the light paths in a number of ways, changed the max samples, tried both CUDA and OptiX, checked the denoiser, tried tiling when rendering (when I did that, the lines were from one end of the tile to the other, not the entire image), changed the feature set to experimental. I even tried making a test file with nothing but a cube with a principled volume shader, and I still got the same artifacts. Without the volumetrics, everything works just as it should (at least I think so).
I am running an RTX 2080ti with a ryzen 5 5600X. When rendering, my GPU memory doesn't exceed 30-40%, so I don't think that the issue is there either. The temperature also remains under 60-70 degrees celsius (which is not bad considering how bad my PC cooling is).
These artifacts show only in blender 4.2.3 LTS, when I tried the same file in 4.0 nothing was out of the ordinary (but the results were underwhelming, because of the older cycles version).
Any help would be greatly appreciated.

Cycles haven't change much (at all ?) recently, maybe try using 4.1 or 4.0 instead ? Sharing your file would also help so that we can see if there is an issue inside it : https://blend-exchange.com/

I think that it has, since the scene looks brighter in the 4.2.3 LTS than in 4.1. This is the link for the file and more screenshots: https://drive.google.com/drive/folders/1KNLMXHJF8KKKaPksOmOigiKUtSoB9WgH?usp=sharing

As far as I can tell, there has been new features but no changes on the engine itself, release notes of 4.2 : https://developer.blender.org/docs/release_notes/4.2/cycles/. I'm not getting any artifacts with your file, maybe try updating your GPU ? Do you also get artifacts with the denoiser disabled ?

I updated the drivers and it's not the denoiser. It's quite insteresting why it worked on your machine. I was thinking, that it just might be my GPU, but then why would it work on earlier versions? Thanks for the replies so far :)


text:
When adding new vertices to a mesh, it messes with the model's weight paints
I'm trying to make a stylized model, with colors set up by using the knife tool and assigning different faces with different materials. I noticed after making the rig though that when I continued trying to make patterns the new vertices would be unassigned.
The only fixes I know are to manually paint every vertex or to massively up the model's poly count and follow the edges with the knife tool, both would be massively tedious, so I'd like to find a fix that simply lets the unassigned vertices follow the weights of the face they're on top of.

Create a copy of the model, do all edit stuff, then use data transfer modifier to copy weights from old model to the new one, using the "Copy from nearest vertex" algorithm: copy thoose settings, targeting the old model, then press the"generate data layers" button, then Apply the modifier (Ctrl A).

This worked! Thank you so much.

You're welcome!


text:
How can particles be emitted from particles?
In a scene with two particle system configured as boids and boids brain set to fight, one swarm attacks the other. I would like to emit child particles as lines (laser or something) to visualize some fighting action.
I couldn't find a way to setup the line emitting particle system, either they are created from the plane or further cones will be added.
Is there a way to do this as I saw on a firework animation tutorial but I didn't get the trick?
Blend file here

At blendersushi blog the author says:

PARTICLE INSTANCE MODIFIER > PARTICLES
With this stacking thing, we can now pretty much emit Particles from emitted Particles, > if you know how to set it up. Not very obvious, but basically you Instance some meshes > (using Instance Modifier) and then add Particle System to the object with Instance > Modifier.
Make sure you have "Use Modifier Stack" turned on.

But I can't get this to work.

The trick is, you use the particle instance modifier on one particle system, and the particle system is recognized as one object, so it can then be emitted from itself.

Create a baseObject (that will be emitting the particles that emit the particles).
Create a ps1Object (it will be the object that is emitted in the first particle system)
Give the baseObject a particle system.
Select the ps1Object, and give it a particle instance modifier. In the object tab, select baseObject. Make sure to reset the location of the ps1Object, so it looks like it's emitting from the baseObject.
Give the ps1Object a particle system and check Use Modifier Stack in the Emission tab.

Unfortunately, Reactor Particles are no longer supported :-/ So you can't get particles to emit particles, as such.
The "trick" that he used to make the fireworks is that particles get emitted from faces, but those faces might move while particles are being emitted. He used a modifier to break the faces of the sphere into pieces. Those pieces happen to be driven by a particle system, but the particles aren't emitting particles. The particles are driving the motion of the faces, and the faces are emitting particles.
In short, this "solution" solves a very specific problem, and I don't think it will be able to do what you want it to do.

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


text:
Cycles Render showing up white
I switched to "Cycles Render" instead of "Blender Render" and my object is now fully white. I would like to render my object with it's material. I have been looking for solutions for quite some time and I'm not quite sure.

You have probably setup your materials for the Blender Render which are not compatible with Cycles. That means you'll have to (re-)create the materials for Cycles.


text:
Fill UV squares completely in all margin
I try to UV in a cubic model using Blender (v2.79).
I don't know how to do the same as this and must be like this:

The cubic model that I'm trying to UV like the previous even using Method: Angle-Based(These aren't the UV that I want):

What it should do?

Are you trying to unwrap all your model's polygons onto the same square of the UV-space? If so, you can just do ANY unwrap you like and then call the Unwrap Menu again and hit "Reset".

To unwrap the UV, so that every Quad fills the UV space from (0, 0) to (1, 1), select the faces in the 3D View, press U and choose Reset from the unwrap dialog. (The bottom most option.)


text:
How to enable an addon on startup via script?
Our renderfarm is running Blender from the network. How can I enable addons on startup without saving user preferences for each node?
The following works when I run it from Blender REPL during a regular Blender session. I thought I would easily add a script in script/startup and run:
import addon_utils
addon_utils.enable("animation_nodes")

But it doesn't find the addon. Maybe the startup script is run before the addons are scanned? Any ideas?
What would be the best way then to enable it for all the rendernodes?

Maybe an addon should be installed first, before ebeing able to enable it. The blender install should perfectly know where all addon files are, and its exact name to use in python (or gui) to enable/disable it. Are you sure it is?

please see the updated question.

i've simplified the question again.

thanks!... actually all would be fine, if USER settings would override LOCAL settings: http://blender.stackexchange.com/questions/19534/shared-network-install-config-priority ... that would solve so many problems for me

You can enable a comma-separated list of addons through the command line/terminal, so you're able to do that through a script. That functionality is described in the blender terminal help (./blender --help).
An example would be ./blender -b --addons animation_nodes,meshlint [file] to enable animation nodes and meshlint, then load your file.
If you need to load a single python script, such as a set of operations you want to use on a mesh object, you can use the --python flag. ./blender -b --addons animation_nodes,meshlint [file] --python [myscript.py] loads blender in the background, loads specified addons, loads the file, then executes the python script.
Unfortunately, the wiki is not helpful here; it only goes over basic rendering functionality. Simply call the help flag to see everything the executable can do from the terminal. A specific thing to remember is that flags are order-sensitive. Those flags listed first will be interpreted first, sequentially until the end of the command.

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


text:
Placing objects using a relative coordinate system
I have been assigned the task of making a 3D model from a site plan for a big wind park in Germany. I have a plane (7km X, 8km Y) long. I want a point in the left corner of the plane as a point from where I can move my windmill models with co-ordinates. Like windmill_1 2km left and 1 km up. A windmill in the left corner of the plane will have the location settings a 0;0;0.
Is there any solution?
Thanks in adavice.

could you make a drawing to visualize what you exactly mean? :)

Sure! https://goo.gl/OUhyoK The settings for this cube should be 0. How could i do that?

@zeffi I know, i mean is there a way to set it to 0 and that is in this position?

@CookieFresh, if you have the object origin (0x, 0y, 0z) at a left corner, an object with co-ordinates 2 units to the left of the origin plane will be off of the site plan.

@zeffi As i said..its hard to explain. But i will have your script use to! I need to lets say, spawn a windmill in the left conor. It need to have x= 0 y=0 z=0. So that i can then use the co-ordinates (in km's) to position the windmills 1:1 like in the site plan that i have.

Do this via a script, if you have the X, Y, Z coordinates of the base of each windmill, you can iterate through the list of coordinates and place a windmill at each coordinate.
Let's say you make a windmill object, or a group..
import bpy
import mathutils
from mathutils import Vector

scene = bpy.context.scene

# if you have a group named windmill
group = bpy.data.groups['windmill']

# all coordinates will be offset by this vector, your new 'origin'.
custom_origin = Vector((3, 4, 0.2))

coordinates = [
    (18.2807, 9.1404, -1.2686),
    (27.4211, 9.1404, 0.9514),
    (9.1404, 9.1404, -1.11),
    (18.2807, 31.9913, 2.1671),
    (18.2807, 13.7106, 0.0),
    (18.2807, 22.8509, 1.3214),
    (27.4211, 13.7106, 2.96),
    (27.4211, 22.8509, 2.1143),
    (31.9913, 22.8509, 3.7),
    (22.8509, 22.8509, 1.3214),
    (13.7106, 22.8509, 0.0),
    (4.5702, 31.9913, 0.0),
    (22.8509, 13.7106, 2.96),
    (13.7106, 31.9913, 2.4843)
]

for loc in coordinates:
    instance = bpy.data.objects.new('dupli_group', None)
    instance.dupli_type = 'GROUP'
    instance.dupli_group = group
    scene.objects.link(instance)
    instance.location = Vector(loc) + custom_origin  # adds them.

Insane! But i think would prefer a non script method. Because i always suck with scripts.

if you have more than 10 coordinates... use a script.

I will try! thanks Have you a idea how i can set this cordinates to 0?  goo.gl/OUhyoK

@CookieFresh I added an alternative portion of script to deal with the offset from the True 0,0,0 , in the second version everything will be relative to the new custom origin.

So i can use both scripts at the same time? And have i to configure at the alternative portion?

make a small demo scene for yourself and experiment with this, there's not much I can explain about this...  they are two separate scripts. The first one has no offset, but the second one (if you copy the coordinates) will place objects at (location + offset). Try it on an experimental scene.

I will try that tomorowor in the office, and will then give my feedback. Thanks so far!

You can parent the windmills to an empty. That way the objects will have coordinates relative to the local coords of their parent.

In edit mode, snap the 3D cursor to a vertex in the top-left corner of your plane
Go back to object mode and add an empty
Snap your windmill to the 3D cursor, so it's in the same position as the empty
Parent the windmill to the empty
Now you can change the location of the windmill relative to the corner
You can add more windmills by duplicating

Choose the left corner of the plane that you want to be the origin point (0,0,0), and select it. Now snap in edit mode, snap SHFT-A the cursor to selected. and set the origin CTRL-Shft-Alt-C to the 3D cursor. The origin point is now at the corner.
Another way is to go to edit mode, select all of the vertices, and move them so that the left corner is over the origin of the mesh.
In either case it would probably be wise to apply your locations with CTRL-A.
Now, to apply your windmills in the desired position, in the edit mode, properties shelf (exposed by pressing N under "3D cursor" enter the location for the new windmill in the spaces provided. When you go to object mode to add the new windmill object, it will be added at the 3D cursor.

Thanks! Is there a way to spawn a object in the left conor withco-ordinates that are 0?

authors: Антон Алексеев


text:
Python: Low level apply rotation to an object
How to apply rotation directly to an object in Python (not BGE, not bpy.ops...)?
import bpy
import mathutils
from mathutils import*

obj = bpy.context.active_object
obj.rotation_euler = Vector([0, 0, 45])

#obj.apply_rotation
#Apply rotation like CTRL+A -> Rotation

Thanks!
I need a method for an object that's been already rotated like in my example code.

Does the python script you included function correctly or incorrectly?

@atomicbezierslinger corrected the error, so now it works except for the "apply rotation" part.

To apply transformation really low-level, you should probably set the object's matrix directly and avoid bpy.ops.object.transform_apply() entirely:
import bpy
from math import radians
from mathutils import Euler, Matrix

euler = Euler(map(radians, (0, 0, 45)), 'XYZ')

ob = bpy.context.object

loc, rot, scale = ob.matrix_world.decompose()

smat = Matrix()
for i in range(3):
    smat[i][i] = scale[i]

mat = Matrix.Translation(loc) * euler.to_matrix().to_4x4() * smat

ob.matrix_world = mat

Change the last line to ob.matrix_local = ob.matrix_parent_inverse * mat if you want to set a rotation of 0°, 0°, 45° (as seen in Object tab) even if the object is parented.
The code might need further adjustments if drivers or modifiers are involved, non-uniform scaling in combination with parenting does not seems to work fine however.

Am I missing something - or does this not work in newer versions?  This code appears to rotate the object without applying the rotation as was requested.

@splic On blender 2.8+, change mat = Matrix.Translation(loc) * euler.to_matrix().to_4x4() * smat to mat = Matrix.Translation(loc) @ euler.to_matrix().to_4x4() @ smat and it should work.

@splic yes it's not working. I tried with version 3.3 and above. In my case it just sets the rotation to zero but not apply it and it even sets the scale X and Y to 0.707 so it gets stretched. Weird stuff happening. Can CodeManX update this answer? :D Here is the correct way to do it https://blender.stackexchange.com/questions/159538/how-to-apply-all-transformations-to-an-object-at-low-level

Ctrl+A executes this operator:
bpy.ops.object.transform_apply( rotation = True )

I would do this in bmesh with each vertex and then reset the object transformation:
rObj = bpy.context.object
vScale = mathutils.Vector(rObj.scale)
vLocation = mathutils.Vector(rObj.location)
rObj.scale = (1.0,1.0,1.0)
rObj.location = (0,0,0)
bm = bmesh.new()
bm.from_mesh(rObj.data)
for v in bm.verts:
  v.co = rObj.matrix_world * v.co
bm.to_mesh(rObj.data)
bm.free()
rObj.rotation_euler = (0,0,0)
rObj.scale = vScale
rObj.location = vLocation

Welcome to bse. The question does stipulate applying rotation. Can you add edit to answer for this case?


text:
Blender closes when using the scroll wheel
I am running a Windows 8 and have recently installed Laplacian Lightning and Blender Source Tools, and have failed to import Mineways twice. My new problem is that I cannot touch the scroll wheel without Blender suddenly closing on me. No error messages, no laggy crashes. Just blankness.
I have no clue what is going on and I need Blender to start working again because I'm not happy with this.
HINT: it's Laplacian Lightning. Looks like there's a problem that can't be avoided. Not because of RAM but because of a possible bug which I don't know how to fix.

How much ram do you have?

I don't really know

To check how much ram you have, open task manager and it should show you. I have noticed that when I don't have enough ram, blender closes. Do you have multiple programs open at a time? Is your systems ram too low?? If you can tell me one of those, I can help.

If you reckon its one of the newly installed addons, try unchecking them in the user preferences and see if that helps at all? If not then it might be the best option to simply uninstall and reinstall blender? :)

well, none of the operators on the laplacian lightning addon are modal, and there are no references to any event which might be triggered by the mousewheel, so.. i'm not inclined to agree that the bug exists primarily in that addon.


text:
How to distribute objects in a circular pattern on a surface (Radial Array, Polar Array)
I'm modeling a bathroom interior, and I was wondering if there were any nice ways to distribute the little water spouts in their pattern along the black plastic for this shower head.  Here is my reference image (sorry for the low quality) :

Thanks.

the search term you're looking for is 'polar array' or 'radial array' (but sadly no-one uses the correct term in their questions) and already has answers: http://blender.stackexchange.com/questions/6023/how-to-make-a-circular-array-using-offset-object-as-center?rq=1

Radial / Polar / Circle Array
First decide how many rings of holes you want, and the sizes of these various holes. The inner ring usually has a different hole count than the outer larger ring.
For the sake of demonstration let's say I pick 3 different sizes
hole count per ring | angle between each hole
--------------------+----------------
big hole: 20        | 360 / 20
smaller hole: 15    | 360 / 15
smallest hole: 10   | 360 / 10

A convenient way, which doesn't appear to be obvious for a lot of people, is to use the Array Modifier and a rotated Empty. The rotated empty will be used as the centre of the radial array. The rotation of the empty will control the angle of rotation of the arrayed objects.
If you want a radial array of 15 objects (for educational purposes I will array around the world center (0,0,0), and the plane is X,Y :

you place an Empty at (0,0,0), rotate it around z by 360/15

add a circle to the world at (0,0,0) and in edit mode move the vertices to in the X direction to until you are happy with where it is

Pick your Object, add Array Modifier to the it
set the Object Offset to the rotated Empty

From that point it's up to you what you do, add more rings. In the end you might have something like this, i've zoomed into the Empties to show that it might look a bit cluttered and that's to be expected (this is why naming your Empties is very important)

Start off with a circle (I set mine to have 16 verts).
Then, in edit mode, extrude and scale it a few times until you come up with something like this (this will act as an emmitter object for the nubs later on):

With some simple modeling techniques model the nub.

Then, with your first circle object selected, create a hair particle system with advanced checked, the number of particles matching the amount of verts in the object (look at the header to see the amount), select verts, and uncheck random.

Then, under render, select object, and choose the nub object. Then check rotation, change the type to normal, and uncheck rotation. This fixing the rotation is probably a bug, but we can take advantage of it to give the nubs the proper orientation.

Then, scale down your nub to adjust the size on the emmiter.

Finally, in the modifiers settings of the emmitter object, convert the particle system, remove the emmitter object (this will make all the particles separate objects, but they will share the data with the nub we made earlier, just as if they where an AltD Copy.):

Then, finally, select the nub, and in the vertex data section, press the number next to the name of the vertex data

and then join the particle objects together.
All that it takes after that, is to move it into position with the the model of the actual shower head which can be done with some simple modeling.

I'm sorry about the length of this, I'm going to clean it up tomorrow, and improve the images to take up less space and provide more clarity.

Awesome!  Thank you so much for the detailed answer.  I never thought of using a hair particle system.

You can do the same thing with dupliverts also. See this: http://www.blender.org/manual/modeling/objects/duplication/dupliverts.html


text:
Multi-line Text in blf (with multi colour option)
Further my previuos question, i'd like to know how i cant draw multi line with an array fonction on the Y axis always there concervant the different colors.
for exemple, i'd like draw:
"Ngons: 5"
"Tris: 60"
Ngons and Tris are the label and have to be in red
5 and 60 are the value and have to be in blue.
How can i do that please ?

Building on the previous answer, now you have to think about line-height. A reasonable line-height for typesetting is the height of capital M x 1.45. But the coefficient can range between 1.2 and 1.45 (See the wikipedia article on Leading. These values are suggestions, and for HUD text or UI information use the value that seems most pleasing and doesn't cause the text to be too close or too separated vertically.
Take for instance the default line-height of Blender fonts.

1 / 0.682 = 1.46    # it's only a suggestion anyway.

A multi-line version of the script from the previous question, might look something like this:
def draw_string(x, y, packed_strings):
    font_id = 0
    blf.size(font_id, 18, 72)
    x_offset = 0
    y_offset = 0
    line_height = (blf.dimensions(font_id, "M")[1] * 1.45)
    for command in packed_strings:
        if len(command) == 2:
            pstr, pcol = command
            #bgl.glColor4f(*pcol) -> Blender 2.7x
            blf.color(font_id, pcol[0], pcol[1], pcol[2], pcol[3]) # Blender 2.8x
            text_width, text_height = blf.dimensions(font_id, pstr)
            blf.position(font_id, (x + x_offset), (y + y_offset), 0)
            blf.draw(font_id, pstr)
            x_offset += text_width
        else:
            x_offset = 0
            y_offset -= line_height

x = 60
y = 100
RED = (1, 0, 0, 1)
GREEN = (0, 1, 0, 1)
BLUE = (0, 0, 1, 1)
CR = "Carriage Return"
ps = [("Blue ", RED),("Yellow ", BLUE), CR, ("White ", GREEN)]
draw_string(x, y, ps)

You aren't limited to single words either:
ps = [("Blue Steel", RED),("Yellow Monk Fruit", BLUE), CR, ("White as an otter", GREEN)]
draw_string(x, y, ps)

produces this. (and note I forgot on purpose to add a space after "Fruit" to show how words are separated).

caveat: Don't change the "Carriage Return" string to something with 2 characters, it's a place-holder to keep the code simple and its length must be anything other than 2.

Thank you very much once again, it is just that I needed


text:
update text after edit mesh with handlers
I need to update my text every time I alter my mesh in edit or object mode or if I edit the Tool panel.
I use this script:
# [snip]
# line 308
def update_scene(context):
    obj = bpy.context.active_object
    if obj.is_updated or obj.data.is_updated:
        handle_add(self, context)
        print("%s - Object data is_updated (pre)" % obj.data.name)

def handle_add(self, context):
    VIEW3D_OT_ADH_display_text._handle = bpy.types.SpaceView3D.draw_handler_add(
       draw_text_callback,
       (self, context),
       'WINDOW', 'POST_PIXEL')

def handle_remove(context):
    _handle = VIEW3D_OT_ADH_display_text._handle
    if _handle != None:
        bpy.types.SpaceView3D.draw_handler_remove(_handle, 'WINDOW')
    VIEW3D_OT_ADH_display_text._handle = None

class VIEW3D_OT_ADH_display_text(bpy.types.Operator):
    bl_idname = "view3d.adh_display_text"
    bl_label = "Display text"
    _handle = None

    @classmethod
    def poll(cls, context):
        return update_scene not in bpy.app.handlers.scene_update_post

    def execute(self, context):
        st = context.window_manager.show_text

        handle_add(self, context)
        bpy.app.handlers.scene_update_post.append(update_scene)

        st.enabled = True

        return{'FINISHED'}

class VIEW3D_OT_ADH_remove_text(bpy.types.Operator):
    bl_idname = "view3d.adh_remove_text"
    bl_label = "Remove text"

    @classmethod
    def poll(cls, context):
        return update_scene in bpy.app.handlers.scene_update_post

    def execute(self, context):
        st = context.window_manager.show_text

        handle_remove(context)
        bpy.app.handlers.scene_update_post.remove(update_scene)

        st.enabled = False

        return {'FINISHED'}

But when I run the script like that, the console shows the following error:
line 312, in update_scene
NameError: name 'self' is not defined

If I add self in the update_scene arguments, another error shows in the console:
TypeError: update_scene() missing 1 required positional argument: 'context'

I have not managed to solve this problem, which is likely an easy fix. How can I do that please ?

Nobody can help you if you strip important parts from the script. E.g. I can't see where you define draw_text_callback

Yes, a copy of a fully functional script would be better since we will probably need to run it locally to test it.

@WorldSEnder it may seem that way, but the problem here is with the logic of adding the handlers. the draw_text_callback function isn't so important.

I wanted to see the definition of draw_text_callback to decide if you could safely remove self from its args-list

The error NameError: name 'self' is not defined is pretty self explanatory, you are using self as a variable name and it has not been defined at the point you are using it. self is a variable name normally only used within a class definition while you are trying to use it in a module function.
self is normally defined to point to the object that the current function belongs to. In the context that you are trying to use it, it will be the first argument sent to the callback function, meaning it should point to the object that will be handling the callback.
I think to achieve what you want, try adding a variable to the scene object that holds a list of data that draw_text_callback draws (See the example for CollectionProperty), your update_scene maintains the list and draw_text_callback goes through it to draw what it needs to.
The second error is because you can't add another parameter to the function used for scene_update_post as it must match the single argument prototype that is defined to be used.


text:
Joining several splines
I try to use points from an import as a spline to make curves as paths to follow for an animation.
These curves share some points at the ends and beginning when I import them via Python.
For example
s1: A-a-b-B
s2: C--D
s3: B-c-C
s4: D-d-E
which in the viewport look like
A-a-b-B-c-C--D-d-E
I want to join them together, so that I'll have one single spline
s5: A-a-b-B-c-C--D-d-E
I could use CtrlJ to join them, but they are still not merged at their shared points, which makes the rest of the spline not used for the following.
If I join them it looks like:
s1: A-a-b-BB-c-CC--DD-d-E
Also, another part of the problem is that the order of the splines from the import is not given, that s1 and s2 may not have shared nodes, and are only connected to each other via others like s3 and s4.
Is there a way to merge them? via commands or scripting

Select the two ends you want to join in editmode and press F. If the shared ends are in the same place, you might want to delete one of them before connecting the curves.

unfortunatly that does not work, gives "Cannot make segment", but thanks anyway

explain your situation as precisely as possible. Because it works very well here. What exactly do you do, what type of curve is it, how many have you selected, etc. The easiest way is to upload a small! blend at pasteall.org. Then I can analyze

i guess its because it is not a beziercurve and therefor it fails: "cd = bpy.data.curves.new(name=curvename, type='CURVE')" and "cd.splines.new('POLY')"

joining two splines within a curve requires both splines to be the same type.  If one is Bezier and the other is Polyline, select the polyline and use the Set Spline Type button in the Tools/Curve Tools section of the t-panel to turn it into a bezier.

Natively the only way to join splines is using Make Segment, which is a bit of a hassle for your use case as you'll need to manually change handle types, snap handles and remove points.
The following adds a Merge operator that attempts to handle all that for you:
import bpy

class OBJECT_OT_CurveMerge(bpy.types.Operator):
    """Merge two bezier curve points"""
    bl_idname = "curve.merge"
    bl_label = "Merge"
    bl_options = {"REGISTER", "UNDO"}

    @classmethod
    def poll(cls, context):
        return context.mode == "EDIT_CURVE"

    def execute(self, context):
        try:
            bpy.ops.curve.make_segment()
        except RuntimeError:
            pass # Already joined.

        spline = bpy.context.object.data.splines.active
        selected = [p for p in spline.bezier_points if p.select_control_point]

        if len(selected) != 2:
            self.report({"WARNING", "ERROR"}, "Cannot merge points")
            return {"CANCELLED"}

        center = selected[0].co.lerp(selected[1].co, 0.5)
        selected[0].co = selected[1].co = center

        selected[0].handle_left_type = selected[1].handle_left_type = \
        selected[0].handle_right_type = selected[1].handle_right_type = "FREE"
        if spline.use_cyclic_u:
            selected[0].handle_left = selected[1].handle_left
        else:
            selected[0].handle_right = selected[1].handle_right

        bpy.ops.curve.select_all(action="DESELECT")
        selected[1].select_control_point = True
        bpy.ops.curve.delete(type="SELECTED")
        return {"FINISHED"}

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

register()

With the above loaded:

Join the curves Ctrl+J
Select points s1:B and s2:B Space,Merge⏎

Repeat for the rest of the points you wish to merge.

The Make Segment link might be broken.  Perhaps http://www.blender.org/manual/modeling/curves/editing/introduction.html in the Joining Curve Segments is the modern equivalent?


text:
Increase quality of water render
Here is my attempt at dropping things into water. Unfortunately it did not turn to out well especially at the bottom right and this is at 900 cycles. Are there any ways apart from increasing the cycles to make it look better? I mostly want to fix the colored spots from the above the lemon.

Could it be that you accidentally assigned another texture to the lemon with default color?

@stacker the lemon color is fine but how do I get rid of that thing in the bottom right. it is still there at 2000 cycles

referring to the pink spots? that's just an image texture looking without an actual file value (you haven't chosen the image)

I'm not entirely sure what part of your render you are asking about, but here are some possibilities:

This appears to be caused by internal reflection of a light source (judging from the lighting, I would say the light source is behind the camera and a little to the left). Try adjusting the lighting in your scene and see if it improves.
The fluid simulation appears to be rendered at a low resolution. Try baking at a higher resolution (e.g. start with 100). If you did bake at high resolution, ensure that the Render display option is set to Final.
It's hard to say what's causing this without looking at your file, but a couple of possibilities are:

The geometry of the orange mesh. Ensure that the normals in that area are facing the right way, check for overlapping faces, ensure that there are no holes in the mesh, etc.
Bounces. Try increasing the number of Bounces in Render settings > Light paths (A fast way to increase all bounce related settings is with the presets, try the Full Global Illumination preset). This will increase the overall accuracy of the render as well, so you probably want to increase them anyway. Note that more bounces will slow down your render.

To help decrease fireflies, see this question. Some techniques mentioned there are:

The Clamp option (may or may not be very helpful in this scene, however I thought I would mention it). From the wiki:

This option will clamp all samples to a maximum intensity they can
  contribute to the pixel, again to reduce noise at the cost of
  accuracy. With value 0.0 this option is disabled; lower values clamp
  more light away.
If the image has fireflies, there will be samples that contribute very
  high values to pixels, and this option provides a way to limit that.
  However note that as you clamp out such values, bright colors in other
  places where there is no noise will be lost as well. So this is a
  balance between reducing the noise and keeping the image from losing
  its intended bright colors.

Render stacking. See the following posts:

Stacking cycles renders in the compositor?
Creating renders from Image Stacking using different sampling levels
How can I pause a render in progress and then resume it at a later time?

Fake refractive caustics
Filter Glossy
No Caustics (definitely not useful in this scene, as you need the caustics for light to reach the fruit, but again I thought I would mention it anyway)

See the manual page on reducing noise.


text:
How do you render a stereoscopic image?
I want to create a 3D animation, but by 3D I mean if you had a 3D tv/screen you could watch it in 3d. From my research in 3d video files they are just regular formats like .avi but they have 2 frames for every one frame of movement. To do this in blender I could put 2 cameras slightly spaced out from each other but how could I get them to both render a image for each frame? Can this be done in regular blender or do I need a plugg-in?

You could use two scenes two render two cameras (see Different camera settings for different render layers?)
However, this is a feature that is currently being developed, so you could try one of the development versions.


text:
How can I round the edges of a mesh?
I have looked at other similar questions on this site but couldn't answer my question. I have a model made of cubes the edges look very sharp (I would put a picture here but I don't have the required rep) is there a simple way to make the edges round?

You could use the Bevel Modifier from the properties panel.

Example with Segments set to 3 and Width 0.1 (red cube) Width 0.3 (blue cube)

stacker's answer answers the question. However, you can also selectively bevel parts of your mesh with Ctrl + B which is often faster than using the modifier if you want to bevel certain parts of your mesh (the modifier has options where you can bevel a group of vertices etc). You can also bevel single vertices with CtrlShift + B.
See a quick example here. It is worth noting that you can set your mesh shading to smooth to help remove faceted geometry at times and give a more rounded look.
Also see Most efficient way to round edges and How can I make sharp geometric 3d models look more realistic? for more tips.

You can also decide to do it the manual way. Add loop cuts Ctrl + R close to the edges of the cube in all directions (or as needed).
Then apply a subdivision surface modifier Ctrl + 1 - 6

Your answer is ultimately the better solution but one con is that it generates much more geometry than is needed. See http://blender.stackexchange.com/q/811/12

Yes. The modifier is actually the best option in this instance.

If somehow your mesh is all messed up and you're looking for a way to avoid selecting multiple outer edges, the Remesh modifier can sometimes yield adequate results.
This applies in cases when you need a more photorealistic edge to objects - it WILL NOT give you full control of bevelling. Whether it's the best way also depends on the complexity of your shape(s) and how much else is going on in your final render. The more complexity, the harder for the modifier to get it "right".
For increased accuracy, set the voxel size really low (save first, even save as if necessary). This operation better be well thought through though, as it drastically slows things down. Keep in mind your intended end result before going this route.


text:
Remove part of a plane
I am trying to build a pool on top of a plane, the pool goes below the plane, How can  I remove the part of the plane that is in the pool?

You can Tab into Edit mode on the plane and use the Knife tool to trace the part of the plane that you want removed. Press K to activate the knife tool and left click to create points, to close a shape, simply left click on the starting point. You can also use right click to cancel a cut if you make a mistake.

Confirm the cut with Enter and there should be a hole in the plane.

Another way you could do it is with the boolean modifier. Basically you would place the modifier onto the pool and set the floor plane as the target object. Then, set the operation to difference. And it should work! (I haven't tested it, so tell me if it works without flaws).
One of the advantages of using a boolean modifier instead of the knife tool is that it is dynamic. You can move the the pool around and it will cut through the floor no matter where you put it. And you could simply apply the modifier if you wanted it to be permanent.

Using a boolean modifier is overkill for just cutting a hole in a flat plane. It would add a bit more geometry and you would still have to cleanup after applying it. I would recommend even insetting and deleting a face then adjusting vertices before doing that. Also, your instructions are wrong.

Also, the boolean modifier will only remove the walls of the pool, not the inside, unless you use a plain cube with the same size to do the operation.


text:
Simulate objects falling into water
On the blender website there is this image:

What would I need to do to recreate this, cubes and spheres falling instead of fruit would be fine. I believe this uses the cycles render I have never used this before.

There's a tutorial that goes with this image on blender guru.

Because you have a good answer, I won't close this, but generally this reads like a tutorial request to me. Not sure if anyone else agrees.

This can be done with Fluid Simulation.
From the wiki:

In general, you follow these steps:

set the simulation domain (the portion of the scene where the fluid will flow),
set the fluid source(s), and specify its material, viscosity, and initial velocity,
eventually, set other objects to control the volume of the fluid (inlets and outlets),
eventually, set other objects related to the fluid, like:

obstacles,
particles floating on the fluid,
fluid control, to shape part of the fluid in the desired form,

eventually, animate the fluid properties,
Bake the simulation (eventually, revise as necessary and bake repeatedly).

A quick way to setup the domain is with Space> Search > Quick Fluid
If you want to make something exactly like that image, check this tutorial on Blender Guru.
Otherwise you could:

Create the domain object (You could select an object and use Space> Quick Fluid, but here is how to do it manually):

Add a cube (ShiftA> Mesh > Cube)
Add a Fluid modifier in Physics and set the Type to Domain:

Add a second cube for the fluid:

Add a fluid modifier in Physics and set the Type to Fluid:

Create the falling objects:

Create the motion. You could either animate the motion or use rigid body physics, in the above case it's probably easiest to animate them.
Add a Fluid modifier to one of the objects and set the type to Obstacle.
Select all the objects which will be falling in (selecting the one with the fluid modifier last so it is the active object) and press CtrlL> Modifiers. This will copy all the modifiers on the active object to the selected objects, including the fluid modifier.
Configure the fluid settings of the domain object as desired (see below)
Select the domain object and bake the fluid simulation in Physics > Fluid > Domain.

Domain Settings:
The settings in the domain object are as follows:
Fluid panel:

Simulation Threads: The number of threads to use for multithreading the baking process. (0 automatically picks, you can probably leave it the way it is)
Resolution: You can bake two different resolutions, this is useful for having a low resolution place-holder in the viewport.

Final: The resolution to bake the Final quality results at.
Preview: The resolution to bake the Preview quality results at.

Render Display: The bake quality to use in the render. The options are:

Final: Use the Final bake resolution in the render
Preview: Use the Preview bake resolution in the render
Geometry: Use the original geometry of the domain object in the render

Viewport display: The bake quality to use in the 3D view. The options are the same as Render Display
Time: Note that baking always starts on frame 1, these settings control the behavior of the fluid (e.g. for slow motion effects)

Start: The number of seconds into the simulation to start caching data.
End: The simulation time of the scene End frame in seconds.

Generate Speed Vectors: Record vector information in the cache (useful for motion blur)
Reverse Frames: Reverse the fluid frames
Speed: Rate of motion of the fluid. (0 = static, 1 = normal)
Offset: Number of frames to offset reading of the cache. This is the only setting which you can still change after baking.
Bake Path: Location on the system to read and write fluid cache files.

Fluid World panel:

Gravity: Force of gravitational pull on each axis. If Gravity is enabled in Scene > Gravity, this setting will not be editable from the physics panel. Instead change the values in Properties editor > Scene > Gravity.
Viscosity:

Base: The viscosity of the fluid
Exponent: The exponent that is used to make entering small values in the Base value easier. The end Base value is equal to base*10^(exponent*-1).

Real World Size: Size of the longest axis of the domain in real world meters. This setting does not affect the size of the domain in the scene, but rather the way the fluid behaves. (e.g. If you wanted to simulate fluid in a glass and your domain is slightly larger than the glass, you would set this to roughly the size of a glass in the real world)
Optimization:

Grid levels: Number of lower resolution grid levels to use in the simulation. -1 is automatic.
Compressibility: Amount to allow standing fluid to be compressed

Fluid Boundary panel:

Slip type: Collsision settings for the domain boundary. These settings are the same as on Obstacle objects. The options are:

No Slip: Fluid sticks to the obstacle surface
Free Slip: Fluid runs freely on the obstacle surface.
Partial Slip: Mix of No Slip and Free Slip. (0 = No Slip, 1 = Free Slip)

Surface:

Smoothing: Amount to smooth surface. (0 = none, 1 = normal, >1 = more than normal). Note that you can also non-destructively smooth the fluid after the back with a Smooth modifier.
Subdivisions Number of subdivisions on the mesh

Remove air bubbles: Remove the gap between the fluid and obstacles. Note that this can result in a dissolving the surface in other places.

Fluid Particles panel:

Tracer: The number of tracer particles to be created in the fluid when the simulation starts.
Generate: The number of fluid particles to generate. Note that you must have Subdivisions set to at least 2 for this to affect the result.

See the wiki for more info.
Some things to note:

Modifiers must be applied in order to affect the fluid simulation

Other notes from the wiki:

Unique domain
   Because of the possibility of spanning and linking between scenes, there can only be one domain in an entire .blend file.
Selecting a Baked Domain
   After a domain has been baked, it changes to the fluid mesh. To re-select the domain so that you can bake it again after you have made
  changes, go to any frame and select (RMB Template-RMB.png) the fluid
  mesh. Then you can click the BAKE button again to recompute the fluid
  flows inside that domain.
Baking always starts at Frame #1:
   The fluid simulator disregards the Sta setting in the Anim panel, it will always bake from frame 1.
      If you wish the simulation to start later than frame 1, you must key the fluid objects in your domain to be inactive until the frame
  you desire to start the simulation. See below for more information.
Baking always ends at the End Frame set in the Anim panel:
   If your frame-rate is 25 frames per second, and ending time is 4.0 seconds, then you should (if your start time is 0) set your animation
  to end at frame 4.0 × 25 = 100.
Freeing the previous baked solutions
   Deleting the content of the “Bake” directory is a destructive way to achieve this. Be careful if more than one simulation uses the same
  bake directory (be sure they use different filenames, or they will
  overwrite one another)!
Reusing Bakes
   Manually entering (or searching for) a previously saved (baked) computational directory and filename mask will switch the fluid flow
  and mesh deformation to use that which existed during the old bake.
  Thus, you can re-use baked flows by simply pointing to them in this
  field.
Baking processing time
      Baking takes a lot of compute power (hence time). Depending on the scene, it might be preferable to bake overnight.
If the mesh has modifiers, the rendering settings are used for exporting the mesh to the fluid solver. Depending on the setting,
  calculation times and memory use might exponentially increase. For
  example, when using a moving mesh with Subsurf as an obstacle, it
  might help to decrease simulation time by switching it off, or to a
  low subdivision level. When the setup/rig is correct, you can always
  increase settings to yield a more realistic result.

When the things fell they don't float! Water does not affect the object!?

@Developer Unfortunately no. See this post.


text:
How can I export curves(nurbs) to AutoCAD without converting to mesh?
I have some curves (nurbs) in blender and I want to use them in AutoCAD the same way as same curves. However, when I export the file as .fbx or .dxf and open in AutoCAD, the curves are converted to meshes.
How can I preserve the state of these when exporting? Is it possible?

The OBJ exporter supports import/export nurbs curves natively.
Otherwise you could find a list of all formats autocad supports, then see if there is support within blender for any of these formats (as 3rd party addons for eg, perhaps shapefile for example).


text:
Can the scale tool show me the real size of the object instead of a 1 - 0 scale?
when I resize I want to see the real width\length\dept of the object instead of the x=1 y=1 z=1.
Is there a way to do this?

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

Are you looking for the Dimensions in 3D view > Tool shelf (N)?

You can also change the units these values are represented in. By default they are displayed in "blender units" (BU), which are equal to meters. To do this, adjust the settings in Properties > Scene > Units:

I should also point out that the Scale of an object is not limited to 0-1. For example:

A scale of 1 = no distortion
A scale of 2 = twice as large
A scale of -1 = inverted

The Scale object property is really factor by which you can non-destructively shrink or stretch the object in any given axis without modifying the mesh.
It's useful to know this, as it can result in some unexpected results if you are unaware of what scale is actually doing. See my answer here for more detail.

No, the three numbers you are talking about in the 3D view header, while you are scaling an object, is the scale factor (example cube is 2" scale factor of 1.5, the cube is now 3").
If you want to change a object by typing in the dimensions you can do so in object mode in the properties region, explained in my answer here.
The process is

change one of the dimensions

copy the new scale from that channel to the other two.
apply the scale with CtrlA > Scale.

If you want units like meters or inch, you can go to the properties panel, then to scene and then to the tab units. Here you can choose metric or imperial. The dimensions is in meters or inches.


text:
How to make all faces convex?
Assuming I have a model with several n-gonal faces, out of which some might not be convex polygons, what can I do to make blender split those that are concave to make sure all polygons are convex?
I know about the "Triangulate" tool, but is there something that only splits the faces if they're convex?
Edit:
Added screenshot clarifying what I need:
So again: I need a tool that lets me select it all, and then subdivides the concave polugons into only convex ones.

Have you tried the decimate modifier or the triangulate modifier? Modifiers might be your answer.

Well they both kind of don't do what I'm asking about. Decimate actually reduces the amount of polygons! What I need is like triangulate, but only to be applied to concave triangles.

What I was thinking was adding a subsurf modifier then decimating it to get the original poly count. Depending on the kind of model. Could you post a screenshot of the model so I could think so more on it?

This isn't for one specific model, rather, I'm planning a project and I'll need the thing that I'm asking for in it. But it's 2D level design, so: very basic surfaces, actually not even bending into the third dimension, no curves etc... Should only be a collection of polygonal faces, with different properties. I can add a screenshot of an example, hold on a sec...

Blender 2.75 now has a feature a tool to perform exactly this operation.
Mesh > Cleanup > Split Concave Faces

You could use Select > Select Faces By Side, set Number of Vertices to 4 and change type to Greater Than. This will select all ngons, from there you can safely triangulate. As an added bonus, if the ngon has a large number of even sides, you could even run a tris to quads operation after if you want to have that clean flat topology.

This is better than simple triangulation, because the tris-to-quads step won't create concave quads, as I feared. However, this method still won't allow convex >4 vertice polygons to stay. In your gif, there would be nothing that needs doing, by my requirements. All polygons are already convex, and in the end result, the big hexagon is unnecessarily split. Any method that avoids that, but still splits concave polygons into convex ones?

@Ludwik Did you try any of the commands outside of looking at my example and afraid not, they are simple tools. Also could use limited dissolve to get a concave quad from a triangulated shape.


text:
How to render smooth alpha transistion between two objects?
I want to smooth the intersection between two objects, similar to the soft particle effect seen in many games:

Here's an example in blender where you would want to use this effect:

I want to smooth the intersection between these two planes to simulate clouds crossing each other. Considering the node system has access to geometry data and such, would this be possible? I'm using blender render if that matters (but the theory is universal i'm guessing).

Yes the renderer has access to geometry data, but the Z-channel clipping is still sharp no matter what.
You would have to make the ground plane transparent where the particles are crossing behind it, which one can do, but it would be pointless because it's not the effect you are looking for - any geometry behind ground could be seen.
What you need to do is to render smaller particles closer to the camera that don't intersect the ground.

authors: Роман Калашников


text:
How do I accurately select half of a symmetrical mesh?
I have this mesh that is probably nearly 100% symmetrical on both sides. I want to easily select half of the mesh, in order to hide it to have easy access to its inside. My object is directly aligned with the origin, so would there be like a Hot-key to be able to select any parts of a mesh in one side of the axis?

You can select everything relative to the last selected (active) vertex.

Select the middle vertex
Access the menu: Select -> Side of Active.(Which has options regarding which side/axis).


text:
How to remotely run a Python script in an existing Blender instance?
I don't want to use /Application.../blender -P my_script.py but I want to tell a running Blender process to execute a script.
Is there an existing method to tell a running Blender process to execute a python script?
For example using http://localhost:123/run_script=myscript.py

I would like to create a vim shortcut, that's why I'm asking.

This can be done with sockets,
using the following examples you can run from the command line:

From the first terminal:
blender --python blender_server.py

From a second terminal:
python blender_client.py /path/to/myscript.py

This will execute /path/to/myscript.py in the first Blender instance.
You can send multiple scripts or run the client multiple times.
Note that this is a simple example, to get return codes in the client or make the port configurable... etc, this would have to be extended.
It could even be made to sent the entire script, or compressed Python byte-code over a network, none of this is especially hard. It just depends what you're after.

blender_server.py
# Script to run from blender:
#   blender --python blender_server.py

PORT = 8081
HOST = "localhost"
PATH_MAX = 4096

def execfile(filepath):
    import os
    global_namespace = {
        "__file__": filepath,
        "__name__": "__main__",
    }
    with open(filepath, 'rb') as file:
        exec(compile(file.read(), filepath, 'exec'), global_namespace)

def main():
    import socket

    serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    serversocket.bind((HOST, PORT))
    serversocket.listen(1)

    print("Listening on %s:%s" % (HOST, PORT))
    while True:
        connection, address = serversocket.accept()
        buf = connection.recv(PATH_MAX)

        for filepath in buf.split(b'\x00'):
            if filepath:
                print("Executing:", filepath)
                try:
                    execfile(filepath)
                except:
                    import traceback
                    traceback.print_exc()

if __name__ == "__main__":
    main()

blender_client.py
#!/usr/bin/env python
# Script to send paths to run in blender:
#   blender_client.py script1.py script2.py

PORT = 8081
HOST = "localhost"

def main():
    import sys
    import socket

    clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    clientsocket.connect((HOST, PORT))

    for arg in sys.argv[1:]:
        clientsocket.sendall(arg.encode("utf-8") + b'\x00')

if __name__ == "__main__":
    main()

For me this freezes Blender until I press Ctrl + C to stop the server

Right, you could use a timer to check for events if you wanted.

blender --python blender_server.py opens blender as blank (grey window, not even splash screen). Any ideas?

@jjk right, if you want to run it from some other context you could use a timer for example.

@ideasman42 I'll rephrase: What's the purpose of blender_server.py as posted (freezing blender)?

You could open files, render, make changes, save them... whatever you want really.

I think this is a simple solution and avoids dependencies entirely.
https://github.com/zeffii/bpy_externall
Blender (Server)
Here's a small modal operator addon that works like this:

Adds a panel to the TextEditor, with a start / end button
when Start is pressed it

reads a file located at /path/whatever.io every n seconds.

If the file is empty we do nothing,
If the file contains a filepath (for instance to a python file)
then the filepath is executed with Blender's python (as if it was running from the TextEditor). Once completed the operator will erase the contents of the file to indicate that it executed the path.

When End is pressed the modal operator stops reading that file location.

External Text Editor (Client)
The add-on includes an example of a SublimeText3 plugin that acts as a Client. All this 'Sender' plugin needs to do is write the filepath of the python file you want Blender to execute to /path/whatever.io

Wow this looks great!

This concept is fine! I've created a small pull-request. I'll start working on a vim-plugin rightaway.

First vim plugin version is here

I don't have a windows machine, but it should not be to hard to create working version for window too. I presume there are a lot of Blender users running Windows.

ideasman42's answer using sockets is really cool, i'll need to study it :)

I did ask a similar question, but as this one is way more popular so I guess that answer should be here. Question on command port
This usually is done with command port that listens for commands, but there's apparently no such thing in Blender. I've created an addon that implements this functionality.
It can be found on github:

Sources
Release


text:
How to write a bpy.app.handlers handler thats only called once?
I have a problem with app handlers in Blender and Python. I am trying to write a script that can start a render and automatically upload it when it finished.
So far it works, but now I want to see the render process as well.
I tried bpy.ops.render.render('INVOKE_DEFAULT'), but that doesn't wait until the render is finished until executing the next parts of the code, where the upload happens.
After a bit of search I stumbled across app handlers, which seem to be what I need.
So I tried this:
import bpy

def my_handler(scene):
    print("render complete")

bpy.ops.render.render('INVOKE_DEFAULT')

def register():
    bpy.app.handlers.render_complete.append(my_handler)

def unregister():
    bpy.app.handlers.render_complete.remove(my_handler)

if __name__ == '__main__':
    register()

When I press Alt+P in Blender's Text Editor, it works fine at first. But when I try it a second and third time, it starts printing "render complete" multiple times at once in the console. Each time I run it, it prints one time more.
So I guess something is wrong here, and if the simple printing doesn't work, I rather don't try to use this app handler to upload the render result ;)
Anyone has an idea what's going on?

It looks like you're adding the render handler multiple times.
If you want a one-off handler, you can do this:
def my_handler(scene):
    print("render complete")
    bpy.app.handlers.render_post.remove(my_handler)

... you'll also want to change unregister not to error when the handler has run.
def unregister():
    if my_handler in bpy.app.handlers.render_post:
        bpy.app.handlers.render_complete.remove(my_handler)

Note: if you end up writing many one-off handlers, you might want to investigate writing a decorator, so a new handler could look like:
@call_once(bpy.app.handlers.render_post)
def my_handler(scene):
      print("render complete")

... where call_once can handle details to avoid a lot of repetition.

I'm in a similar situation as OP. I need a way of holding a 'for' loop until the render is over. I can't find a way of doing so, and blender crashes.


text:
Text object with a custom font shown up weirdly
I often have the problem with custom fonts in Blender in that they end up looking really poor like this:

I used a Google font here:

I am working with a MacBook if that is important.
Do I have to consider any "special" font attribute that they work fine or am I making something really wrong here?

You have selected very poor made font. I case of J, it made by 2 shapes, overlapping each other:

Not only J, but look at e ant t:

And compare with good font, there no overlapping is allowed:

Good font makers will not allow themselves such sloppiness. It may be ok in 2D graphics, but not for 3D, where such things will lead to non-manifold geometry.
So better choose the right font.

might be...but this happens to every 2nd font on google....so are they all poor fonts? is there any "special" thing i can look upon, that the font is suitable?

Might be something related to dynamic weight, Or it just new kind of fonts made without care. All fonts that I usually use (Lato, Din, PT) have no such issues.

ok, thank you, i will try them as well

@Chris I usually don't have these issues either, but I never used any Google font so I cannot say anything about the quality of them - if they are generally a poor quality or not...

From my post on a duplicate question:
Variable fonts, even when they come with static TTF files, seem especially prone to this issue because they're intentionally (and correctly!) designed with multiple overlapping elements and self intersections. Unfortunately, the static versions of these variable fonts may still retain those features, causing issues in Blender.
Some users report that OTF versions of TTF fonts may correctly flatten the shapes, but you can also fix files yourself with Font Forge.
Steps:

Download Font Forge (free and open source)
Open the font file you want to use in Blender
Select all (Edit > Select > Select All)
Remove overlap (Element > Overlap > Remove Overlap)
Generate font (File > Generate Fonts…)

I used the default TTF options when generating fonts. It takes all of 10 seconds to open a font file, process, and generate the patched file. Even easier if you macro the keyboard shortcuts (in MacOS that's command+a, command+shift+o, command+shift+g).
Many thanks to user chojnicki and their similar question/answer for pointing me in the right direction.

+1 thanks! good to know!


text:
How can I use a driver for multiple objects?
I made this little easy animation where a barrier opens automatically, if the car is near enough. I realized it with a distance driver.
Link: https://youtu.be/s78ClbPBHNM
Now I would like to add another car, where the barrier should open too. Is there a way to add more objects to a driver or how would you realize this?
My driver settings:

Hello, I don't really see any reason for the downvote... could you post a screenshot of how you setup the driver for the barrier ? You can use several variables for each driver, you just have to set the correct expression afterwards

thanks, i do not see any reason too...but some people... ;) of course, i updated it

If your driver is: max(0, min(pi/2, 2-abs(v1))), where v1 variable points to the car's location component of the axis perpendicular to the gate, then you already use max which is the method to take the bigger out of two (or more) values.
So you can calculate the bar's rotation for all cars on the scene, and pass each to the max function so the bar is always as low as the closest object in the equation allows it to be. Therefore, the driver becomes max(max(0, min(pi/2, 2-abs(v1))), max(0, min(pi/2, 2-abs(v2))))

In your case you have to add distance2 to have a distance of the second car to the gate. Then you apply the above advice with max:
max(pi / 2 + (abs(distance/15) < 0.8) * (pi * 3/4 - abs(distance / 5)), pi / 2 + (abs(distance2/15) < 0.8) * (pi * 3/4 - abs(distance2 / 5)))

i just didn't know i can add more input variables....i have to learn so much!! thank you! Nice barrier by the way...!!! ;)

You can add as many (maybe not, but at least several dozens) variables as you wish.
In the driver editor, click on Add Input Variable and choose your second object. In my case, I used a suzanne and a cylinder. Set up the distance variable exactly as for the first object.
Mind the name of the variables; it is important for later.

Then it is just a matter of modifying your expression to take the new variable into account. In your case, you want the expression to detect the closest one, that is to say the smallest variable, since the variables represent the distance of each object to the barrier.
The expression then becomes:
pi/2 + (min(suz,cyl/15)<0.8)*(pi*3/4-min(suz,cyl)/5)

Side note: You can ditch the abs. Distances are (normally) always positive numbers.
Result:

Thank you!!!!!!!!!

Have fun with drivers, they're really powerful :)

i have! ;))) thank you!!

Using the driver depsgraph.
You can create a driver method, and pass the gate object and the depsgraph to it: How to use different types of data blocks for driver variables?
You could add each car object as a matrix, or distance from the gate object variable. However, instead you could pass the depsgraph and look through it for objects that match a criterion.
This way, to have a car considered in the driver, you only need to give the object a custom property named "prop".
Here is a test script. A driver is added to the property of the gate.

import bpy

def test(self, locals):
    dg = locals['depsgraph']
    for o in dg.objects:
        if o.get("prop"):
            print(o.name)
            print(self.matrix_world.translation - o.matrix_world.translation)

    return -1 # A simple value to indicate working

bpy.app.driver_namespace["test"] = test

Any object in the depsgraph that has a custom property named "prop" is considered a car and the distance to the gate is printed to the console. Use it to make the angle calculation desired

Sorry for my laziness as I haven't tested it, but I think instead of checking for a particular property, you could also check for a particular name, e.g. if o.name.startswith('car')

Defintely the most scalable answer ! Would there be a noticeable impact on performance in a scene with thousands of objects ?

@Gorgious Absolutely. You could, however, create a list of objects that satisfy the criteria, calculated only once (only when you run the script), by putting this line before def test...: cars = [o for o in dg.objects if o.name.startswith('car')]. Now, you would iterate over this short list of cars instead of a long list of all objects in the scene.


text:
How can I position a connecting rod multiple times between two cylinders of different distances?
Modelling beginner here.
I want to connect two cylinders to a connecting rod - and this I want to do often.

So how can I do this simple and quick? The cylinders don't have the same distance. So yes, the connecting rod has to be lengthen as well.
I know about Shift + S → move cursor to selected and move selected to cursor, but I don't know a quick efficient way to do that.
In this image you can see some "ready" connecting rods (the lower two) and a "not" fit one to the right cylinder.

do you mean that what you want to do is what you show in your picture? Yes Shift S is the way to go, select the rods, in Edit mode select 2 opposite circles then Shift S > Cursor to Selected?

yes, but then i have only positioned one end....how to i rotate and lengthen that it fits to second cylinder?

could you please show what would be the final object?

i updated my question - just notice: the rods have different length....

so you're looking for something that will automatize the length, something like that? I guess you need to do it manually

actually i am looking for both, how to position and align both ends right and then kind of shorten it, yeah. I am aware of doing manually is needed, but i think my way is a bit complicated...i cut with knife and did bridge edge loops with the end. I hoped there would be some cool solution. Maybe i should work with just "one" end, position that two times and then use track to constraint to the other end...might be the quickest way...

Is this a possibility?

.. constructing the connecting rods to the cylinders..

+1....now i learnt "looped pairs" ;) didn't know that, thanks for that hint!!

@Chris  I've never worked out exactly how Bridge Edge Loops decides what goes with what.. but it seems practical, whenever I've used it.

me neither...i just try until it fits...and that's how i work 98% with Blender ;)

the problem with your solution is that i have to select exactly that faces manually so that the connection is looking perfect....so that's still pretty tedious :(

maybe i should change my question to...how can i connect two cylinders on tangent easily... ;)

@Chris My cylinder-pairs were dupes of single  pair-object, with the holes pre-cut. (They could even have been mirrored) If you give the each end an on-axis vertex, you can quickly create an orientation from those vertices when  needed, to move one end with respect to the other, in line. I always have 'Create Orientation' on my Q menu.

clever!! i like that!! thanks for that additional information


text:
Blender Python module (bpy): use integer property with exponential increment
I have an integer property I would like to increment as 2^int property.
If that isn't possible, I would alternatively like to just have regular increment, but display the value in the panel as 2^property.

Here's a trick you can use. Incrementing will continue to adjust by ±1, but we'll give the prop a custom setter that snaps it to a power of 2. If the value decreased, we'll snap to the next lower one; if it increased, to the next higher one.

import bpy

def set_prop(self, value):
    cur_value = self.power_of_2_prop
    value = max(value, 1)
    power_of_2 = 1 << (value.bit_length() - 1)  # rounded down to power of 2

    if value != power_of_2:
        value = power_of_2 if value < cur_value else 2 * power_of_2

    self["power_of_2_prop"] = value

# Note: This is the default getter, but the setter won't
# work unless we provide it too for some reason.
def get_prop(self):
    return self.get("power_of_2_prop", 1)

bpy.types.Scene.power_of_2_prop = bpy.props.IntProperty(get=get_prop, set=set_prop)

# Add panel in the Properties Editor to test it

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Test Panel"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        layout.prop(scene, "power_of_2_prop")

bpy.utils.register_class(LayoutDemoPanel)

Look for the Test Panel in the Scene tab of the Properties Editor.

@scurest's answer is definitely works as an answer for the first, however I think I'll use this approach because the interaction of setting a number and then it snapping to the nearest power is a bit wonky.
I was able to figure out the second approach, where it just shows 2 to the power of the property alongside the power, using the following expression:
col.prop(Rprops,'resolution', text='Resolution: '+str(2**Rprops.resolution))


text:
How can I control node values without input inside a group node?
I have created the node group, but I can't control the values inside.

Does this answer your question? Controlling ColorRamp nodes with Group Inputs

@RayMairlot I think there is another answer since Blender 2.82 which wasn't discussed in the related question, namely with the map range node which is effectively the same as a grayscale color ramp node with 2 stops, but with the obvious advantage of offering input fields.

@Gorgious Then an answer can be added on the other question. Just because there are new answers, it doesn't mean this isn't a duplicate question.

@RayMairlot Good point. Will do then.

@Gorigious The problem is that the topic I have linked has a question about the ColorRamp and that is why it is hard to find. I was looking for a general solution not connected to ColorRamp at all so this thread wasn't visible for me. I have found this thread by some forum where it was linked. So I decided that this is worth to make a post if it saves a few hours of searching.

This issue was discussed in Controlling ColorRamp nodes with Group Inputs post but as Blender workflow get simplified and I wasn't able to find this post druging googling I decided to add another answer.

Right click on source and choose "copy as New Driver" then go to the target and "Paste Driver". You can use any group node silder as a Driver.

Just wanted to thank you for this tip :). It's so simple, yet somehow never crossed my mind.


text:
Complexity versus NGons!
New 3D enthusiast here with a very basic question: for game assets which is more desirable:
1). The complete lack of ngons? or
2). A reduced triangle count?
Here is a little more detail:
I am building a game asset, a vending machine, which is basically a big, bulky rectangular box (it will not be animated). But, because of the many details on it, it has a lot of faces subdivided, creating a large number of--seemingly--unnecessary faces that could easily be joined. This, however, would obviously create a lot of Ngons. So, I am at a dilemma. I really want to simplify the model by reducing the number of faces (it would not only make the mesh simpler to work with, but I assume the less faces also equal faster rendering, which is crucial for a game component), but I know this would create Ngons, which are supposed to be really bad (although I do not yet complete understand why).
Here is an image of my mesh:

Because I am a beginner, I do not want bad habits to take root in my workflow. I want to approach and learn 3D modeling the right way. That is why I ask this question from you guys with much more experience than myself.

Related https://blender.stackexchange.com/questions/48954/merge-around-a-face/

as Lukasz-40sth says, select all the unnecessary edges and press X > Dissolve Edges

Do you really need those indents on a game asset? They could be faked with normal map just fine. But if really creating indents for something like mid-poly and avoiding normal baking you would dissolve all unnecessary quads and leave only edges supporting indents. Quads or quads mixed with tris would work fine for asset

If I understand your question, the ngons will become triangles in game engine. So there is no difference between using ngons or not toward reducing triangles. But it might be a good practice to manually change quads and ngons to triangle when exporting to game asset.

Let's start with the question first.
Ngons' behavior in game?
It will become Triangle faces that support the ngons vertices, exactly same when you manually triangulate any face in Blender, with some algorithm you don't know or don't care.
So the answer seems to be clear: You need to know when will an Ngons behave as same you want
We could divide the situations in following:
1. The Ngons is flat
Then the algorithm matters, in Blender, most of the ngons can be easily triangulate:

But not all game engine use a good algorithm to deal with this thing, it might be confuse by the strange behavior, or the ngons corners is not always convex. And the UV coordinates might be messed up. You should better try it in the game editor to test it.
2. The Ngons is not flat
If the angle is small, it will be OK with the same issue in flat Ngons. But when the angle is quite big. Don't use that ngons. Quick example:

The face with 2 vertices in different height cause render engine confuse. When manually triangulate it, it might not be the thing you see in view port before.
conclusion
Don't keep ngons when you are not sure what will happen to it. Use CtrlT to make them triangle, especially when it is not a flat plane.
The rest of the things
And your mesh: Separate those detail mesh if doing it will keep the mesh clean
If you are creating the game asset, then you might want to bake those detail to bump and normal map, or even displacement map. And Ngons might not be bad if the ngons is flat, and clear to triangulate. You should try on rough attempt, export the object to game engine and see what will happen.
And also, it is not that evil to separate the mesh that should be one thing in real-life. If the object is craft in that way (traditional way, not CNC or 3D printing), then do the same thing in modeling.
You may need to decrease the vertices on the large object and use details map textures. But for the tiny thing like buttons and grips, make it separated help a lot in your topologies. Look at the mesh in your vendor machine, those checked edges are meaningless.
It won't cause large overhead using multiple mesh toward rendering. In fact, there is no any cost when the vertices is not connected, the shader(program who draw your scene) only care about the number of vertices, faces and of course the textures. On the other hand, a complicated, well constructed mesh will slowdown your shader by the large amount of vertices and geometry.
But keep in mind: The shader used in these separated meshes should be the same one. Otherwise, this object will be treated as multiple draw calls. That's why it is not recommend to add too much material(shader) to your game object in Unity or other game engine.

Nice point about having disconnected islands of meshes inside an object for games, as these models won't be 3D printed so no benefit in holding on to that idea.

At a short glance I can tell you for sure that, you do not need that many faces if that area is going to be used flat. Like Hikariztw mentioned n-gons can be used but in this case I'm not so sure. Separation is another neat trick which you can use.
You mentioned you want to learn the correct way. And mostly the correct way is to avoid using ngons ; but having said that you must always consider it... because it is not a must. If the new topology you get by having all quads in your mesh is adding up tremendous amount of work and does not really give you any positive benefit in a game engine; then there is simply no point of trying to workout ngons into quads or tris!
You must note that ngons do not :

behave good in animation,
cannot produce accurate shading
light bounces unexpectedly
hard to uv
and etc problems...

For those reasons, it is usually good practice to avoid them. But if the role of that ngon is not gonna interfere with those circumstances go with it.

I always think we should talk about in what circumstances Ngons fails in game engines. That is quite important in modeling issue with game. But it might be too deep into rendering pipeline and people just don't care about it...

As far as this particular model is concerned, you have mostly quads, which are most desirable. Use CTRL+X to dissolve unnecessary vertices to reduce the number of faces.

I have done some of that since I posted this, but there are areas that are tricky and produce ngons. However, the question still stands (in general) of which is more desirable: low polygon count but with some ngons or more polygons but no ngons?

@Gergely Kovacs: More? I wrote what is most desirable. And ngons are bad when you want to e.g. subdivide faces. If you're not gonna do anything with a face, e.g. it's a base, then it can be an ngon.