text:
Geometry Nodes: How to Read Last Digit of a Big Integer?
I have made the following setup:

As you can see, the assertion fails. The Custom Group is what you would expect:

(╯°□°)╯︵ ┻━┻

Some approaches I tried and failed
I figured you can calculate the biggest possible error you got upon conversion to float, by using an expression:
$$\operatorname{floor}\left(2^{\log_{2}n-24}\right)$$
floor(2**(log(number, 2) - 24))

or just much simpler
$$\operatorname{floor}\left({n \over 2^{24}}\right)$$
n // 2**24

And at the end of the integer range $2147483647$ that error is no bigger than $128$. For simplicity I just assumed this maximum regardless of the input, because a loop of 128 iterations is no challenge for a computer (sure, should be optimized when dealing with many numbers).
So the idea is: just after converting the integer to float (add zero to the int) I can convert it back to an integer and see if it's smaller or bigger than the original integer (or equal if I'm lucky, but this case is simple). Then I can add/subtract the calculated error (or assumed $128$) and end up with two float values, one lower than the original integer, one bigger.

First approach was to spawn a curve with two points, and capture on them an integer attribute: the lower bound one the first point (start of curve), and the upper bound on the second point (end of curve). I captured it in the integer domain. Now upon resampling the curve to 129 points, I would expect the integer attribute to lerp with $1$ increments. This is where the idea fails, because apparently lerping is done using float32, even if the datatype is integer. Moreover, even assigning a single integer value to both endpoints before resampling, for a big integer, upon resampling produces a corrupted result (different integer, a negative one). If it actually worked properly, I could use my answer of a repeat zone, simply starting with a modulo $10$ on the lower bound, and iterating through the points, incrementing (mod 10) my digit only if the captured attribute on currently evaluated point is lower than the original integer.

An even more desperate attempt was to increment an integer using a "Random Value" node. I could take the lower and upper bounds, use integer comparisons and hopefully, using a ridiculous (but not 4 billion!) number of iterations emerge at the integer that is just 1 higher. This way I could iterate over 128 integers one by one, like I planned in the first solution. Moreover, I discovered a random integer just randomizes an integer in range from zero to the difference of max and min, and then adds min. So I can actually find a seed that for a random integer in range $[0, 128]$ gives me $1$ and then I can use the same seed for a bigger range to the same effect. Except, again, at big integers the node breaks:

I tried to simplify the StefLAncien's answer (the first one that actually worked!), by simply spawning the input number of points (at first I disregarded this option thinking it would take too much memory, and went for a repeat zone that shouldn't take any memory and just take long time - turn out I was wrong), detect if the integer converts to a float by going down or up, in the second case just add 128 more points (or less, as I argued earlier; hardly matters for performance) separate the points with indices larger than than the float, take modulo of the separated domain size (subtract 128 if you added it earlier), take modulo of the float, add together, take modulo again. But I discovered yet another integer related bug!

The above turned out to be a tooltip bug - thanks scurest!
At this point I'm thinking... Maybe we should consider big integers just not supported? Maybe we shouldn't limit integer inputs to the big range of $[-2147483648, 2147483647]$? It clearly just doesn't work, we should limit the range to $[-2^{24}, +2^{24}] = [-16777216, +16777216]$

As explained StefLAncien, I think this is effectively hopeless. As soon as you're going through float math (including value to string, for instance) you loose the last digits. And there is no integer math nodes.

If there is a trick (but we don't know the use case), that could be before that, for instance splitting the integer in two or several parts before, using a driver (Python).

For the tooltip issue, see https://projects.blender.org/blender/blender/issues/118073.

Explanation
I'll assume the integer X is non-negative.
The first number where the fmod doesn't work is 16777217. But if we remove the first digit by subtracting 10 million
   16777217
 - 10000000
-----------
    6777217

the last digit doesn't change, but the number is now back in the range where fmod works!
You can do the same thing for any large number by subtracting the right multiple of 10 million to get a number with at most seven digits
   123456789       2147483647
 - 120000000     - 2140000000
------------     ------------
     3456789          7483647

How do we know what multiple of 10 million to use? We can just try all of them. If X is our integer, we make the list
X
X -   10000000
X -   20000000
X -   30000000
...
X - 2140000000

At some point in this list, there's a number that's seven digits or fewer, so fmod will work on it. All the numbers after it are negative, and all the numbers before it have more than seven digits, so it is the smallest non-negative number in this list.
The reason this is useful is this list can be computed with the Accumulate Field node. Accumulate Field calculates the running sum of a field, ie.

In
Out

a
a

b
a+b

c
a+b+c

...
...

and it does this with proper integer math on integer fields, no float conversions. So we can make our list by feeding it this

In
Out

X
X

-10000000
X-10000000

-10000000
X-20000000

-10000000
X-30000000

...
...

-10000000
X-2140000000

The input list is easy to make as a point-domain attribute on a cloud of 215 points with (if index == 0 then X else -10000000).
We can extract the smallest value from the accumulated field with the Attribute Statistic node, but we want the smallest non-negative value, so we need to select the non-negative values first. The smallest value is now our desired number with the same last digit as X and no more than seven digits, so all that's left is to fmod it.

HAhahahah I don't understand this at all, I just tested it, and it works and is very fast. Amazing answer! I'll definitely analyze it thoroughly as soon as I have the time to do that, but regardless, I think it would benefit from some ELI5 explanation.

I tried to expand the explanation.

All clear now, thanks!

I used the Selection socket on the Attribute Statistic to simplify the graph a bit.

+1 for identifying and sharing that "Switch" and "Accumulate Field" nodes are preserving int32 algebra.

(Using Blender 3.6.5)
Taking advantage that Blender internal algebra of indexes is preserving int32 and that $2^n$ is not truncated in binary32 format (at least not for $n \le 127$), the following approach relies on deleting points of a point cloud with indexes lower than $2^n$, with $24 \le n \le 30$, such that the remaining count is lower than or equal to $2^{23}$. From this value, not truncated in binary32 format, and keeping track of the successively subtracted last digit of $2^n$, the last digit of a int29 can be computed, at a "huge" RAM cost.

0. Preliminary information:
0.1. $2^{23}=8.388.608$ is the largest int32 not a power of $2$ stored without truncation using binary32.
0.1. $2^{31}-1=2.147.483.647$ is the largest signed int32.
1. Because Floored Modulo operator is not available in Blender 3.6, the last digit is recovered by firstly shifting it after the decimal point, by dividing par 10. Then the decimal part is extracted with a Fraction operator. Finally, the last digit is brought back before the decimal point, by multiplying by 10.
2.  For step 1 process to be accurate, the treated value $v$ must not be truncated, i.e. it is mandatory that $v \leq 2^{23}$. So numbers such that $2^{23} \lt v$ must be reduced; others are unmodified.
3. A point cloud is initialized with as many points as the number to reduce.
4. $2^n$ points are successively deleted. Values between $2^{30}$ and $2^{24}$ must be subtracted from the number to reduce. So this deletion process is called at most 7 times. Because Repeat Zone is not available in Blender 3.6, the Group Node call is duplicated.
5. After reduction, the subtracted last digits are added to the remaining points count to recover the original last digit number. This value is initialized at 0.
6. At each iteration of step 4, the remaining points count $N$ is compared to $2^{23}$. If it is such that $2^{23} \ge N$, this step is skipped and inputs are just passed as outputs.
7. Let $n$ and $K$ be defined such that $N=2^n+K$ with $K \lt 2^n$.
$$
\begin{array}{rrcl}
\mbox{} & N & = & 2^n \left( 1 + \frac{K}{2^n}\right) \\
\Rightarrow & \ln{(N)} & = & n \ln{(2)} + \ln{\left( 1 + \frac{K}{2^n}\right)} \\
\Rightarrow & \frac{\ln{(N)}}{\ln{(2)}} & = & n + \frac{1}{\ln{(2)}} \ln{\left( 1 + \frac{K}{2^n}\right)}
\end{array}
$$
As $1 \le 1 + \frac{K}{2^n} \lt 2$, the second addend is positive and lower than 1, so $n$ is computed as the integer part of $\log_2{(N)}$. It is to notice that the truncation from the Point Count socket of the Domain Size node, to the Value socket of the Logarithm node, is affecting the accuracy of $K$, not of $n$.
8. Points with Index lower than $2^n$ are deleted, reducing the points count. Even with $n \gt 23$, $2^n$ is accurately passed as Binary32 by the Power math node. (NB: because indexes start at 0, comparison operator is "$\lt$", not "$\le$").
9. A record of the last digit of the "Subtracted" number of points must be kept, to recover the original, before reduction, value. It is noticed that this last digit value is circling between $2, 4, 8, 6$ as the value of $n$ increases. Let $i$ and $j$ be integers defined as $n=4i+j$ with $5 \le i$ and $1 \le j \le 4$, keeping in mind that $n \gt 23$.
$$
2^n = 2^{(4i+j)} = (2^4)^i \times 2^j = 16^i \times 2^j
$$
As the last digit of $16^i$ is always $6 \ \forall i$, the last digit of $2^n$ is the same as $2^j$.
9.1. The value of $j$ is computed from $n$ with a Modulo(4) operator.
9.2. The returned value of $0$ must be changed to $4$ to comply to the definition of $j$.
9.3. The largest $2^j$ value being $16$, and step 4 being repeated at most 7 times, the largest accumulated value is $112$. So the values manipulated by the Add operator are without truncation.
10. Final remarks:
10.1. To extend this approach to negative numbers, an Absolute operator is to be linked right after the int29 socket, before step 2. By just affecting the sign bit, it does not induce truncation of the input value.
Resources:

With my 10 years old, 8Gb of RAM MacBook, I succeed to reach 812^3 = 535.387.328. At 813^3 = 537.367.797, it just frizz and reboot...

NB: 2^29 = 536.870.912. Still a factor of 4 before the last signed int32: 2^31-1.

I just started analyzing it, and it's late so I'm going to bed, but I just tested it for integers 123456780 to 123456789 AND IT WORKS!! - great job!

Oh, you just spawn as many points as the integer AHAHAHAHA I was thinking about that, but figured it can't possibly work, too many points, too much memory, I figured a repeat zone should be much more lightweight - and yet your approach ended up working LOL, it's also quite fast, much faster than say the python equivalent of the loop I was trying (which took somewhere between 10 and 20 seconds for me)

I guess the reason why it works so fast is that you don't do something obvious that I would try - iterating over points, but instead remove points - as I said, I haven't yet thoroughly analyzed it, but I think I understand it in principle, it's a smart solution and takes advantage of some of geonodes optimizations...

(Using Blender 3.6.5)

This post is an extension of scurest's proposal.
It deals with negative values and it should run faster, not relying on an Attribute Statistic node coupled to a selection mask.

Objective
To split an int32 into two parts not affected by truncation, to possibly develop a fully compliant int32 algebra.
Approach
Let $n$ be an int32, and $X$ and $Y$ be two float32 such that $n=X+Y \times 10^7$ with $|X| \lt 10^7$. If $n \lt 0$, then $X \lt 0$ and $Y \lt 0$. The highest value of $|Y|$ is 214.
Following scurest's proposal, $10^7$ is chosen as base because it reads 0x989680 in hexadecimal. So it is 6x4 bits long, and as the significant precision of the Binary32 standard is 24 bits, $10^7$ and all lower integers (i.e. $X$) do not undergo truncation.

$Y$ is computed as the truncation of $n\ /\ 10^7$ using Math nodes.
$X$ is computed as $n + \varepsilon.10^7 \times |Y|$  with $\varepsilon=-\text{sgn}(n)$, using an Accumulated Field node which is compliant to int32 algebra.

Geometry Node Graph

1. $X$ and $Y$ are encoded in a Vector, with $Z=0$.
2. $Y$ is computed as $\text{trunc}(n \times 10^{-7}, 0)$.
3. To compute $n + \varepsilon.10^7 \times |Y| = n + \sum_{i=1}^{|Y|} \varepsilon.10^7$, a Point Cloud of $|Y|+1$ elements is created.
4. At the point of Index 0 is associated the field value $n$.
5. For subsequent points of Index between 1 and $|Y|$ is associated the field value $\varepsilon.10^7$. It is to notice that the Power and Multiply Math nodes do not truncate this number.
6. The value of $X$ is recovered as the accumulated field of the point with the last, i.e. $|Y|$, index.
NB: It is to notice that if $|n| \lt 10^7$, $Y=0$. So a single point is created with the 0 index, and the Accumulated Field node is returning $n$ as sole value.
Resources
Blender file:

I figured this solution:

However, Blender crashes when I try it. I'll have to report a bug on the Issue Tracker…

I think the repeat zone is not meant to be run hundreds of millions of times on update, you're surely hitting a limit there. Maybe you can do something really dumb and take a string as input, and compare the number of output vertices (assuming they're all different for each digit) . Something like that https://i.sstatic.net/ptmf4.png

@Gorgious string as input works, but if you start with an integer, how do you obtain the string... You can't. So if you read some kind of integer data, be it imported from csv or generated in a random value node etc. you're in a pickle. As for the limit - I was joking with the bug report, but on the other hand, that would be the first programming language I ever used with such a limit. It's rather sad that Blender crashes on something this simple - I think to both of us, the number isn't as scary to think a modern CPU would never finish the job. Less than 20 s for Python actually.

Sure, but converting a column in a csv to a string or generating a string of arbitrary length with random digits should be relatively straightforward, do you really HAVE to deal with integers in the first place ?

@Gorgious what inspired this question was the simplicity of a single integer input and the limitation of 7 digits here which could be increased by just 2 more digits and the workaround is not terrible - multiple integer inputs. Of course knowing Python I can make a workaround to any situation offloading the work to Python (and even then if Python doesn't work I can code a binary in some other language and execute it from Python). Still, I'm quite surprised it's so hard within geonodes.

(Using Blender 3.6.5)
The Binary32 standard might prevent this query. It states that :

All integers with 7 or fewer decimal digits, and any $2^n$ for a whole number $−149 \leq n \leq 127$, can be converted exactly into an IEEE 754 single-precision floating-point value.

As $123456789$ is 9 decimal digits long, the last two might be lost in the float32 format used by all Math nodes.

This figure illustrates that as a string, the largest positive int32 (i.e. 2.147.483.647) can be displayed. However, it shows that integers from 123.456.780 included to 123.456.788 included, after conversion to float (the format of the Value socket) are displayed as 123.456.784. Even the last 8 is questionable as 123.456.789 is displayed as 123.456.792.
These results are indicating that Blender Geometry Nodes behaviour is conforming to the Binary32 standard. Pure int32 algebra or double-precision floating point data type are required to capture accurately digits from the $8^\mathrm{th}$.

This is all correct, but question is, can a hack be used to obtain that digit anyway. For example my answer does just that, it just requires ridiculous processing power to do such a simple task. Imagine if "Value to String" had an integer input, it would then be possible to succeed by analyzing the string. Maybe I'm missing something that is possible...

I am sharing the same hope for a hack. After failure of the classical x-floor(x/10)*10 to get the last digit, I tracked down the round-off error and found that as soon as an integer socket is connected to a value/float socket, the last digits were lost. So the idea to use strings. But the "Value to String" node suffers the same limitation ! My conclusion is that we can rely only on nodes manipulating integers without conversion to float (green noodles should remain green...). I have to check yet, but I think there are not so many...

Exactly. But it gets worse. See even if you stay green, the internal implementation often uses floats or otherwise just fails. Try generating a random integer in range of MAX-2...MAX. You will get a negative integer. Try setting an integer attribute on curve, on both points set it to MAX. Resample to 3 points: the attribute becomes negative. BTW MAX = 2147483647 https://i.imgur.com/VvrDdTJ.gif

A "brute force" approach might be to use hexadecimal representation (for example) of integers as string, and to develop new "Math " GN manipulating strings. Inside such nodes, an int32 might be decomposed as two float32. The internal algebra could be coded using standard Math GN. Then the result could be encoded back as a string. A challenge ? (side note: instead of HEX, chucks of 7 digits, as 1234567_8901234_5... ?)

But how would you convert the input integer to a hex representation? I don't see any option to do that.

This is related to "how/why do we get such a large integer ?". If it is from user input, use a string (as for the locker you show here: https://blender.stackexchange.com/a/311086/177431) ; if it is from algebra using "regular" integers, this is only GN internal storage so strings should do. Remaining without answer: could a GN node (such as "Domain Size") return such a large value ?

I deleted the comment that you can't use string input, clearly you can, what I meant is, you can't animate a string input, and you can't store it in as an attribute... It's a 2nd class citizen. Also the interface doesn't allow you to neatly adjust a string as you do with an integer...

The integer's capacity just does not fit your purposes.
Though as a workaround you could use strings.

Attaching my file with the node setup:
(made with blender ver. 4.0.2)

there is a "Compare" node with a "string" mode. Yes, you're right, strings can be used, but as you can read in the comments somewhere here, you can't convert an integer to a string, so if you have your data as a string for some reason (some data loaded from an external source, or some random number or some ID etc....) you just can't read the last digit. BTW, your picture of strings doesn't show the part that actually makes them strings - the string, which is on the other side, and unlike in other types of panties, doesn't cover the buttocks.

Blender 4.3
The ability to convert an integer directly to a string, but more importantly, the integer math nodes in Blender 4.3 both allow to get the last digit easily:

Imgur mirror (SE image hosting has problems)


text:
Geonodes: which is faster, Set Position or Transform node?
Not sure if BSE is a good place for such benchmarks, feel free to let me know with downvotes (question downvotes are free).
Since many operations can be done by both, which of the two should be preferred performance-wise?
(as for which is more readable, it seems obvious Transform node wins, but there's a better place to discuss it)

(Modified image by Karen Arnold)

It's hard to give a down-vote for a question with a picture like that. :D

Blender 3.6.0
Testing on Suzanne, ✲ Ctrl5 5 subdivision levels, and this setup:

All measurements are done on the Group Output of the above, while modifying the contents of the i custom group. Throwing out 10% lowest, 10% highest, taking an average, but beware, the testing took much less scrupulosity than the description suggests.
For Entire Geometry

Only Translation
Only Rotation
Only Scale

12 ms!
40 ms
40 ms

Translation & Rotation
All 3
Set Position

40 ms
39 ms
31-32 ms*

*the Set Position node had much more wild results for some reason, ranging from 29 ms to 49 ms.
It doesn't matter how many of Transform inputs you use, I imagine  [confirmed by mod nop] because a transformation matrix is created, and then applied on all the geometry. The exception is if you only translate, this is optimized by just adding a number to all coordinates. Interesting, that a similar optimization wasn't implemented for only scaling (multiply all coordinates by a number; might be updated soon). Anyway, thanks to this translation, the only scenario in which Set Position could be used as a single node, is still won by Transform. And once you start using fields, the performance plummets:

Set Position rotation: ~278 ms
Using a Selection
Let's rotate only the Suzanne's eyes.
Transform: 2245 ms

The separation and joining is very costly. If separating by faces, the time increases to 2840 ms…

Set Position 282 ms

TLDR; conclusions
For entire geometry always use Transform node. When using a selection, always use Set Position. Of course If you want to apply a chain of operations on the same selection, the costly process of separating and joining might be a good investment.

source: Stack Exchange

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

sort: votes


text:
Raycast-influenced Shapekeys
Are there any possible geometry node setups (even if scripts are needed) that may allow Raycast to trigger multiple shapekeys based on rays touching whatever faces/vertices each shapekey is influencing?
Contingency:
Only if above requires vertex grouping, is there a way to convert/link shapekey influences into vertex groups? (don't need to require vertex groups, of course)
Goal: Autonomously dynamic shapekeys influenced by light direction.
Example: The ray reaches the left cheek of the face, activating the shapekey #1 (spikey cheek) and as the light reaches the ear it activates shapepkey #2 (spikey ear). As the light leaves both, it recedes the value of spikey ear and spikey cheek.

That's a very abstract description.. can you give a more concrete example?

The example edited in might help get things into perspective. Essentially, the question is simply: can shapekeys be influenced by the raycast geometry node?

the short answer is: yes. But the question is: will it be performant? and that answer is: no, because you will get a field as result (e.g. is hit or hit position) and if you ask for the value in the output node via python script, this script will be executed n-times and so it will be laggy as hell.

Ahh now I understand. So the possibility is out there, but one has to factor in the possible issue is performance and reliability. Dang. I was really hoping to get really innovative with this idea but didn't know where to start lol. Really appreciate the suitable insight my friend.

In this example the cube starts growing, when a ray hits it and it starts shrinking, when no ray hits it.

I first will explain, how to set this up. Afterwards I will talk about some performance considerations.
How to set it up
We start by constructing the cube and add two shape keys to it:

Value 1 means small, Value 0 means tall.
Next, we need a light. And as we would like to use raycasting to check what is hit by the light, we need a source for the rays. We would like to have six rays on the edge of the cone of light and one in the center. Thus, we create a hexagon with a center point, place it at the light position and bring its normal in line with the light direction:

One could use a parallel projection and scale the hexagon to the right size, so that the rays will cover the cone of light at the desired distance. Alternatively, you could move the center point of the hexagon along its normal and thus create a cone of rays. When you adjust the angle correctly and scale the hexagon down, the cone of light will have the right size independent of the distance of the target.

After setting this up, we add an Empty and create a driver that transfers the rotation of the empty to the light and the hexagon. This way we can define an animation based on markers with the rotation of the empty.
Now let’s do the raycasting. We add the following Geometry Nodes setup to the cube:

The rays are casted from the hexagon, that we provide by the input parameter Lightplane. They are casted into the direction of the normals. The result of the raycasts is stored in the ID of the related point of the hexagon. Afterwards, we check all these points. If at least one has the ID 1, we set the output attribute shouldGrow to true and otherwise to false.
The output attribute has to be configured properly, so that the script below works. I would have liked to use the Instance domain for the output, but I did not find a way to read the result with python. Maybe someone else can help out here. Thus, I ended up in using the Face domain. Additionally it is important to provide an attribute name in the modifier panel.

What is left is, to change the value of our shape key based on the value of this output attribute. We do this with the following script:
import bpy

def grow(scene):
    delta = 0.01
    # get evaluated cube object
    evaluated_object = bpy.data.objects["Cube"].evaluated_get(bpy.context.evaluated_depsgraph_get()).data
    # read the first value in the shouldGrow output attribute of the object
    should_grow = evaluated_object.attributes['shouldGrow'].data[0].value

    if should_grow:
        delta = delta * -1

    # modify the shape key
    current_value = bpy.data.shape_keys["Key"].key_blocks["Key 1"].value
    bpy.data.shape_keys["Key"].key_blocks["Key 1"].value = current_value + delta

# register the above method, so that it is called before every change of frames
bpy.app.handlers.frame_change_pre.append(grow)

This script creates a function, that is called every time, when the frames change. The script evaluates the cube object, reads the shouldGrow output and modifies the shape key correspondingly. This script is executed exactly once per frame.
To run the example, you first have to run the script, so that the function is registered. Then you can start the animation.
Performance considerations
As long as you create something like a movie, performance should be good enough. But if you want to create an interactive solution, you will have to have a look at the computation time.
Before I go into detail: Different from what Chris has stated in his comment, the script will only be executed, when you call it. In the above example, the script will be called once per frame and not once per frame and some other n.
Nevertheless, the execution time of the node setup depends on two factors:

number of rays
number of faces of the target object

The above example takes 0.19 ms on my computer. It uses 7 ray casts and the target object has 34 faces.
First let’s have a look at the impact of the number of rays. Therefore, I created a setup, where I distribute points on the Lightplane and project them parallel onto the target. This is the result with 34 faces of the target object:

ray count
computation time / ms

6
0.19

76
0.34

774
0.45

7700
2.80

77500
9.00

775000
73.00

As one can see, the ray count is proportional to the execution time for a high number of rays. But you won’t really need that much rays, I guess. So, one could see the number of rays as negligeable.
This, you can’t say about the number of faces. I used the Subdivide Mesh node to get the execution time for different numbers of faces of the target object. Here is the result:

face count
computation time / ms

34
0.19

136
0.43

544
0.62

2200
0.93

8700
2.10

34800
7.00

139000
29

And same as the number of rays, the computation time is proportional to the number of faces of the target object. Having 6 rays and 139k faces, I get 29 ms on my computer, which means, you will have about 34 frames per second ignoring all other computation needs. If you go beyond, you will need more/better hardware or it will be laggy in an interactive solution.

Very well said! I can get a good grasp of the foundation and can delve a bit further into your concept. Really have to thank you my friend. Although there are limitations, as the goal is to be interactive as your animate the model, the limits on what is and isn't possible can be measured and allows me to branch into a new perspective in the multi-faceted research overall!

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


text:
Disable button when another button has been enabled
So what I need is when Eyes Follow Cam is False then Head Follow cam and Influence is disabled(grayed out)
and when Eyes Follow Cam is True then Head Follow cam and Influence is enabled

Here is the code for for the necessary parts:
import bpy

from bpy.props import BoolProperty

bpy.types.Scene.EyesFollowCamera = BoolProperty(
    name="Eyes Follow Cam?",
        description="Makes the Eyes to follow the camera",
        default = False)
bpy.types.Scene.FollowCamera = BoolProperty(
    name="Head Follow Cam?",
        description="Makes the head and spine to follow the camera",
        default= False)

from bpy.props import FloatProperty

bpy.types.Scene.FollowInfluence = FloatProperty(
    name="Influence",
        description="Infuence of Head following eyes",step = 10,min=0, max=1,precision =3,
                default = 0.6)

class Blah_settings(bpy.types.Panel):
    bl_label = "Settings"
    bl_category = "IDK"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"

    def draw(self, context):
        layout = self.layout
        sce = context.scene
        row = layout.row()
        row.prop(sce, "EyesFollowCamera", icon = "HIDE_OFF")
        row.prop(sce, "FollowCamera", icon = "USER")
        row.prop(sce, "FollowInfluence")

classes = (Blah_settings, )

def register():
    for cls in classes:
        bpy.utils.register_class(cls)

def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)

if __name__ == "__main__":
    register()

Do I achieve it through a if statement? if so, how?

Does this answer your question? Contextually grey out panel element in python 2.8

Assign any bool to UILayout.enabled (layout element): https://docs.blender.org/api/current/bpy.types.UILayout.html?highlight=uilayout#bpy.types.UILayout.enabled

When false, this (sub)layout is grayed out

Quick demo using the 'Use Nodes' property (bool) in the World Panel. If enabled the other element (can be anything) gets greyed out.
import bpy

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the World properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "WORLD_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "world"

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

        row = layout.row()
        row.operator("mesh.primitive_cube_add")

        # Layoutelement.enabled = any bool
        row.enabled = not context.world.use_nodes

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

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

if __name__ == "__main__":
    register()

How do I get the opposite (negation) of a Boolean in Python?

@YunethAlwis https://www.codepile.net/pile/deJ8GGWo same thing...


text:
How to replicate `%` operator in simple driver expressions?
Since Python's modulo operator % isn't available in Simple Expressions:

Blender can evaluate a useful subset of Python driver expressions directly, which significantly improves performance, especially on multi-core systems.

Since Python drivers are considerably slower how would one port a Python formula using % modulo operator, to use fmod function (or something else?) instead?
Below a testing script to compare % operator with fmod function:
from math import fmod

def fakemod(a, n):
    return fmod(a, n)

row = "| {:>7} " * 5 + "|"
header = row.replace('>','^').replace('<','^')
line = header.replace(' ','-').replace('^','-^').replace('|','+').format(*'-'*5)

print(line)
print(header.format(" ", "     ", "fakemod", "     ", "fakemod"))
print(header.format("i", "i % 4", "(i, 4)", "i % -4", "(i, -4)"))
print(line)
equal = lambda a,b: '==' if a == b else '!='
for i in range(-10, 10):
    a, b, c, d = i % 4, fakemod(i, 4), i % -4, fakemod(i, -4)
    print(row.format(i, a, f"{equal(a,b)} {b}", c, f"{equal(c,d)} {d}"))
print(line)

I'm looking for a way to remove the inconsistencies between % and fakemod. For readability I mark the inconsistencies with != below:
+---------+---------+---------+---------+---------+
|         |         | fakemod |         | fakemod |
|    i    |  i % 4  | (i, 4)  | i % -4  | (i, -4) |
+---------+---------+---------+---------+---------+
|     -10 |       2 | != -2.0 |      -2 | == -2.0 |
|      -9 |       3 | != -1.0 |      -1 | == -1.0 |
|      -8 |       0 | == -0.0 |       0 | == -0.0 |
|      -7 |       1 | != -3.0 |      -3 | == -3.0 |
|      -6 |       2 | != -2.0 |      -2 | == -2.0 |
|      -5 |       3 | != -1.0 |      -1 | == -1.0 |
|      -4 |       0 | == -0.0 |       0 | == -0.0 |
|      -3 |       1 | != -3.0 |      -3 | == -3.0 |
|      -2 |       2 | != -2.0 |      -2 | == -2.0 |
|      -1 |       3 | != -1.0 |      -1 | == -1.0 |
|       0 |       0 |  == 0.0 |       0 |  == 0.0 |
|       1 |       1 |  == 1.0 |      -3 |  != 1.0 |
|       2 |       2 |  == 2.0 |      -2 |  != 2.0 |
|       3 |       3 |  == 3.0 |      -1 |  != 3.0 |
|       4 |       0 |  == 0.0 |       0 |  == 0.0 |
|       5 |       1 |  == 1.0 |      -3 |  != 1.0 |
|       6 |       2 |  == 2.0 |      -2 |  != 2.0 |
|       7 |       3 |  == 3.0 |      -1 |  != 3.0 |
|       8 |       0 |  == 0.0 |       0 |  == 0.0 |
|       9 |       1 |  == 1.0 |      -3 |  != 1.0 |
+---------+---------+---------+---------+---------+

I think an example workflow to place this feature in the context of Blender would be nice, currently I feel like only the people who would know how to solve this problem may understand the question :)

@Gorgious Well I lost some time figuring this out, unable to google the existing solution… I also got it wrong in the past because I tested lazily.

def fakemod(a, n):
    return fmod(fmod(a, n)+n, n)

Result:
+---------+---------+---------+---------+---------+
|         |         | fakemod |         | fakemod |
|    i    |  i % 4  | (i, 4)  | i % -4  | (i, -4) |
+---------+---------+---------+---------+---------+
|     -10 |       2 |  == 2.0 |      -2 | == -2.0 |
|      -9 |       3 |  == 3.0 |      -1 | == -1.0 |
|      -8 |       0 |  == 0.0 |       0 | == -0.0 |
|      -7 |       1 |  == 1.0 |      -3 | == -3.0 |
|      -6 |       2 |  == 2.0 |      -2 | == -2.0 |
|      -5 |       3 |  == 3.0 |      -1 | == -1.0 |
|      -4 |       0 |  == 0.0 |       0 | == -0.0 |
|      -3 |       1 |  == 1.0 |      -3 | == -3.0 |
|      -2 |       2 |  == 2.0 |      -2 | == -2.0 |
|      -1 |       3 |  == 3.0 |      -1 | == -1.0 |
|       0 |       0 |  == 0.0 |       0 | == -0.0 |
|       1 |       1 |  == 1.0 |      -3 | == -3.0 |
|       2 |       2 |  == 2.0 |      -2 | == -2.0 |
|       3 |       3 |  == 3.0 |      -1 | == -1.0 |
|       4 |       0 |  == 0.0 |       0 | == -0.0 |
|       5 |       1 |  == 1.0 |      -3 | == -3.0 |
|       6 |       2 |  == 2.0 |      -2 | == -2.0 |
|       7 |       3 |  == 3.0 |      -1 | == -1.0 |
|       8 |       0 |  == 0.0 |       0 | == -0.0 |
|       9 |       1 |  == 1.0 |      -3 | == -3.0 |
+---------+---------+---------+---------+---------+

Back in the day.. not needed any more, in nodes, with Wrap.   But.. how come I got % to work in the expression in my comment  here?

Oh Rich Sedman came up with exactly the same solution, nice! I tried googling "implement Python's modulo using fmod" etc. but never found something concise (and drivers really need conciseness). As for why you have no problem using % - drivers work in 3 modes: Blender first tries to tokenize an expression for its own stack machine, if it succeeds, you have a simple expression. % operator is not there, so using it will make Blender fail to tokenize and use a slow Python expression.

@RobinBetts BTW when Python is used, first the names and opcodes are checked against a whitelist, if the check fails, you're asked for a permission to run a potentially dangerous script. Here's an interesting case showcasing that. I actually wrote this Q&A to relief some bloat from that answer.

And only now I realized I misrepresented Chris'es solution there because I just represented % as modulo, whereas shading modulo uses fmod…

MVB: Wow! That is such a complete response! (Like your answers, of late).. Thanks! :)

I know that the topic is closed, but I want to add something for future readers, cause I found a simple solution to use modulos in a Blender scripted expression.
So maybe that can help ?
Replace **i%4** by **i-i//4**
For exemple, for i = 406 (406%4 = **2**) :
406-406//4 = **2**

406-(101x4) = **2**

406-404 = **2**

Welcome to BSE! Unfortunately, as simple as this answer is, it seems incorrect: let's assume $i = 4$, then we expect $4 % 4 = 0$, whereas your solution 4 - 4 // 4 will evaluate to 4 - 1 which will evaluate to 3. You have a unit test prepared in the question, just replace fakemod function's body with return a-a//n and you will see the result:  https://i.imgur.com/XljD9mj.png Also, topics are never closed (from old age) on Stack Exchange, feel free to add an answer, suggest an edit, comment etc. after decades.

Hello !
Thanks for your reply ! I hadn't noticed this error because in my use this case couldn't occur. the behavior changed if a=n. So it seemed perfect to me. Thank you for your help !


text:
Geonodes: when creating an instance, get index from instancer
While trying to recreate my answer here with geonodes: Array + Curve + Subdiv anomaly
I came up with this geo nodes setup:

The strategy is to set a "flag" A, represented by the top frame, if it's the back face and the first instance, or flag B (middle frame) if it's a vertical (back or front) face and it's a middle instance, or flag C (bottom frame) if it's the front face and the last instance. Then, if either flag is set, remove the currently evaluated face.
It doesn't work, however, because instead of the instance index, I use the face index. To my understanding, the Index node gives the index of the currently evaluated element, which is a face, because those nodes are evaluated by Delete Geometry node, which is set to iterate over faces. I'm not even sure if Instance on Points is iterating - i.e. if each instance can be different (other than using a collection and passing indices...). So does it mean I have to move the logic after Realize Instances node, somehow capture the point index (or use modulo...) and then delete faces? Perhaps makes sense, but the question remains: can the index further down the chain be accessed?
I tried to capture attribute between Mesh Line and Instance on Points, and pass that back to the frames, but it didn't seem to work - I have no experience in geonodes though, maybe I was debugging incorrectly.

Hi, @Markus! Is your question specifically about transferring the index from instance to geometry, as in the title? .. otherwise, you could think of a more general 'Capped Array' method than this..

@RobinBetts I'm all ears. :)

If your question is not particularly about capped arrays, but about transferring attributes from instancers to realized geometry in general, then I think this answer might be relevant?
If your question is about capped arrays, then I think it might be simpler and more general to dodge the bullet of transferring attributes altogether, and use the bounding box of existing geometry to control the location of new elements, or vice-versa.
OK, you can make an X Array group, to produce a no-gap array of elements along the element X-axis:

And you can make an X-Append Geometry group, which adds given Geo. to the positive X-end of existing Geo., lined up along X by bounding-box, so, again, there is no gap:

You can set up an interface for use with external geometry:

.. which I think is more convenient than the Array modifier's capping system; you don't have to adjust the X-location of the cap meshes so they fit. The GN looks up the bounding boxes for you:

Looking at your example of GN-generated boxes, the same groups could be used, something like this:

..and you can pipe the groups together to make more exotic combinations of elements, without worrying about their x-lengths, or where the element origins lie on their x-axes.

The idea was to avoid using other objects, but your last solution with custom groups is much more elegant, I need to develop my collection of custom groups (or copy-paste yours!).

@Markus Sure, I just used the external geo to illustrate.. a line of boxes is not very spectacular :D..  I expect you'll want to tweak the 'capped array' group to adjust the position of the mesh relative to the object-origin  . I wasn't sure where you would want it.

I just tried using your blend file, and with a little adjustment and modification, it works fine for me.

The strategy is to set a "flag" A, represented by the top frame, if it's the back face and the first instance, or flag B (middle frame) if it's a vertical (back or front) face and it's a middle instance, or flag C (bottom frame) if it's the front face and the last instance. Then, if either flag is set, remove the currently evaluated face.

I think your strategy at the beginning worked fine and probably something went wrong during the process of combining different boolean values that led to the inaccurate result when deleting faces.

It doesn't work, however, because instead of the instance index, I use the face index...

For me, using the faces' indices (instead of the instances' indices) in this case makes more sense since instances are only copies of the mesh, they don't actually hold any information/data of the mesh's components (points, edges, faces, etc...). So if you use its indices, I don't think there's actually any proper way of telling Blender to correctly delete the faces.
I'd organized again the first part of your node tree. The final set-up might differ a bit from your original file since I'm using the latest 3.1 alpha build (December 14th's build).

What I was trying to do is to create 3 different instances, and choose the instance based on the point index. But the the noodles I ended up with didn't convince me there's a remote chance Blender could read it this way...
Eventually I came up with this...
I couldn't find the Domain Size you used, is it new in Blender 3.1? I think instead of using a literal value (6), one could use Attribute Statistic node for index attribute, getting max output (and then subtract 1 since the index is 0-based).

For the Domain Size node, it's new and it's only available if you're using the 3.1 alpha build (see: https://builder.blender.org/download/). And yeah, I think you could try and use Attribute Statistic in this case also.


text:
Driver based on shading types/ change boolean when switching shading types
I have a Boolean property in my custom panel that I would like to either use a driver or can I use python to do make my option true/false Based on the shading type. I have searched up what I want, but the answers don't help and I am asking again because those were based on older blender versions.
For example,
When I go into solid shading mode, Visibility of a object is set to hidden and vice versa for other shading types.

I'm a bit confused.  Do you want to use this Boolean in a driver, or do you want a driver that sets its value?

@MartyFouts sorry i will edit that to make sense

@MartyFouts I edited my post, check whether you can understand my post now.

Yes, I can.  What you want can be done, I think.  I'll try to put together an answer as soon as I have some time.

@MartyFouts Thank you so much for taking the time to answer my stupid questions

It's not a stupid question.  I'm finding it a bit tricky in fact, but I'll see what I can do.

Does this answer your question? Automatically run a script when an object is transformed or a condition is met Checking the property before/after each frame is rendered is probably the easiest solution. Msgbus typically is the hardest solution - I wonder if someone investigated performance gains of msgbus way...

As for a driver solution, it's enough to right-click on the "viewport display" icon in the outliner, "Copy as new driver", then right-click on the driven property "paste driver" - except the driver won't update immediately when you click on an icon to disable viewport visibility, it will only update if you e.g. keyframe the viewport visibility and play the animation.

@MarkusvonBroady  It doesn't answer the question because material preview mode changes don't happen during renders, they happen during when rendering isn't happeing.

@MartyFouts Aaah, I understand now. I think the solution would be to use SpaceView3D.draw_handler_add in the 2nd part of my answer: If you don't want it for an animation

@MarkusvonBroady the downside of draw handler is that it gets called very frequently so it's slow compared to a msgbus based solution.

@MartyFouts Yes, but it doesn't matter

Let us continue this discussion in chat.

As in comments under the question, I think it's a duplicate of:
Automatically run a script when an object is transformed or a condition is met
Which points to a Space3DView draw callback solution:
Use a driver to programmatically set the positions of many vertices
Since we had a conversation in the comments about it, I decided to write an answer here. The principle is the same as under the link (the 2nd part, "If you don't want it for an animation") - on every draw, try to figure out if you don't have to do anything as soon as possible, and in such case just quit the function. That's the purpose of 'last_shading' variable - if you keep track of the last value, you now know if the value changed - if it didn't, you don't have to do anything and you can just quit. The sooner you realize the function has no work to do and can quit, the less CPU cycles you will waste. But, as I show in the benchmark you don't have to worry about it too much...
import bpy
from bpy import context as C, data as D
from bpy.types import SpaceView3D

visibility_data = {
    'Cube': {'SOLID', 'MATERIAL', 'RENDERED'},
    'Sphere': {'MATERIAL'},
    'Suzanne': {'SOLID', 'MATERIAL'}
}

last_shading = None

def test():
    global last_shading
    if C.area.type != 'VIEW_3D':
        return
    shading_type = C.space_data.shading.type
    if shading_type == last_shading:
        return
    print(last_shading)  # The lesson from edits... Use a print to inspect if the function isn't executed too often
    for ob_name, shadings in visibility_data.items():
        ob = D.objects[ob_name]
        ob.hide_viewport = shading_type not in shadings
    last_shading = shading_type

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

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

If you run the script with a project that has a cube, sphere and , all with default names, you should be able to see that they hide automatically based on the visibility_data dictionary:

Not sure if changing the rendering mode updates depsgraph, but for almost anything, consider replacing the view 3D callback with the application handler, as used here by Martynas Žiemys:
Operator that runs when a value input is changed

Thank you for giving an example as well, it helped me understand how to do this. This works.

There is a tiny issue tho, This seems to run every second which heavily impacts the scene I am working on. is there something like Run once in python?

@YunethAlwis This runs much more often than once per second, but it doesn't affect the scene in my tests. If you can reproduce the issue in a .blend file you can share, I'll be willing to look into it. Running first 5 lines of the test function shouldn't be heavy on CPU even if it's run 100 times per frame. But perhaps there's an error there that causes more work to be done? Could you also tell me what's your hardware you're working on?

My Hardware is i7 9750H, GTX 1650m.

@YunethAlwis Your hardware is not an issue then. By "heavily impacts the scene", you mean lowered FPS? It could possibly happen if every time it runs there's an error printed to console... The only idea I can come up with is to add if not C.area: return as the first line to the test function. Otherwise I'd need to look at your project to find what's the issue.

I did a test of my own how performance correlates to your code, this is my results i found.
160FPS when code isn't running
100FPS when Code is running
The scene contains 1 million faces with the same setup as you did but with subdiv modifiers.
Also the more geometry you have the more the fps exponentially slows donw with the code.

@YunethAlwis which code are we talking about? The code in this answer or the code in the linked benchmark?

The code in the answer

@YunethAlwis aaah I found the error, mea culpa

@YunethAlwis see the edit - that's the crucial part :)

Thank you Markus von Broady, Very cool :)

Markus there is a error in the code, UnboundLocalError: local variable 'last_shading' referenced before assignment, this got fixed by putting another = symbol on the new line of code you put, I just wanted to put. thank you:). Is it okay if I can edit your post.

@YunethAlwis it's getting embarassing... See another edit  - this time I tested it and it works.


text:
Curve modifier around bezier circle in Blender 3.0 not functioning correctly
Weird one. Im deforming a very simple cubic plane around a bezier circle using the 'Curve' modifier.
Problem is when the bezier points of the circle are moved at all, I get this hard twist in the geometry halfway around.
It only appeared since I updated to 3.0. The original file was made in 2.8 and when opening back in either 2.8 or 2.9 it works fine - just broken in 3.0.
It also happens when creating a completely fresh file and starting from scratch. See shot.

Any ideas?
Edit:
Adding the super basic file setup that has the error. Does the same thing happen when anyone else opens it?
https://www.mediafire.com/file/5zmy8hxr48s6953/CurveMod.blend/file

hello, could you please share your object (upload and copy paste the URL)? https://pasteall.org/blend/

Hey there. Popped a link in the main body, heres one using your file share too :)
https://pasteall.org/blend/4a78522f62e8415b982897d5d2b009cf

Just move in edit mode your plane to 0. Then it works:

Amazing, thanks Chris. Why on earth would that be the solution? Given that in previous versions of Blender it didnt work that way. What's changed??

I don’t know and I didn’t try the older versions. Since I work with Blender it was always that way ♂


text:
Add faces for too many looped edges
I have a bunch of closed cylinders and I want to add faces between them (not inside the closed edges). Would be grateful if someone can help me with that.

I'm not sure there's a way to do it, maybe you should create a module of your object and repeat it with an Array modifier?

@Hrishav's answer is a good lead but it's quite incorrect.
You will need booleans for this and also, like @moonboots said in the comments, you'll need to join your cylinders to one object if you haven't already.
After following the steps that I describe here, you'll end up with this :

It is the fast way but the topology is really messy, if you want to have proper topology, you may want to consider doing retopo.
After joining your cylinders, create a Cube (it has to be a closed volume so the Plane is a no-go and the cube is the simplest IMO --for the method I describe, that is-- ), place the cube like this :

Make sure the top end of your cylinders are outside the cube and the bottom end inside.
Add a Boolean modifier set to Difference to the cube and select the cylinders as the boolean Object :

Apply that boolean. You can hide your cylinders to better see the result :

Now you can go to Edit Mode and delete the lateral and bottom face of the cube :

As I said in the beginning, this topology is really messy but this is what I would suggest if you want a quick result.

You can also duplicate the cylinders, fill the caps (select the shortest edge, select similar by length...), and then boolean difference a plane with that.

Yes, this would work, in my example, I have only 13 cylinders and filling their caps one by one is still doable but it would be a nightmare to do that with those from the question unless there is a fast way to do that too?

select a single edge of the cap, Shift+G, length, F.

Pressing F from there actually fills the individual caps, thank you for that tip.

Thanks for your help. It worked. My mistake was unioning them rather than differencing them using the Boolean modifier.

@BroAli I'm glad I helped.

Just for completeness a simple way without joining your cylinders. Move them in a collection and use this collection as operand type for the Boolean operation.

Select all the meshes, join them into one object. Then add a Plane mesh, and add a boolean modifier. Im not super sure which one works. I just try all of them one by one, but i think the Intersect will work, probably.

Thanks for your reply. I have tried this before, but the plane mesh adds faces inside cylinders too, and I couldn't find any ways to distinguish the inter and outer faces of cylinders.


text:
Unable to reduce the number of points
Unable to reduce the number of points.
i create terrain in terresculptor 2
moved this terrain to blender
tried to reduce through the decimate command, for some reason this command does not reduce the number of points. The collapse and planar commands work, they save the grid at each vertex, but at the same time they destroy the grid at each plateau. Un-subscribe does not work at all, the number of points does not decrease.
how to reduce the number of points on the grid, but at the same time the points of view themselves were quickly distributed on the grid ???
my cart-model
https://drive.google.com/file/d/1yIxTqQLlo1WIo38BbusyFY8ZqPymkDVp/view?usp=sharing

the Unsubdivide option (in the Decimate modifier) should work, you need to go in Object mode, increase the Iteration value to see the effect, and click on Apply if you are good. You could also go in Edit mode, select all and Ctrl E > Unsubdivide, and set the Iteration value in the Operator box (bottom left of your 3D view)

@moonboots you didn't read the question

The number of vertices doesn't decrease as long as you don't apply the modifier. Please share your file

@moonboots https://drive.google.com/file/d/1yIxTqQLlo1WIo38BbusyFY8ZqPymkDVp/view?usp=sharing

it asks for an unthorization, please unlock or use another platform  ;)

what do you mean by "at the same time they destroy the grid at each plateau"? Maybe I understand why unsubdivide doesn't work, it may be because you have tris instead of quads. Also, what you could try is the Remesh > Quad tool in the Object Data panel > Remesh

Another possible idea is to use a shrink-wrap modifier with a plane and project it on to the terrain. It should work, and you could make the plane as low or high poly as you want before shrinkwrapping.


text:
Geometry Nodes: How the nearest face/edge is found?
I created a cube, aligned with axes, going from world origin to 1;1;5, and moved vertex 0 to the nearest face:

The vertex moved to the center of the nearest face, described by vertices 0154. It moved $\sqrt{0.5^2 + 2.5^2} = 2.55...$.
If it instead moved to the center of the face described by vertices 0462, it would move much less, $\sqrt{0.5^2 + 0.5^2} = 0.707...$.
Apparently my understanding, that the nearest face is the face with the nearest center was wrong. But then what makes a face the nearest face?

I guess you have applied the scale of the cube so that this is not the issue? Because if it was just a cube scaled on the Z axis, then I wouldn't even know what center should be preferred by this, as the centers of 0154, 0132 and 0264 would all be the same distance away.

@GordonBrinkmann the scale is applied, let me upload the file... Uploaded.

just a guess: the nearest vertex? or the average of all vertices distances?

Face that has nearest point. you have 3 since 0 nearest itself. so real q: how break tie. prob random.

@Chris the description says "using face and edge centers for distance computation"

For me it's working as expected: nearest face-centre before transformation

@RobinBetts Have you tested in Blender 3.0? Look at my answer to see how it works for me

Thanks to Crantisz I think I finally understand:
The nearest face is the face built on an edge that is the nearest to the Source Position.

not a face with the nearest center to s.p.
not a face with the nearest vertex to s.p.
not a face that could have a point on its surface closer to the s.p. than any possible point on any other face.

But what is the nearest edge then?
The nearest edge is an edge, on which you could place a point closer to the s.p. than any point you could place on any other edge.

not an edge with the nearest center to s.p.
not an edge with the nearest vertex to s.p.

Below I spawn an icosphere on the nearest edge to vertex #0:

Below I spawn an icosphere on the nearest face to vertex #0 (I positioned vert #0 to lay on the surface of the big face):

Now I stretch and move the small face along X, so neither its vertices nor centers of its edges are closer to s.p. than the top vertex (#2) of the big face) - and yet it still spawns the icosphere, because the top and bottom edges come closer to vert #0 than any other edge:

I think transfer attribute works in a slightly different way - it gets face nearest to face. This works only when you try to transfer data from face to face. I don't know how it works under the hood then you use vertexes instead of faces, but from my point of view, it doesn't have any sense. So I decided to convert face to points and then try to find the closest.
Now it works as expected:

UPD.
A, gotcha!
Look at this example:

Then you use faces as point, Blender gets the middle from faces connected to point. As you see this middle point much closer to one of the long faces

The update doesn't make sense though  Capture attribute is redundant there, and I don't get the explanation. But "Mesh to Points" as you used it in the first part is exactly what I should use to find the center of a face nearest by its center.


text:
How to fix inconsistent behavior of two quads defined by the same corner vertices?
I have two objects with two separate meshes. You can snap vertices of one, to the respective corners of the other, set the origin of both objects to the center of mass (surface), and their positions will be different. Moving the blue one up along Z axis a little, will show the two faces intersecting (in material preview mode):

Triangulating the top (blue) face fixes the issue, which leads me to believe that internal Blender's triangulation divides the quad across the other two corners for some reason:

As a confirmation, manually dividing the quads in inconsistent way leads to the same result as on pic. 1:

However, after consistent triangulation, when the quads double triangles no longer intersect, Set Origin still gives inconsistent results.

OK, I get what you mean, now, please see edit (replacement?) of previous answer.

Related: Edit face triangulation without actually adding edge

Edit (Better understanding of OP)
If you show the internal triangulation for rendering by using a Wireframe node, you can see that the (non-planar) quads are indeed triangulated in opposite directions:

..(and here the shipped add-on Measureit has been used to show vertex indices at a reasonable size.)
I've found that can be flipped by CtrlT manually triangulating with a real, editable edge, selecting the appropriate direction, 'Fixed' for 1st and 3rd vertices, 'Fixed Alternate' for 2nd and 4th:

Then CtrlX Limited Dissolving the new edge, setting the angle high enough to lose it:

After that, the internal triangulation appears to follow the hint:

.. and you get good ol' Z-fighting between the coincident faces, which is what you would expect.

Thanks! I reuploaded the .blend file with this vertex removed. Still, according to my test, removing it doesn't solve the inconsistencies (it wasn't part of the intersecting surface or any other surface, and I used set origin in center of mass by surface)

Ahh, OK, different problem...

Nice, thank you very much, it worked like a charm! I wonder how it works, as vertex numbering didn't change, maybe vertices or edges have some orientation property that gets flipped? And while we're at it, do you perhaps have an opinion on twisting quads? Would you consider some angles between opposite edges excessive? https://i.imgur.com/QwgnpQd.png

@MarkusvonBroady.. Vx numbering the same, but we have asked explicitly to use 2,4... not 1,3... and even though we took out our editable edge, the renderer seems to have taken the hint. Everything's triangles to the renderers, so the only thing about non-planar quads, is how closely smooth-shading (based on linearly interpolated normals from tri corners) approximates the curved surface we thought we were making. Not close with long thin tris... visible valleys/peaks along the diagonals of quads... unpredictable interpolation over narrow bevels not coplanar with large adjacent faces, etc.

In 3.5 an operator was added to make that easier: https://docs.blender.org/manual/en/3.5/modeling/meshes/editing/face/face_data.html#flip-quad-tessellation


text:
How do I attach cloth apron well enough to character so that I can animate without the apron going through the character?
Very new to Blender. I have been successful in creating my cloth apron and having it lay nicely on my rigged character mesh/model during the cloth simulation. However, when I begin animating and posing my character, the cloth does not follow the character and the body of the character goes through the cloth mesh. Any help would be appreciated! Attached is the link with pictures to my settings and modifiers. Blender Pics and Blend File

There are several tutorial videos on animating characters with cloth.  you should search in places like YouTube (search "blender animate character with cloth"), or here in blender exchange "[cloth-simulation] [animation]".   You'll need to have a frame 1 pose with your cloth hanging as you desire and progress towards a first pose, and then run the cloth simulation to that point.  Be prepared for playing with many parameters; it isn't very simple.

Two things: 1) Please edit your question, then upload and add the images directly to your question so readers get a quick overview and the images don't get lost. 2) Cloth simulation + animation is very challenging because of the collision detection and clipping issues. The cloth probably doesn't follow your character because of the wrong order of the modifiers on the stack. Modifiers work from the top down. The armature modifier must be above the cloth modifier because it moves the character. Check the modifiers tab.

@Blunder Thank you for your response! The images are too large atm. I can upload them to the post sometime tomorrow. I made this post right before work haha.

@james_t thanks for the suggestion! Surprisingly there are only a few tutorials out there atm. I have looked at most of them but have not achieved success. I will try searching more in depth on this site tomorrow. I am starting to realize that this is definitely a difficult task!

Hello and welcome. Instead of having users go through links and external sites please use the builtin tools to embed images in your post. See How to upload an image to a post? or GIFs


text:
Blender cannot sculpt anything
My blender sculpting tool suddenly not working today. I cannot sculpt or make change to anything including the initial default cube. I just updated to blender 3.0. Is there any reason might caused that? Thank you so much! I've been trying to search this on internet for a while.

some images or gif would be really helpful, as well as if you tried to restart your blender to default settings or not

wait, do you have vertices on your cube? I mean, can you show us what you are trying to sculpt in edit mode? Because you cannot sculpt cube like that if you didn't subdivide it's surface or you didn't enable Dyntopo

If you're trying to sculpt on planes and cubes without having first added extra geometry to them or subdivided them, then that would be why.
It may be that you had Dyntopo (contraction of 'Dynamic Topology') enabled by default before but an update or something disabled it.
Towards the top right of your viewport, click the checkbox to enable it.
It will automatically add extra geometry where you try to sculpt, dynamically!
Alternatively, see the Remesh menu right next to it to flatly add extra detail across the whole mesh.

Thank you so so much. It finally worked. For extra detail you mean subdivide the face?

@Tianyi Great, glad to hear it! And yes sort of, the Remesh tool basically cuts geometry into your shape using a voxel grid, the resolution of which you can define. It's like subdivision but it's based on the volume or area/size of the shape rather than the existing faces if that makes sense.


text:
Cycle render views grey in viewport and (almost) wouldn't render
the file itself here
New learner here. I was trying to render an image/animation and the viewport on cycle mode wouldn't show anything, just all grey and outline of the selected objects. I read all the similar questions in the forum but seems nothing applies. I don't think it's simply the camera or object setting because:
1.If I leave the screen for a long time it would eventually show up again but would be gone if I move the screen.
2.I left it render before going to sleep and it appears rendered something in the morning.
3.Everything is fine with EEVEE mode, viewport, render, all fine.
so I think if the setting was wrong it just wouldn't render at all, if it helped with time given means it's too heavy or something complicated for the computer to run.
I will attach some screenshots, you can see in viewport is all grey and in render window is just empty. and sample 0 out of XXX. I will also attach one that appear it would eventually render something is you give eternity of time.

pls provide blend file

it was too big to load,,,, 155 mb

you can use google drive or any other cloud service...

link added! thanks!

also after all night to investigating, I found the problem was texture shading being too heavy, if I turn off the clouds(which where Volumetrics was applied) the render assumed normal. I also tried with different texture like Magic texture, it helps but still super super slow to render. I coudnt figure how to improve this, I have the new macbook pro, shouldnt be a machine that too weak to run

if you mean the m1 max...i don't think it is too weak to run...it depends on your scene/models etc.

as far as I dont have the object involved with Volumetrics texture or magic texture, it works all good, but I just cant work it out how to make the texture works, when it turns on, all night( 10 hrs) I just got 10% of 1 steal image done..... I'm at dead end :P


text:
Bevel tool issue (Not a scale reset issue)
I have been having this issue for some time and seems to be pretty persistent although to greater and smaller degrees. When beveling, it seems the some edgeloops follow the expected curve, but the rest seem to create a linear shape. Im honestly not sure how to describe this better but please see the attached GIF. As mentioned, this is not a scaling issue. I have reset all of this. It is incredibly frustrating and I have not seen anything about it in my searches

The middle face is an ngon which will have unpredictable behavior

Maybe share a representative  file on https://blend-exchange.com/ so we can have a look.

Is this the difference you are talking about?

'Loop Slide' is often necessary when bevelling over existing bevels

Unfortunately Loop slide does not resolve this specific issue.
Also, although it is an N-gon, and I agree this can cause issues, this happens on properly edge looped edges as well unfortunately..


text:
Mesh in edit mode not selectable by vertex select, and mesh is un-editable
Ear mesh on the model's head appears darker and vertices arent showing in edit mode. I can still select the faces of the mesh but Cannot edit them when selected. All I can do is delete them I was working on the face when this happened and had the ears hidden with H after un-hiding them this happened.

Edit: I had to re-do the ears at this point with an older copy of the file I had made. Didn't set me back very far but I have encountered the problem again and I am too far in to use any backups as I have just noticed now and it happened to a bigger object. The same problem wherein vertex select mode I can not select vertices or see them.

For anyone that finds this. I have no clue how to replicate the bug but the vertices were just hidden without hiding the faces of the object. Try Alt + H when editing the object.
Edit: Forgot to mention I was thinking about this issue for a while and had tried Alt + H many times with it not working but every time I did that I had hidden the ears (Which were fine) beforehand. When it worked I had just entered edit mode.


text:
Rigging Character - Parent and Child Bones FK Rig Malfunction
I’m new to rigging and this model is my first attempt.
But because of that, I’m of course having some minor issues ( that I hope remain minor lol ).
The Problem

I’m following this tutorial concerning a spine rig. It seems as though I and a few others in the comments are having the same issue at the timestamped 13:25 mark.
When Dikko selects "DEF_spine.001" and "DEF_hips.001" to parent them with "CTRL_hips.001", his parent to child relationship is the only one rotating. The rest of the deformation bones stay put along with the “CTRL_COG” and “FK_torso” bones. This is the effect that’s supposed to be achieved.
However, when I rotate "CTRL_hips.001" after making it the parent to "DEF_hips.001" ( in my scenario as I only have one bone there ), all of my deformation bones rotate. This is not supposed to happen.
What I’ve Attempted
I’ve done very simple rigs with FK and IK controls before with success and I’ve tried various things to fix this issue.
I was thinking that maybe because “DEF_hips.001” is attached to the entire deformation chain that it’s causing the entire thing to move when it’s made the child of “CTRL_hips.001”. But should “DEF_hips.001” not inherit the properties of “CTRL_hips.001” if it becomes the child of that instead of the “CTRL_hips.001” apparently inheriting the properties of “DEF_hips.001”?
I should note I used this tutorial to replicate the basic heat bone method to avoid initial errors I had. That's what the "dupe / duplication" collection is for.
My Files
Attached in my box are two files people can open to see what I’m doing wrong. One is called “base” ( original ) and “error” what’s replicating the problem above.
Also his a visual of what my current FK setup looks like in both files.

the files are private and not accessible.

@Blunder
Thanks for pointing out the error. I've made the files viewable.
Please let me know if there are any other errors.

You're welcome. But the files are still private ;-)

@Blunder Oh my god I'm doing to die lmao.  Is this below link working now?
https://drive.google.com/drive/folders/1HAzSUKIHn8aa89zJ91Sfz1bqJ-4rlmFV?usp=sharing

Good news, everyone! I ( think ) figured this out on my own!
Below was my solution.
[1] I had to remove the “DEF_hips.001” bone as a child from the rest of the deformation rig.
[2] Then I had to make it the parent of both the left and right def_hip bones so it controls everything from the hips downward.
[3] Then I had to make “DEF_hips.001” the child of “CTRL_hips.001”.
So far it’s working, but in case this backfires, I am still open to feedback of other methods to achieve what Dikko’s tutorial is doing.

I've not run into any errors onward and the control works as intended!

I had to remove the “DEF_hips.001” bone as a child from the rest of the deformation rig.

Then I had to make it the parent of both the left and right def_hip bones so it controls everything from the hips downward.

Then I had to make “DEF_hips.001” the child of “CTRL_hips.001”.


text:
Bone Constraint Error

I’m in the process of adding an ik-control to my thigh that counters the extreme twisting on bones “DEF_thigh.L.001” and “DEF_thigh.L.002”.
The “copy rotation” bone constraint on “DEF_thigh.L.002” is meant to counter the extreme twist of “DEF_thigh.L.001” when using the “CTRL_ThighCounterTwist.L.001” control. When built properly, everything below bone “DEF_thigh.L.001” does not crush when rotated to its extreme axis.
Problem is, despite implementing Dikko’s controls, “DEF_calf.L.001” is rotating and crushing when pushed to its extreme, even if the axis of “DEF_thigh.L.002” isn’t moving as intended ( as seen in Dikko’s video ).
= = = = =
Below are things I’ve checked.
I checked to ensure my "CTRL_ThighCounterTwist" for both sides was the correct orientation in relation to the "DEF_thigh" bones.
When I applied "copy rotation" I ensured the constraints are "local space” and that the mixing came "after the original". For "DEF_thigh.L.002".
I then checked the targeted bone within the "copy rotation" attribute to ensure it was targeting the respective "CTRL_ThighCounterTwist".
I also checked to ensure "deform" was enabled under "bone properties" for my deform bones only.
= = = = =
The only other things I think would cause my issues are my FK and IK bone properties and their drives. But they seem to be fine in terms of what's enabled for my FK and IK controls.
The only other thing I can think could be an issue is a potential parent-to-child relation somewhere or maybe a misapplied driver data path?
I've provided visuals of both my thigh and arm bones. The arm bone constraints work great and the thighs' constraints are an exact copy of the arms'.
I'm at a complete loss as to what I am doing wrong in my file so any help is appreciated!
PS: Nathan provided me with an awesome way to work around this using weight paint. But Dikko's tutorial has no weight paints yet and I'm trying to match what he did exactly. But if I have to fix it that way, I'll give it a shot.
Blender File: https://bit.ly/3LE1MTJ
Video ( 46 minute mark ): https://bit.ly/3GolbUI

About your PS, do you mean something like https://www.screentogif.com/ ? (With https://www.ffmpeg.org/ you even can create a video file. But this site here only accepts animated gif images, max 2 MB)

Please read here for how to include gifs in your questions and answers. You may also see any of the questions on our meta that are tagged faq for helpful information about the site.

@Blunder Thanks so much! I'll be sure to check it out and educate myself on the methods you've suggested.

@Timaroberts Thank you! I'll be sure to check out both of those sections.  I just know gifs and videos can help provide far more information than static images can. I want to make the process easier for all involved haha.

Your file's armature isn't colored for me.  It looks like "purple bone" here is DEF_thigh.L.001 and "yellow bone" is CTRL_ThighCounterTwist.L.001.  In the future, referring to bones by their names is a better idea than by colors, because names are unique and colors aren't.
The rig appears designed such that rotating CTRL_ThighCounterTwist.etc rotates DEF_Thigh.etc but not its children, and it does that.
However, your mesh is still deforming all the way to the knee because your mesh is weighted to DEF_thigh.L.001 all the way to the knee:

The thigh twist bone is not being affected by the rotation of the upper thigh bone, but that doesn't matter, because the mesh that should be weighted to the thigh twist bone is weighted to the upper thigh bone.

Hey, @Nathan; thanks so much for the visual! It’s very clear and informative. I sincerely thank you for providing it. : D
However, I'm trying to match Dikko's method exactly and he’s not applied weight paints on his model yet ( that I can tell ). I know for sure there's something I'm doing wrong because the IK constraints in my arms work fine, and they don't have weight paints either.
I’ve updated my source file to fix some naming conventions and plan on updating this post with clearer visuals and what I’ve tried since my original question based on your feedback!

I've updated my question’s terminology and visuals to hopefully make it clearer based on your feedback! Also gave you credit for helping me to improve my question because I did not realize how vague spots of it were until you pointed those areas out. So seriously; thank you for that! Until then, I’ll mess around with your weight paint suggestion once I’m done with Dikko’s other rig setups because I’m at a loss of what else to do to fix my thigh problem haha. Unless that’s something I should do now instead of later?

Guess who solved their own question - me!
After recreating the leg’s child-to-parent relations, drives, controls, and running into the same issues, I deduced the problem was a relation of the bones to the mesh. Nathan’s response about weight paints sparked this thought into my head.
I then recalled a similar issue I had fixed with an area of the spine.
Below’s my solution:
[A] Select your mesh in “obj mode”.
[B] Go to “obj properties” and to “relations”.

[C] Remove ( click x ) the parent ( in my case it was legature ).
[D] Go to modifier properties and select “armature”. Remove that.

[E] With the mesh selected, then shift-select the armature.
[F] Press [CTRL]+[P] and assign “automatic weights”.
This resolved the crunching I had seen around the knee and now my mesh works like Dikko’s!
I’m presuming my original issue was because I did not update the mesh to bone relations when adding these constraints? I will keep in mind moving forward.


text:
Toggle Lamp Visibility Blender Game Engine and Python
I have this Sun lamp in my scene. I need to toggle the visibility of the lamp with the press of a button. I tried using the Visibility actuator, but it does not remove my lamp because visibility in the Physics panel does not apply to lamp values. I thought of a few ways of toggling the visibility of it, but could not get any of them working:

Move lamp to another layer on the same scene
Delete lamp and re-spawn it (I tried endObject() but it would never remove the object)
Change the lamp's brightness value

Remember, this is going to be on a button, so it has to be re-spawnable. If I could get the base code, I can make the toggleable if block myself. Also, this is a Python question. Logic blocks take more time to setup than just a simple script. ;)
Thanks in advance!

In python you can access the lamps energy attribute like this:
bpy.data.objects["Lamp"].data.energy = 0

In the game engine you can toggle the energy by this script (assumes energy value set to 1.0):
co = bge.logic.getCurrentController()
lamp = co.owner
toggle = co.sensors["space"] # space is the name of keyboard sensor

if toggle.positive:
    lamp.energy = 1 - lamp.energy

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


text:
Can a mask stick to a shape in the motion tracker?
I have some video footage of a flat surface (for this example, let's say it's a binder or a book), and I want to digitally replace the cover of the book using a plane in Blender. So, I set up my tracking scene and align the plane and stuff and it attaches to the book. The problem is, someone picks up the book, so their hand is now covering part of it. Is it possible to draw a mask that will conform to the shape of the hand, or something similar? Maybe like a lasso tool (like they have in photoshop) or something similar? Or will I have to adjust the mask frame-by-frame?
Thanks. :)

Related: http://blender.stackexchange.com/a/23902/2843

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


text:
Is it possible to reduce video light flicker with Bender?
This is more of a compositor question. I have a video that I filmed (actually, it's stop-motion), but it has lots of light flicker (and I mean lots. Every frame is brighter or darker than the other). Is it possible to reduce this light flicker using Blender? I know there are other programs to do this with, like VitrualDub or AfterEffects, but I was wondering if I could use my favorite program (Blender, ;) ) to do it too.
Thanks in advance!

@cegaton I am pretty sure if you can do it manually then you can script it with Python, which then would be one click. Not posting an answer as I have no idea how to calculate values for filter/adjustments.

That would be a feature request for a new node.

Not necessarily a new node. Not everything has to be done with on node. I am looking for a node setup maybe, or like elmo said, a Python script. Any way to do it would be fine.

This is my photographer half speaking, but I would go back and re-capture the image sequence, taking more care to keep the lighting constant between frames. The result will look much better and might even be easier than trying to keyframe the brightness like others have suggested. What caused the variation in the first place?

You could normalize the brightness and dark values then retarget them but the gama value would be almost impossible to determine of the image is being over exposed. Deflicker is non trivial and requires inter frame access which blenders nodes don't have.

I guess you're saying that I'd have to do it manually. I did find something to do with the normalize node, and it worked well, but it removed some color-data and made the contrast on my images strange.

Yes you can never really know where the mid point of the brightness should be hence a strangely contrasty picture I guess.


text:
Delete un-seen mesh with Blender
I am wondering if there is a way to delete un-seen mesh with Blender. Here's an example. I have a cube, and it has 3 cubes inside of that cube.

Is there a way to delete the mesh inside of the cube without selecting the cubes manually? This would clear up lots of extra mesh and speed up my render engine. I am using Cycles, so if Cycles has an option to not render hidden meshes, that would be good too. (although deleting them would be better). A Python script would also do. :)
Thanks!

The fastest way I can think of which works for the cube case is:

Select part of the outer cube (a single vert will do)
Press CtrlL to select connected vertices
Press CtrlI to invert the selection
Delete.

To delete geometry not visible from the camera:

Enter camera view (Numpad 0)
Ensure you are in solid shading and that Limit selection to visible is enabled
Use border select (B) to select all visible vertices (you may also want to do this with face select enabled to select visible faces too)
Grow the selection (Numpad +)
Delete.

From the camera, there isn't much indication that there are missing faces. Note however that shadows and reflections will be affected.

I already do that and it takes a very long time on my advanced models. I was looking to a way to do it more automated. Like Blender doing it for me, just deleting the un-seen mesh.

By unseen, do you mean literally all the geometry not visible from the camera? Including geometry behind other geometry, not necessarily inside?

I would prefer to delete inside, but un-seen from the camera is ok too. I think I have a method, but I couldn't figure out any way of activating it through Python...

I wish there were a way to cut geometry and insert vertices where the view beings to obscure so that all geometry not visible currently is removed. That way you're not keeping some geometry that is invisible to the camera between the visible vertex and the invisible vertex
edit: perhaps a combination of the answer above and this? https://blender.stackexchange.com/a/115669/168825

You could select something of the surrounding object (vertex,edge or face) in Edit Mode and select linked L followed by invert selection Ctrl-I
Faces where all edges are connected to more than 2 other faces (users) can be selected via Select Menu / Interior Faces


text:
How to list the frame numbers which contain keyframes in Python?
I animate with lots of holds in between each keyframe so there are lots of frames with no movement throughout my animation. I don't want to render a bunch of duplicate frames (I'd rather stretch them out in post), so I've devised a way of rendering only the frames which have keyframes using a batch script.
"C:\Program Files\Blender Foundation\Blender\blender.exe" -b "C:\Users\Me\Documents\Blendfile.blend"
-f 1 -f 23 -f 24 -f 25 -f 26 -f 31 -f 32 -f 33 -f 34 -f 37 -f 38 -f 39 -f 45 -f 46 -f 47 -f 51 -f 52 -f 53 -f 59 -f 61 -f 71 -f 72 -f 73 -f 75 -f 76 -f 77 -f 83 -f 84 -f 85 -f 93 -f 94 -f 95 -f 98 -f 99 -f 100 -f 103 -f 104 -f 105 -f 110 -f 111 -f 112 -f 114 -f 115 -f 116 -f 122 -f 123 -f 124 -f 127 -f 128 -f 129 -f 130 -f 131 -f 132 -f 140 -f 141 -f 142 -f 143 -f 144 -f 145 -f 149 -f 150 -f 151 -f 152 -f 153 -f 154 -f 156 -f 157 -f 158 -f 161 -f 162 -f 163 -f 169 -f 170 -f 171 -f 175 -f 176 -f 177 -f 178 -f 179 -f 180 -f 181 -f 182 -f 183 -f 192 -f 193 -f 194 -f 196 -f 198 -f 200 -f 202 -f 204 -f 206 -f 208 -f 210 -f 211 -f 212 -f 213 -f 217 -f 218 -f 219 -f 226 -f 227 -f 229 -f 234 -f 235 -f 236 -f 237 -f 238 -f 239 -f 240 -f 244 -f 245 -f 246 -f 249 -f 250 -f 251 -f 253 -f 254 -f 255 -f 264 -f 265 -f 266 -f 267 -f 268 -f 275 -f 276 -f 277 -f 279 -f 280 -f 281 -f 282 -f 285 -f 286 -f 287 -f 296 -f 297 -f 298 -f 308 -f 309 -f 310 -f 316 -f 317 -f 318 -f 319 -f 323 -f 324 -f 325 -f 332 -f 333 -f 334 -f 343 -f 344 -f 345 -f 352 -f 353 -f 354 -f 356 -f 357 -f 358 -f 361 -f 362 -f 363 -f 367 -f 368 -f 369 -f 370 -f 371 -f 372

Currently I'm manually populating this script with the frame numbers. However, I know that Blender keeps the data of all the keyframes (such as at the top of the Dope Sheet).

So my dilemma is, how can I write a Python script that collects this data for me? Does anyone know how to tap into this Super Sheet Summary or some Blender internal function to grab the frame numbers of the frames which have keyframes on them?
All help would be greatly appreciated! Thanks!

Graph editor Operator
(for version 2.79.4 and above)
Set up the selections on your graph editor to match those of the dope sheet.

Since version 2.79.4 the graph editor has the very handy context.selected_editable_fcurves property. The operator below uses each of these selected fcurves.  Render frames are added to a list sequentially from frame start to end if there is any change (over a tolerance) in the evaluated fcurve between frames current, f, and previous  f-1.
The render command line is written to a text block
To use, run the script (to register) Use the space bar and search for  "Report Changed Frames" in the graph editor space.  Remember it uses the selected fcurves, press A before running to select all visible in current graph editor selection.
import bpy

def main(context):
    scene = context.scene
    selected = context.selected_editable_fcurves[:]
    # all selected fcurves
    f = scene.frame_start
    render_frames = [f]
    f += 1
    while f <= scene.frame_end:
        def changed(fc, tol=0.0001):
            return abs(fc.evaluate(f) - fc.evaluate(f - 1)) > tol

        if any(changed(fc) for fc in selected):
            render_frames.append(f)
        f += 1

    report = bpy.data.texts.new("Changed Frames")

    report.write('"%s" -b "%s" ' % (bpy.app.binary_path, bpy.data.filepath))
    for f in render_frames:
        report.write(" -f %d" % f)

class GRAPH_OT_report_frames(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "graph.report_frames"
    bl_label = "Report changed frames"

    @classmethod
    def poll(cls, context):
        return context.area.type == 'GRAPH_EDITOR'

    def execute(self, context):
        main(context)
        return {'FINISHED'}

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

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

if __name__ == "__main__":
    register()

As stated this doesn't list all frames with a keyframe, rather it lists all frames that have some animated change on that frame, (for any of  all selected fcurves).
If you are just after keyframe frames, add all kfp.co.x (keyframe point frame) points to a list, for all selected fcurves.  Converting to a set s = set() will remove doubles.
all_frames = set(kfp.co.x
        for fc in context.selected_editable_fcurves
        for kfp in fc.keyframe_points)

Oldschool (all versions)
You can also iterate through all actions and check the state of Keyframe.select_control_point property to get the corresponding frame of all keys in the selection.

import bpy
from math import ceil

class ACTION_OT_report_selection(bpy.types.Operator):
    """Report Selected Keyframes"""
    bl_idname = "action.report_selected_keyframes"
    bl_label = "Report Selected Keyframes"

    def selected_keys(self):
        """Returns the frames of all selected keys"""
        ctrl_points = set()
        for action in bpy.data.actions:
            for channel in action.fcurves:
                for key in channel.keyframe_points:
                    if key.select_control_point:
                        ctrl_points.add(ceil(key.co.x))
        return sorted(ctrl_points)

    def cli_block(self, frame_list, block_name):
        """Creates a new textblock with all necessary command line arguments"""
        report = bpy.data.texts.new(block_name)
        report.write('"%s" -b "%s" ' % (bpy.app.binary_path, bpy.data.filepath))
        for f in frame_list:
            report.write(" -f %d" % f)

    @classmethod
    def poll(cls, context):
        area_types = ('DOPESHEET_EDITOR', 'GRAPH_EDITOR', 'TIMELINE')
        return context.area.type in area_types

    def execute(self, context):
        render_frames = self.selected_keys()

        if not render_frames:
            self.report({'ERROR'}, "Nothing selected")
            return {'CANCELLED'}
        else:
            textblock_name = "Render Arguments"
            self.cli_block(render_frames, textblock_name)
            self.report({'INFO'}, "'%s' text block created" % textblock_name)

        return {'FINISHED'}

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

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

if __name__ == "__main__":
    register()

Thanks for the answer! Unfortunately, no matter what i do, I always get this error. I've tried selecting all in all windows to no avail.
Traceback (most recent call last):   File "C:\Users\Me\Blenderfile.blend\Text.py", line 35, in execute   File C:\Users\Me\Blenderfile.blend\Text.py", line 6, in main AttributeError: 'Context' object has no attribute 'selected_editable_fcurves'

I'm using 2.79b, which is why I commented.

Docs for 2.79.4 thought it was earlier Commit (August 2017)  See version via bpy.app.version


text:
Disabling Face Overlay of Multiple Objects
I've done something silly where the faces of my retopology layer is doing a kind of "overlay" atop my sculpt.
While I see the benefit, I only want the faces of the view I'm retopologizing visible, not the back ( highlighted yellow ).
I've toggled "in front" via viewport display and checked other view displays as depicted in the image as well as settings in my modifiers.
I'm using a mix of "Retopoflow" and methods utilized by Grant Abbitt and Julien Kaspar.
The only fix I can think of is disabling the "in front" within "viewport display" while raising the geometry above the sculpt via shrinkwrap's "offset". But I'm wondering if there's another method that's not that?
Here's a google drive of my current file.
Thanks in advance!

I think the best you can do is enable Backface Culling under the Viewport Shading properties. That doesn't remove the geo completely but essentially sets it to look like Hidden Wire if the polygon is facing the opposite direction. I haven't been able to find a way to have it be in front and completely invisible otherwise.

Uncheck 'In Front' in viewport display?

@RobinBetts Your suggestion solved a lot of my issues! I can more easily achieve what my initial question was trying to tackle. Thanks so much!


text:
Issue with overlapping bones
I have character model that have multiple objects and bones. Models were psk files.

I want to merge all bones in one armature but ctrl+j simply doesn't work. It just do overlapping bones.
Here picture of head part in pose mode. I think brown ones are unused bones and have no idea about green bone. Browns don't effect mesh in weight mode (They look purple in weight mode). So I can delete brown ones. White and green bones has weight paints.

In this picture bones in red circle are overlapping and have diffirent weight paints on their own meshes.

In these two images common bones and their weights are seen.

All meshes have common bones like in head and torso. The question is how can I merge bones with their weigths on diffirent meshes?
edit: all meshes imported from psk file =>


text:
How change mesh form with an armature bone
I want to change the shape by moving the bone along the x axis. how to do it?
meaning:
when bone x = 0.000. it's a basic shape
when bone x = 1.000. i want to change shape and save it to this state of bone(position x axis)

You could do it with some shapekeys and with a driver:

Create a cube, subdivide it, give it 2 shapekeys (one basis and a second one), keep the second one selected, go in Edit mode and round your cube with AltShiftS (make sure that the factor is at 1 in the Operator box):

Create an armature at the middle of the cube or wherever you want (parent the cube to the armature if necessary). Right click on the shapekey Value of the cube and choose Add Driver:

Then right click again and choose Edit Driver, choose the bone as Object, set the correct Type and Space (here, Local). You can also right click and Open Drivers Editor in order to change the ratio:

Thanks that what i mean. Сan you advise ?Where can i read about it more?

I don't know, but if your struggle somewhere in the steps, please tell

So awesome! Works even better than I thought. But i have a question at part about Shape Keys. At 0.000 and 1.000 its perfect, but how edit intermediate result?(0.500)

maybe you can try to edit the curve (right click on the value and Open Drivers Editor and edit the curve (make it bezier with V > Aligned)

Got it, I'll try to figure it out! So easy and so powerful experience. Thanks for it


text:
I have a problem with adding particles on a surface
so, I started a Blender Guru donut tutorial, I'm on part 1, level 2: particles. I am not able to make my particles (sprinkles on the donut) go on the upper part of the donut (icing). The tutorial tells you to switch to "hair" in the particles panel and then render to object, after that select the object (in my case a cylinder) to become particles on the icing of the donut. In my case: the particles take the form of the icing, but float on top of it, the particles are like stuck to the icing so I can't put them on the icing manually. I tried to modify the "object" settings, but the particles just disappear.
Edit: I managed to fix the problem.
the link to the tutorial: here
here's what it looks like:
.

please provide blend file so we can check it out

You say "in my case a cylinder", yet in the Render Object I see "Sphere".  1) are you selecting the correct particle object?  2) for you cylinder particle object, set its location to 0,0,0, or else each instance may be offset.   Also try varying the Scale, or deselecting Object Scale which will help you play around with object particles that became too small to see.


text:
Material and Texture not applied to Plane in the 3D Viewport
I am following some old tutorial about Point Tracking and I added a Plane to follow my finger together with Particles.
My problem now is what ever Material and Texture I create it doesn't seem to apply to my plane when looking in the 3D Viewport (I changed to a yellow color).

Also I don't see my plane when I render.

Being a beginner with Blender I am a little confused what is going on. Can someone point me in the right direction ?
And let me know if I didn't provide enough information about my scenario.
File Upload:

if u provide your blend file i can exactly tell what you have to do to achieve what you want

i just opened your file and see that: [1]: https://i.sstatic.net/MhcPG.png ...so your plane is yellow....assuming you are a beginner: click on the plane in the outliner, then click on "." -> then you see the plane (in yellow)

Hmm, it does nothing for me. I am using a laptop, so not sure if I need Numpad keys or not.

Instead of „.“ you also go View - Frame selected

Ah ok, now I see it. Thanks. I wonder why my particles haven't changed to that color. Instead of white bubbles I was expecting this yellow ones :)

As you can see here:

there are several buttons.
In the default settings you won't see material colors in the viewport shading and wireframe shading. (left 2 buttons of the 4)
But if you click on Material preview or rendered view you can see materials.

I tried that before, but it doesn't work. I switched to different layouts and nothing.

If you want I can provide you with the file. Not sure how.

Open https://blend-exchange.com/ and follow instructions

Thanks. I added the uploaded link in the my question.