text:
Bending wires like using move with auto IK in response to another bone rotation
The gif that shows what I want to do was done manually, on each frame before being made into an action. Basically, I rotate the hinge, and the wire is meant to follow the bottom of that part of the lamp. Everything is on one mesh, with weight painting and auto IK.
The reason for this question is that I want to do this without using moving the wire manually every frame. Most of the methods I've tried simply stretch out without dealing with the loop. Is there a way to do this that's better than just going frame by frame and adjusting the wire as the lamp rotates?

Instead of using bones for the wire you can use soft body physics.

create a line of vertices and subdivide it (this is your rope/softbody)

give it these four modifiers (order matters!)

the hook modifier should be set to the upper vertex which is then pinned to the armature. Easiest way is select the upper vertex and press CTRL-H -> this hooks it automatically to an empty

add a copy location constraint to that empty and the part of your armature where you want to pin it

give the softbody a goal with a vertex group, which includes both vertices (the first and last, which should be pinned to armature and lamp)

Set goal stiffness to highest value.
result:


text:
Rigging simple objects
Here is the object I want to animate.

It's pretty much about piston moving in the syringe. But how do I make it move along the syringe's axis, "lock" it in the axis so I don't have to position it myself every frame? What constraint should I use? I noticed the "Follow Path" and "Clamp To" constraints but I am not really sure how do I use them.

You could do it this way (here, syringe and piston are two separate meshes in one unique object):

Create an armature with two bones, the top is child (Keep Offset mode).
Parent the syringe to the armature With Empty Groups.
In the Properties panel > Data > Vertex Groups, assign the piston vertices to the vertices group that has the name of the top bone and the syringe vertices to the vertices group that has the name of the bottom bone.
Select the armature and switch to Pose mode.
Select the piston bone and give it a Limit Location constraint.
Activate all axis to limit the piston in all axis possible.
Keep all values to 0, just change the Y maximum value (here: 2), Y being the vertical axis of the bones.
Choose Local Space instead of World Space, so that it takes only the local space of the object into account.
Now when you move the piston bone it will only go up and down and will be blocked at its maximum Y value.

If you piston and syringe are 2 separate objects, keep the same bone settings, switch the armature to Pose mode, select the piston object, select the piston bone, and ctrlP > Bone. Same thing for the syringe.

I have a bit of a problem since I am not familiar with rigging at all. I should parent both piston and syringe to the armature object, right? Both in syringe's and piston's Data there are two vertex groups named just as the bones are, if I do it. How do I exactly assign them?

Nevermind, figured it out.

when you parent With Empty Groups, it gives your mesh as many groups as you have bones, with the same bone names, but it doesn't assign these groups to any vertices, you have to do it manually: select the vertices you want to assign to a group and press the Assign button. Then the bone will control the vertices group that has the same name.

Often for mechanical rigging (no deform) it is simplest to parent objects directly  to assoc. pose bone. No modifier or vertex groups required.

"to pose bone"? what do you mean?

Make pose bone active , select object select armature Ctlr_P parent to bone.

you mean if the meshes (piston and syringe) are separate objects, but if they are not?

Yes  they need to be separate objects.  The OP considering using a follow path constraint would suggest to me separate objects. (as does first comment above)

oh ok, I'm going to edit my answer to take this into account  ;)

Yes, he's right. They're separate objects, and I did the job just by parenting them to appropriate bones.

source: Stack Exchange

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

sort: votes


text:
how can i make blender render only the visible parts of the object?
(i use blender 2.79)
it seems when blender renders an object it does render also the non-visible back of that object and for that reason, it increases the rendering time.
so to test my theory I had cut an object in half I removed the non-visible part in the back
and the render time has been decreased.
but doing this to every object i want to make is impractical
so is there a way to make blender only render the visible parts? inside of rendering everything even the unseens object ?

Just because parts of objects that are not directly visible to camera doesn't mean they don't contribute to the render solution. They may still be visible in reflections, cast shadows, onto surfaces, bounce light differently, occlude light sources, etc.

Using cycles, there is a BVH Bounding Volume Hierarchy that is built based on the surface area heuristic and spatial splits that try to optimise what is in the scene, what geometry will go to the GPU etc..
But that won't split back of the objects that may be reflect some of the ray light of the path tracing.

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


text:
How to know the size of a Text object with Python?
I am trying to measure a Text Object with Python, but I am getting discrepancies when I run my code in the Blender Python Console and then in the Text Editor (with output to the System Console).
My code is as follows:
import bpy

# Create text object
obj = bpy.ops.object.text_add(location=(0,0,0))

# Set the text
bpy.context.active_object.data.body = "Hello World!"

# Find the text size (try with two methods)
dimensions1 = bpy.context.active_object.dimensions
print(dimensions1)

dimensions2 = bpy.context.object.dimensions
print(dimensions2)

If I run this code from the Blender Console I get the following object in the viewport (measured to be like 5.3 m in the x direction, with the Measure tool, as shown):

And the Blender Console reports the correct size as a result (5.3160 in the x direction):
<Vector (5.3160, 0.7000, 0.0000)>
<Vector (5.3160, 0.7000, 0.0000)>

But if I run the very same code from the Text Editor, which reports the results to the system console the size reported in the System Console is quite different:
<Vector (1.8980, 0.6910, 0.0000)>
<Vector (1.8980, 0.6910, 0.0000)>

Yet the object in the viewport is keeps the same size as the first one (5.3 m)!?

Am I doing something wrong?
Why one method gives the correct result (5.3 m) and the other not (1.89 m)?
Why the mismatch between the results?
Can you reproduce these results on your computers?

Thanks in advance for your ideas.
(I am using Blender 2.83.0 on Mac OS 10.13.6).

Should work on text objects as well: https://blender.stackexchange.com/a/8470/31447

Thanks, @brockmann. I just tried the method you refers. Sadly it does not fix the problem. I keep getting different results from the System Terminal and the Blender Console. Is this a bug in Blender?


text:
"Export UV Layout" no there in the menu
I cannot find the "Export UV Layout" option in Blender. The menu option "Export UV Layout" is simply and plainly not there. I have this problem with Blender 2.81, 2.82, 2.83, and 2.90, so it is most certainly something I am doing wrong.
I searched for the "Export UV Layout" add-on in the preferences and the add-on is not there. Can you please tell me what do you think I am doing wrong?
I am doing as follows:

New project.
Select the default cube.
Change into edit mode.
Go to the menu UV -> Unwrap
Change into de UV Editing screen layout.
Menu: Image -> New... -> Ok
Select all vertices of the UV map
UV Menu -> and fail!

I tried using the "Operator Search... (F3)" option, but it doesn't find it.

The "Export UV Layout" is not there. Can you please spot my mistake?
Thank you very much.

Search for 'UV' rather than 'Export' in the addons:

Indeed, there it is. Thank you very much John. You absolutely solved the problem. Best regards.


text:
Soft body simulation wasn't rendered
I made two object ; one was for soft-body simulation, and another one was for mesh-deform. Set the simulation to both and made animation.
But, I rendered animation and checked it, the simulation had not worked. I can see simulation at view port correctly, but at rendering, I can't see it.
Could you tell me some idea for this problem?
Thank you for any help.

If you haven't already, I would recommend that you bake the cloth simulation before you render it. If you already have, try baking it again.
If it still doesn't show up in the render, check to make sure "Render visibility" (the camera icon) is enabled in the modifiers panel for all of the objects associated with the simulation.

Thank you very much! As you say, I had not baked simulation before render animation. Thank you for your help and kindness.


text:
Does array modifier constant offset use blender units or the object's radius?
From the official guide and some video tutorials I understood that constant offset move in blender units, but when I try to apply it, it works like relative offset but using the radius instead of the whole dimension. In the picture below I used constant offset=1 in all 5 cubes.

I'm new to blender so I don't know if I misinterpreted the guide, fail to apply it or if it is a bug.
I'm using Blender 2.79 on Linux,Suse Leap 15.1

@batFINGER has answered this.. this is just putting the same thing another way. The constant offset is in Blender units, but in the Object Space of the modified object. If you scale the object, (as opposed to scaling its mesh, which you would do by scaling it in Edit Mode) then the object's space is scaled with it.

That's why it's better to use Relative Offset as it takes the object's size.

@Lukasz-40sth on a case by case basis.  Relative makes it difficult to maintain a Constant offset (and vice versa)

Scale is factored in
The constant offset is in Blender units, but in the Object Space of the modified object. If you scale the object, (as opposed to scaling its mesh, which you would do by scaling it in Edit Mode) then the object's space is scaled with it. (Thankyou @RobinBetts)
So if scale is 2 and constant offset is 1, scaled by 2 is 2 (explaining the result of your "What I got" column).

Image shows default cube with constant offset one array mod.  Notice at unit scale both expected and result are the same.  Note: non unit scale is one of the most common reasons for getting unexpected results in blender
It is then scaled by 2. (Result: "What I got")
Finally the scale is applied CtrlA Scale(sets on local mesh coordinates object scale returns to unity, equiv of edit mode scale or changing radius when creating cube) (Result: "What I expected")
To keep scale and maintain the 1 x offset could drive the constant offset by
1 / self.id_data.scale.x

making sure to check use self in driver properties.

Thanks a lot. This was driving me crazy.

So that's why has been the Constant Offset in Blender always "broken" :-D. Here's my vote up :-)


text:
Trouble with first time motion tracking
I'll be concise:

while I can get to motion tracking I don't have the same menus I see on specific tutorials that seem to be running 2.8.  odd.
I can Ctrl+A and place markers all over.
I cannot get them to track and show tracers when scrubbing left or right, regardless of which track button I'm using (command T, or Shift command T).

Everyone seems to have a menu next to "help" that shows motion tracking as an option.  I've got nothing but tabs up there (layout, modeling, sculpting, UV editing, etc).

Hi welcome! You should perhaps investigate (eg: ask the author) which version was used to create that tutorial you're referring to, then use that exact same version (download that version from the release repository - https://download.blender.org/release/ - and run it from it extracted folder). When you understand the tutorial workflow, using another newer version could just need to adapt it.

The simplest way to access the layout for tracking is to create a new project: File->New->VFX.

It should open with all the windows you need for motion tracking.

To display the paths for tracking marks Open Clip Display and enable Marker Display-> Path


text:
Strange effect on the solid color faces
I'm trying to achive something really simple but I've got the annoying effect. I'm using Cycles for rendering. On some meshes I applied the solid color wihtout any special effects (just the Diffuse BSDF with the chosen RGB color). I have one point light and a surface shader set in World Properties. The area on which the strange effect appears doesn't have multiple faces, in which case some problems with normals might appear.
I even didn't know how to name this visible effect, so it was difficult to find the solution somewhere. It's something like a shades along the faces. If there is already an answer on this forum, sorry I didn't find it - please direct me to this answer.
Thank you in advance for any help. Probably it is something very simple. But I don't have much experience in Blender, especially in materials and rendering.
Mariusz

This looks like denoising artifacts. Denoising is active by default in newer versions of Blender, and a quite powerful tool. It smoothes the noise that you get when rendering, and can save some render times, but results in some "washed out colours" if rendering with too few samples. Try increasing your render samples, and try deactivating Denoising for testing purposes to see the difference.

Yes, you are right. Deactivating Denoising didn't make me 100% sure that that's the reason, because there was a lot of noise (what is not really surprising :) ), so it was difficult to ensure that the effect has gone. But when I left Denoising turned on and increased much the number of samples the render effect is much better. Thank you.


text:
Why is half of my UV mesh off of the grid, and how do I fix it?
I've got two models, each with their own texture, that I'm trying to combine into one model with one texture so I can mod it into a game. I've tried following tutorials on how to bake textures into one, but when I join the models and look at the UV editor the body of the model is off the grid, like this:

This makes it really hard to follow tutorials, since all of the ones I've seen have everything nicely located within the grid, and I've tried in Blender and 3DS Max. None of my attempts have resulted in a texture that lines up with the model in the correct way, and I think this has something to do with it. Has anyone else experienced this?

I don't know why it doesn't match up to begin with. But I do think I know how to fix it. Select all your UVs in the UV Editor and from the UV menu, choose Pack Islands. This will force all your islands to scale down (evenly) until they are contained within your UV space.
Another useful feature, under the same menu, is the Constrain to Image Bounds checkbox. It will prevent any islands or UVs from being dragged outside the UV space.

@R-800 that worked, thank you!


text:
How do you change the "False Color" colormap?
I am testing the Color Management option to show an image with the setting of "False Color", which shows, for example, the following image:

It's a colormap according to the scene's luminance; red, orange, and yellow regions are highly illuminated, while blue, purple and black are barely, or not at all, as shown in the following image of the same scene but with a "Filmic" color profile:

The problem:
Is there a way the change the colormap (or color ramp) for another one? For example, is there a way to remove that gray circle in the middle of the green area? (which according to this source stands for the middle gray value.)
Where does that color map resides within Blender? Can it be changed like if it was a color ramp node?
The official Blender documentation page doesn't give any information on this particular topic. It barely mentions the "False color" feature.
(Yes, I know one can render the image as pure luminance, like the black & white one, and then apply a ColorRamp node in the compositing node tree, however, I would like to use this "false color" feature in real time (with my own colors), while working with Blender for setting up lights' and objects' positions, not necessarily for rendering a final image. Having control of the color ramp would allow me to adjust some luminance thresholds, therefore higher precision work would be possible.)

Related: Is there a way to adapt False Color to be seen for color blind people?

There's the answer. Thank you very much Jachym.


text:
How can I animate a face onto a 3D model using Grease Pencil?
Is it possible to animate a 3D model with an animate-able face made with Grease Pencil? I have an idea on how to rig the GP but I'm not sure how I can attach it to my model. I've tried parenting it to my model and then the armature and adding weights but neither worked. Once I pose the head the GP doesn't follow. Fairly new to Blender, so I'm not sure if this sounds absurd or not.


text:
Modifier to remesh objects
I remember a modifier which allowed to remesh a object and to choose something like a tree depth. Depth one led to a single cuboid surrounding the whole original mesh. Increasing the depth further the mesh was subdivided in more faces and got closer to the original shape. Can anyone point me to that modifier? I am searching for it now quit a while and just cant find it...
Best regards

You are looking for the "remesh" modifier.

Ok thank you. Maybe it is really what I am looking for and just remember the behaviour a little bit different.

What behaviour are you looking for ? the "octree depth" is the parameter you can tweak to achieve what you asked in your question. I f you want a blocky look remember to set the mode to "blocks"

Sorry you are right. It was the tool I was looking for, I was just not used to such an ugly mesh, therefore I remembered a even cleaner mesh using that modifier.


text:
How to create a dashed line?
What is the simplest way to create a horizontal or vertical dashed 2D line in Blender?

Could you please provide more info on what you are trying to do?

@Nate_Sycro27 I want to put a dashed straight line on the one face of a cube.

Related maybe https://blender.stackexchange.com/a/76111/15543

Just for fun, you can use a simple plane with the Array modifier :).

You can create a long cylinder.
Under Edit mode, insert several "loop cuts" to the side of the cylinder;
with "face select" activated, you press "a" once or twice to select all faces.
Press "space" and write "checker deselect".
At this time, you have 2 options, assign a transparent material to these faces, or you just delete them (I would go for the transparent material, so you get a single object all connected).

I just remembered another way. You do a small cylinder. Rotate it on the direction you want. Using the "array modifier", you have control on the spacing between cylinders (dashes) and the array length will be the length you need to your final line,

(Following Mcunha comment, using Blender 3.6.1)
For a single body pattern (e.g., dashed line):

Fig. 1: Create the pattern as a Bezier curve, setting its origin at one end. Use “Bevel“ to make it a cylinder.
Fig. 2: Create the curve to populate with the pattern as a Bezier Curve. Projection along this curve is less unpredictable if the pattern and this curve share the same origin (see the note on this page: https://docs.blender.org/manual/en/3.6/modeling/modifiers/deform/curve.html). Make it a child of the pattern, just to keep things organized.
Fig. 3: (1) Add to the pattern an Array modifier. Specify the curve to populate to set the repetition count, and adjust the gap with the “Relative Offset”. (2) Add to the pattern a Curve modifier specifying the curve to populate as the “Curve Object”, and try and test different values for the “Deform Axis”.
Fig. 4: Adapt the final shape of the pattern using “Geometry/Extrude” and “Bevel/Depth” parameters.

For a multibody pattern (e.g., dot and dash line):

Fig. 5: (1) Create each piece of the pattern as a Bezier curve. All should share the same origin to keep aspect ratio and relative position if scaled later. (2) Place an Empty where the next pattern should be.
Fig. 6: Repeat the process described at Fig. 3 for each piece, using the Empty to specify the Offset. Every piece is deformed to follow the underlying curve.
Fig. 7: For straight lines (see bottom curve), it is more convenient (1) to add a Plane to the pattern, (2) to make it the Parent of all the pieces, (3) to set Instancing on Faces, adjusting its visibility by toggling “Show Instancer”. Because instancing is applied after the Curve modifier, the pieces are not deformed to follow the underlying curve, yielding to misalignment for patterns long compared to the radius of curvature of the curve to populate (see top curve).
Fig. 8: Examples. Counterintuitively for the circle, the pattern origin is next to the circle center, not to the starting point of the Bezier curve.

You can do this by using Blender's knife tool. In edit mode, select the knife tool, and LMB to start. Then drag the line to the opposite corner of the cube. LMB again, and then press 'enter'. You have a new diagonal line now on the cube.

I need to draw  a vertical or horizontal line. It should look like [ | ] or [-].
The line should consist of the small lines like "- - - - - - - -".


text:
"Deselect On Nothing" python script
I am trying to emulate "view3d.select" shortcut but I don't know how to emulate "Deselect On Nothing" option of "view3d.select". Do you guys know how?I am using blender 2.93.

https://docs.blender.org/api/current/bpy.ops.view3d.html#bpy.ops.view3d.select

Please [edit] any new information into question.

thanx, but I've just realized it wont work.
what I want to do is, clicking vertex and moving it pressing mouse button without pressing G key, so I use this script.
bpy.ops.view3d.select('INVOKE_DEFAULT')
bpy.ops.transform.translate("INVOKE_DEFAULT")
I need to omit all bpy.ops.view3d.select options in order to make it work in python script.That script needs "deselect_all" operation to make it perfect but seems it's dead end now.


text:
How to get driver's own full data path?
For example I set a driver to rotation_euler x of a bone called "Bone_L" and it uses a my custom function in driver_namespace. I need to get other half of Bone_L,Bone_R's animation data and sync Bone_L with Bone_R.So I need Bone_L's own full data path.
if I simply copy full data path by right clicking bone's rotation column and click "Copy Full Data Path", I can get this info.
bpy.data.objects["Armature"].pose.bones["Bone_L"].rotation_euler[0]
I need 3 words of this data path. "Armature","Bone_L", and "rotation_euler[0]".
I am gonna use those 3 words to access other half of Bone_L. If I can get those 3 words, I can access animation data of Bone_R like this.
armaturename = "Armature"
bonename = "Bone_L"[:-1]+"R"
transform = "rotation_euler"
xyz = 0

Bone = bpy.data.objects[armaturename].pose.bones[bonename]
Transformation = Bone.path_from_id(transform)
Value = Fcurves.find(Transformation, index=xyz)

Scene_Name = bpy.context.scene.name
framenumber = bpy.data.scenes[Scene_Name].frame_current

KeyframeValue = Value.evaluate(framenumber)
return KeyframeValue

Is there any way to get Bone_L's full data path inside its driver function?

https://blender.stackexchange.com/questions/42150/splitting-an-objects-data-path-into-hierachal-list

thank you. I will use the function before using that I need to know how to get the path inside Bone_L. Do you know how?  I need to split the path to use it but I don't know how to get this path bpy.data.objects["Armature"].pose.bones["Bone_L"].rotation_euler[0]

Can you please state this clearly eg you wan't that full data path from what starting point?  Are you using self in the driver?

I need to get Bone_R's animation data and paste it into Bone_L, but I need to get Bone_R data by Bone = bpy.data.objects[armaturename].pose.bones[bonename]. to make it work I need to get both bone's armature name, name of Bone_L and transformation name of Bone_L. I am using self but it only gives me Bone_L's name or it gives me the path? I know self.name gives me a name.

How about repr(self) then?  As for what it's driving, maybe create a wrapper method

how to use repr()? I googled it but I couldn't understand how.

I quit using drivers. It's much easier to use just normal functions to control bone animations and it makes easier to manage all script controlled bones. it was hard to find which bones have drivers.


text:
How to stop driver's "TRANSFORM_FINAL" Error message from popping up in system console
There is a bone called CTRL_Head and it has Copy Location constraint.
I added a driver to this Copy Location constraint's mute state.  This driver simply checks scene's custom property and if this custom property is 1 this driver returns 0 if custom property is 0 driver returns 1, but I always get this error because of this driver, and this error seems not to cause anything bad but this error message itself is simply annoying because it fills up system console window.
find_node_operation: Failed for (TRANSFORM_FINAL, '')
add_relation(Target -> Driver) - Could not find op_from (OperationKey(type: TRANSFORM, component name: '', operation code: TRANSFORM_FINAL))
add_relation(Target -> Driver) - Failed, but op_to (OperationKey(type: PARAMETERS, component name: '', operation code: DRIVER, 'pose.bones["CTRL_Head"].constraints["Copy Location"].mute')) was ok

I don't know how to fix this error, so please tell me how to fix this.
I guess this error message pops up when "bpy.data.objects.pose.bones.constraints.mute" has a driver.

We'll need a lot more detail than this.  Can you add a blend file to your question that has an armature that shows the problem?  Is this happening in a script?  If so, please include it. (How to add a blend file)

I can't upload blend file because it's so complicated and big. then this error is not general error.

make a copy of the file.  Delete everything but the armature that has the problem and any scripts. Is the problem still there?  Upload that file, if it is.

ok I will try to

https://www.dropbox.com/s/fxg6m4zklanjm99/TEST_ARMATURE.blend?dl=0 this is the blend file, Just simply click "Update Dependencies" button in drivers editor please. you will see the error message in system console.


text:
IK rotation control question
please see the picture below. there are 3 bones, bone A,bone B, and bone C.bone A is bone B's parent and bone A and bone B are connected. bone B has IK constraint and chain length is 2, target is bone C.If I move bone C, bone A and bone B bend like left picture, but I need them to bend like right picture.

I need bone B to bend fully, but bone A to bend at half degrees. For example when bone B bends at 50 degrees, bone A needs to bend at 25 degrees.I tried to edit bone A's Inverse Kinematics values in Bone Properties,but it doesn't work, and I added a driver to bone A and make it use bone B's rotation value(like "var/2" driver expression )but it causes dependency error and it breaks animation. Is there any way to solve this problem?

Maybe this could be a solution for you but it is not exactly BoneA.rotation = BoneB.rotation / 2

A dummybone is used for the IK constraint.
Bone A copies rotation of dummybone with half influence.
Bone B is parented to Bone A and damped tracked to dummybone to avoid dependencies.

thank you. my temporary solution is, bone B is child of bone A.bone A has damped track, target is bone C and bone B has IK, target is bone C and chain length is 1. damped track influence is 0.5. It may work like yours.


text:
No BAKE BUTTON in 2.92
I'm trying to upload a fluid animation to a render farm (rebus.net) but it says I have to do a FINAL bake. There is no FINAL bake button as far as I can see in 2.92, just the All bake button and Modular. I've tried Modular bake as well - no difference. Anyone come across this issue?
Thanks in advance.
Rich

There has been a renaming. What before was Final has changed to All, while Modular stayed Modular. The difference between Final and Modular was, that with modular you had to bake data, mesh, noise etc. separately which allowed you to build the simulation step by step.
So if you had a high resolution and baking the data took long but was great, then you baked the mesh and the settings were wrong so it looked horrible, then you could rebake the mesh without having to rebake the fluid data.
Final assumes you've finished testing your settings and are ready to bake everything at once for a final simulation, not separate parts one after another - so Final bakes all of the simulation. I don't know the reason, maybe people were confused about what Final meant, so to clarify that all is baked together it was renamed to All.
But that's just a guess on my behalf. The result is the same, Modular let's you bake different parts separately, Final and All simulate everything completely with one bake.
In how far the Renderfarm is able to work with the simulation I don't know - but the baked data should not be different from Final to All.


text:
Lines or streaks when Applying Textures
I created a cube and I added  a simple texture to it. On some faces of the cube, the texture is skewed and this produces some strange lines on some of the faces of the cube.
And I don't think it's about how I unwrapped the cube because even if I set the Texture Cordinate Node to Generate, those lines still persist.
Can anyone help me solve it?

yes please, I will..

This effect is produced by having faces unwrapped as lines in the UV coordinates. Meaning, your long rectangles are represented as long lines in the UV layout, without any width to them. So the pixels of the texture are correctly represented only in 1 dimension (ALONG the rectangle), but not in the other.


text:
Blender glass shader adds a weird shading to the edges
I was trying to create a realistic plastic , transparent shader.
I just mixed a few nodes at first and it was great till later some noises and weird shading took over the edges of the model.
I would like the edges to look the same as the inner the rest of the model
Here are some images.

try to add thickness with the solidify modifier, as otherwise the whole bottle will be rendered as one block of glass (plastic)

thank you soo much Sir


text:
Converting Particles Into Fluid
I wanted to ask if there is a way to convert a particle system to a fluid?
Is it possible?

There is a plugin called Cube-Surfer that can do that. It voxels your particles and creates a mesh-skin around them.
Take a look:
https://www.youtube.com/watch?v=Tz2VivdcfQs
Download:
http://pyroevil.com/cubesurfer-addon-download/

Don't forget to mark the answer as accepted, if it worked for you.

please how do I do that Ben?

and I also don't know how to convert the script into an addon

It is an add-on. My guess is, you did not install it properly.
To select an answer as accepted, set the check-mark next to the vote count. Take the tour, it has a guide: https://blender.stackexchange.com/tour

Hey, to mark an answer as accepted, just click the check mark next to the answer.

Pyroevil add-on does it, but the company's official site is down.
This is up right now:
https://github.com/Pyroevil/CubeSurfer
Go there and download the add-on.


text:
Voronoi texture Eevee rendering problems with 2.81
I am having problems with Voronoi texture node on Eevee after the new update (2.81). It is working fine on Cycles and older versions of Blender (Cycles and Eevee on 2.80)

don't confirm on 2.81.16 how do other procedural textures behave in eevee? have you tried factory reset blender?

When I import it to an older version, it automatically adds a math node (multiply), so it seems there is some kind of way to convert to new Voronoi that I don't understand

The rest of procedural textures are OK

Same situation on 2.82 alpha

Has this been fixed|? I am using blender through Steam and have the same problem.

I ended up replacing my laptop to something with decent GPU. Do you have Intel or built-in graphics card?


text:
How to get x, y, z texture coordinates in LuxCore?
I do a lot of math-based procedural texturing, and have been considering switching a few of my scenes to LuxCoreRender instead of Cycles since it seems to do a better job with reducing noise from emission materials. However, I can't seem to figure out how to get the local coordinates as values to use as the starting point for my textures. In Cycles I would've just used the "texture coordinate: object" input and then plugged it into "SplitXYZ," but I'm having trouble understanding how to do that with LuxCore nodes. What should I do?


text:
how to make an object blend with the background without looking fake?
i use blender 2.79
if you look at the object in this case the moon, it looks so fake compare to the background
i used a plane with an image of fog on it
does anyone know how to make my object blend with the background ?

I think it's a problem of contrasts, you need to either:

Push up the black levels of your planet

Or decrease the medium values of your background so that the 2 elements work together.

Also, maybe it's weird that some fresnel comes on the edge of the planet that faces the darkest side of space, try to rotate it (not sure about that but it may work on the perception)? And add some stars?


text:
how to make blender render less from far objects?
(i use blender 2.79)
in video games, the farther is the object the fewer details it has, and that of course to save memory
but how to do it in blender
if you have 2 complex objects and one of them is closer to the camera than the other
how to make the farther object get less render?

Dude, breathe! Try to use punctuation, structures like paragraphs and so on. Some images would also help. Try to describe your problem as detailed as possible. It's really hard to get anything out of your question, when it sounds like incoherent ramblings.

LOD (Level of Detail). You may find this earlier post usefull:  https://blender.stackexchange.com/questions/64614/is-it-possible-to-have-automatic-lod-level-of-detail-on-large-scenes. I


text:
how can we remove the blurry effect that has been caused by denoising?
(using blender2.82)
hey guys i have been trying to add fog to my scene but when i do it i have a lot of noise in the image i tried to use  blender default denoise but it made it worst because it added huge amount of blur in place of the noise i also tried to use intel AI denoiser but it did the same thing it didn't help
here are the examples:
here with no fog or denoise
and here with fog without denoiser:

and finally here with denoising:

how you see the grass get so smooth in bad way!! can any one help? i just want the noise gone without effecting the other objects !

What method are you using to denoise?

it is the same result with the INTEL AI denoiser and blender default version

but if you mean the last image i used the AI version

so the compositor node?

@AllenSimpson yes i used the compisitor node

use more samples and avoid denoising.

In the case of fog, if you can get away with adding it in compositing - using the mist pass is one way - instead of brute-forcing it with volumetric calculations, it should save a lot of time. Of course whether this is practical or not depends on the scene, but the example in your question looks like something I would tackle in compositing. I realize your question is not new, but I mention this for people's future reference.

Denoisers are an imperfect, but useful tool.
I have this scene where there's light coming in through a window and I've given the room a volume to catch the light.  If we run a low amount of samples you can see the fireflies produced.

This is normal, the nature of a volume with lower density is that it will only affect some rays cast from the camera.  The denoiser gives us this ugly result:

with only little wisps of dust visible.  This is also normal, because the denoiser can only work with the information we give it.  I only ran this at 12 samples, and it is really interesting that it can produce this result.
Usually the answer is to run more samples, but even at 300 samples it comes out as this:

Which is part of the way there.  I cranked a small region up to 1200 samples to turn this:

into this:

That's a lot of samples, but you can probably see from the noisy image that it would take many thousands of samples to render this volume in a realistic and pleasing way.  Volumes with lesser density are just very noisy.  The grass will be a lesser case of this, where more samples will give each pixel more influence over itself.
I did find in doing this that volumes aren't contributing to denoising normal or albedo, probably by design, but I wonder if it isn't related.

You may want to play with Adaptive Sampling instead, run some experiments with a render region.

thanks for the answer :)

If this answer was helpful, please consider to accept and up-vote it @LightKnight How this site works: https://blender.stackexchange.com/tour


text:
how to make an bright spot similar to a star?
how to make an bright spot similar to a star ?  i  we tried to make a sphere and add emission to it
but it didn't work it only made the sphere clear bright without looking like a star

you know something similar to this image right here

Search for Lens Flare like here https://codeofart.com/flares-wizard/ you can try ten of them. In general all these lens artefact are done in post proces. Simple one can be done in Compositor with Glare node. Can be done also as set of images rigged in 3D or Eevee use simple Bloom effect.

Does this answer your question? How do I achieve this kind of light star effect?

thanks guys for the help flares wizard achieved what i wanted

For simple static lens flare you can try blender Composite nodes:

Light source very small Object with high Emission like 1000.
Big star is Glare node > Simple Star
(Streaks works too, but I could not get them enough long)
Central effect is based on Glare node > Ghost Fog "scratched" by Cloud Texture plus Sun Beams node.

For advanced  and more flexibility try this https://codeofart.com/flares-wizard/

thanks dude for your answer, but sadly because i don't use blender 2.8 that much i couldn't use these nodes to link them to my object :( because i don't know how,but flares wizard did achieve what i want thanks again :)

@Duarte Farrajota Ramos What is the common strategy of closed Q. Should I move this answer to your link to make the answer useful? Thanks


text:
texture sky doesnt work in blender 2.8 (Eevee render)
when i want make sky and sun i just use sky texture but with new render everything convert white, like this.

so can i fix it? or can i do another way to make sky and sun(with new render)
and sorry if i not speak English very well.

I just checked and it is not supported in EEVEE (yet?) according to the official documentation. https://docs.blender.org/manual/en/dev/render/eevee/materials/nodes_support.html


text:
Viewport Display and Base Color in Solid Display 2.8
is there a way to link the base color of an object and the viewport display color in solid mode? or do you have to separately assign the color to see it. Just want to avoid switching back and forth between eevee, cycles and solid mode on my weak computer.

Are you talking about a dynamic link that updates when you change the base color? Bc. each material has a viewport display setting. at the very bottom (properties tab) where you can set it manually.
Linking probably won't work, because there can be numerous "base colors" in a material.

@FrederikSteinmetz ok

I can write you a script that tries to find a shader node and uses its first color input as the VP color, but you'd have to run that everytime you add a new object.

All good, I have already accepted I have to change the color twice. Thank you


text:
Object Selection options not showing in 2.8
I am using Blender V2.8. I am a novice user. The options to Add, Subtract from selection which is supposed to be shown below the top bar are not visible on my interface. What am I missing?

Assuming that your problem is not fixed yet, and you are using the latest version of blender (Version 2.82):

If the header is missing like this

then just click on the arrow pointing down at the top-right of the viewport window to unhide it.

The texts were replaced by icons as shown below:

If the Header is missing and you can't find the arrow as shown

then right-click on one of the control buttons at the top of the viewport window to show a Options where you can find the "Header" options And activate the "Show Tool Settings" checkbox found as shown below.

Are you sure this bar still exists? All these options are available on the N panel > Tool tab. You can also find them in the Properties panel > Active Tool panel (second tab from the top).


text:
Blender renders different from preview
I have this wierd issue in blender 2.8,
im trying to render (with both cycles and eevee) this wolf

but when i try to render it does this.

I tried everything and i dont know what to do.
I dont have subdivision surface modifier.

Check your visibility options on each mesh supposed to be rendered. The render visibility toggle is hidden by default in the outliner, find it in the Filters:

For the main mesh, t looks like you unchecked the "Show Emitter" option in the render panel of your hair settings.

If neither of these is the issue, maybe check your materials.


text:
Extrude multiple Shapes along the same Curve
I wish to switch from C4D to Blender and I'm trying to replicate the same workflow I'm already used to before making the step.
In this specific case, I need to extrude a number of different Shapes (be it shape-0, shape-1, shape-2, shape-3) along the same Curve (be it curve-0), but I noticed that would require me to have many hard copies of curve-0, since the extrusion is generated from that object. Making Instances of curve-0 wouldn't work because that makes it impossible to change the extrusion Shape.
For reference, in C4D I would create a Loft object and put any Shape and curve-0 in it to generate the extrusion. In that case, multiple copies of curve-0 are still required for multiple Lofts, but then I can use Instances since they don't need to be modified. I can then just edit the original curve-0 to modify all the extruded objects at once.
I couldn't find anything that fits my issue around. Am I missing something maybe?

maybe I've missed something in your explanation but you could make a linked duplication of the curve (alt D), if you need to modify the curve's shape select one of the duplication and the modification will be replicated on the other ones

@moonboots That might work, but in that case I need all the Curves to be linked to the original one except for their bevel object. I'm trying but I can't seem to achieve that.

@Leander I can do that later when I'm back home, but it will be just a bunch of shapes extruded along a single spline.

Yeah have also been longing for that functionality, but at the moment it isn't supported as far as I know, since both curve shape and curve bevel are part of object data. Maybe when overrides feature arrives this will be one of te overridable properties eventually. Until then I'll try to think of a clever workaround

As far as I know this is currently unsupported, since curve geometry itself and Bevel Object are both part of Object Data.
Maybe this will eventually be supported when Library Overrides project is merged, until then here are two workarounds.
Workaround 1 - Curve deform modifier
Use bevel objects on independent "dummy curves" with a simple straight geometry, but set handles to Free or Automatic so there are enough geometry subdivisions.
Now to each of these dummy curves add a Curve Modifier and set it to an independent instance of the same "deforming curve" sharing object data. There must be one instance of "deforming curve" for each "dummy", both at the same world space coordinates, so deformations are undistorted.
Easiest way to set this up is probably to complete a single "curve bundle" and then clone both around and just change the bevel object.

Cons: The dummy curves wont keep up with severe length changes from the deformations, only shape changes.
Workaround 2 - Array + Curve deform modifier
Slightly extrude your "section defining curves" so they have a small but non zero height, then add an Array Modifier set to Fit Curve on Z axis.
Pick a "path defining curve" as curve to fit. Now add a Curve Modifier set to the same curve object on Z axis.
Clone this modifier setup around to different "section curves", but always set the "path defining curve" to an instance of the original one so they always copy the same path shape. Once again make sure objects using Curve Modifiers are always coincident with their deforming curves.
Cons: Since this relies on an Array Modifier there will always be a slight  difference (as little as the extruded height of the section) in length between deforming curve and the actual profile. Decreasing height will improve precision at the expense of performance.

Thanks for the reply (and sorry for being so late), this might do I guess! I will try this as soon as I can.


text:
(2.79) How do I make a plane transparent without making the texture transparent?
I want to make the plane with the texture transparent, but I don't want the texture to be transparent. to be clear, the texture is a png file with some parts being transparent, but I cannot figure out how to make the plane transparent without making the texture transparent.
I'm using Blender version 2.79.

so actually I'm an idiot and forgot to use face textures and alpha face textures
I got it working
whoops


text:
Creating and Animating Line Segments?
I have a zig-zag figure I want to import and manipulate in Blender, preferably on a segment-by-segment basis.
The canonical method for doing "line art" in Blender appears to be to create a curve object then, in the Properties, crank up the Bevel Depth to a suitable value.  The problem is that, for "curves" having hard, acute angles, you end up with a very thin, distorted shape.
Here's an example curve.  All handles are set as vectors:

Here's the same curve with a bevel applied.  Note how the generated tube is flattened, making it nearly invisible when viewed along the Z-axis.  The sharper the angles, the thinner the resulting tube:

I'd like uniform "thickness" no matter what angle I view it from (particularly along the Z-axis).  How can I best achieve this?

https://blender.stackexchange.com/questions/53475/how-can-i-extrude-curve-shapes-onto-curve-without-tapering/53486#53486 https://blender.stackexchange.com/questions/87253/can-i-extrude-a-path-in-x-y/87254#87254 https://blender.stackexchange.com/questions/56079/how-can-i-make-a-perfect-sweep-with-bevel-object-in-bezier-curve3d-pipe/56115#56115 https://blender.stackexchange.com/questions/66353/how-to-make-beveled-90-degree-corners-on-a-curve-better/66367#66367

This mesh is maden by 7 vertices only, with a skin modifier. Tweak the thickness with Mean Radius values, and don't forget to select one of the starting vertices and use the "Mark Root" function on the skin modifier.

If the original curve is planar, then a 2D curve (right) will miter correctly where a 3D curve won't:

In that case, you can set the curve to 2D in its geometry panel.


text:
Deforming Grease Pencil Strokes in 3D
I think I'm missing something elementary, but I'm unable to figure out how to deform
grease pencil strokes in 3D as demonstrated in the following videos:
https://www.youtube.com/watch?v=kpY-WVQUxYw (seconds 30-38)
https://www.youtube.com/watch?v=5FW3Lrnm5Eg (seconds 50-54)
I have managed to do something similar using bendy bones, but these
videos seem to suggest that is not necessary (and they don't explain
how to do it!)
TIA.

There's a new UI method intended for this (see below) but I find that the standard binding workflow actually works. In Object Mode, create a Grease Pencil object. Next Create an Armature object, and use Edit Mode to make whatever adjustments are needed to get them to line up as desired. Next, in Object Mode, select the Grease Pencil object, and Shift-select the Armature object, and from the Parenting menu (Ctrl-P), choose to bind with Automatic Weights. The Grease Pencil object will follow the bones.

The new UI for doing this is in Edit Mode for the stroke itself. First, create an Armature modifier for the Grease Pencil object, and point it to the Armature to be bound, as a target. Then in Edit Mode for the stroke, from the Grease Pencil Menu, go to Weights > Generate Weights > With Automatic Weights.

I assume these methods are the same and don't know why you would choose between them. But I think it's easier to use the old method.

Thanks! I managed to use bones to achieve this effect, in a similar manner to what you suggested. In those videos, is the deformation being done in this way (using bones?) I don't see any armature/bones in the viewport in those videos...

Yes, bones are involved in my screenshots. Can you not see them? I set the stroke to draw "In Front" because I felt that it wasn't easy to see the stroke otherwise. But now I realize that maybe because you were not expecting the stroke to draw in front of the bones, that you didn't see that the bones are indeed there. It looks like we used the same method, but maybe you thought we were using a different one. So much for visual aids... :(

Oh, I see the bones in your screenshots perfectly! I meant to write that in the youtube links that I posted in my original question (and at the time slice mentioned in brackets), I don't see any bones being used, but they seem to be achieving the deformation effect. Maybe I missed something in those videos that you can notice? Thanks for your help!

My apologies. For some reason, I have been misinterpreting people's questions lately, and thinking they're misunderstanding me, when actually, I'm misunderstanding them. In the videos you posted, it appears that the artist is simply using sculpt brush influence and/or proportional editing tool influence to move the vertices of grease pencil strokes around. As for how one would get smooth interpolation from any keyframes set afterwards, I don't know. I can't seem to get it to work. So if you happen to find out something on this, please let us know here what you discovered.


text:
cut and rotate out parts of sphere evenly
I'm trying to replicate the following animation but as my knowledge is very limited I cannot figure out how to do it.
So, basically what I want to do is to cut a sphere into 8 different pieces, then rotate and spread out the parts evenly like in the image. Any help will be appreciated.

you can use the knife or knife project tool to cut it from the top view, parent all the parts to an empty, make the separation animation, then rotate the empty

OK, I manage to cut and parent the parts to an empty. But I cannot yet figure out how to make the separate animation/ separate the parts evenly.Can you please give me a hint.

you animate them before the empty animation, enable the Manipulate Center Point option (Pivot Point > Only Origins in 2.8)

see this answer: https://blender.stackexchange.com/questions/130554/how-to-make-a-centered-hexagon-door-consisting-of-6-triangles

Thanks, I'll check the instructions.

make sure the origin is on the geometry of each part, otherwise it won't separate correctly

Thanks a lot for the tips. Really appreciate your help.
Here's my result
https://media.giphy.com/media/dy9fOaevJUmi2KN8yG/giphy.gif

nice! you're welcome!


text:
How do I use array and curve modifiers, without bending?

I want the bricks to align to each other while keeping somewhat of their shape. Even when I add more edge loops they start z-fighting.

Here are the sequence of steps I followed for getting the arrayed objects to follow the curve without distortion in Blender 2.82a:

I began by adding a Bezier circle object to the scene. Then I added a polygon cube to the scene. Both remain at World Space 0,0,0 (and this may actually be significant).
In Edit Mode for the Cube, I scale it along the Y axis.
In Object Mode, with the cube still selected, I create an Array Modifier. I choose Constant Offset and enter a value for spacing between the cube instances which looks good (in my case, 0.22). I do not apply the Array Modifier.
Still in Object Mode, with the cube still selected, I create a Curve modifier. I point it to the Bezier Circle as a target. I enter Y for the Deformation axis, which is the depth axis in my scene. I do not apply the Curve modifier.

Below is my result, and as you can see, there is no distortion between the edges of cubes. I do not know how you are getting distortion. I tried changing the order of my modifiers as a test, and it did not produce your results.


text:
Baking Heightmap, Curved Instead of Flat?

I am trying to bake a heightmap using Map Range. The mesh is -30m to 230m and is shrunk to 0 to 1 values.
I open the heightmap and it is curved instead of flat.
I've tried the other settings of Map Range and linear, stepped linear, etc outputs a curved surface.
I want to achieve an inclined plane not a curved one.

How do you bake the heightmap? What format is it? Are the greyscales linear or some other interpolation or colorspace?

That's a beautiful visualization of the sRGB gamma curve.

Set View Transform in Color Management in Render properties to Raw and the rest to default or depending on the Blender version untick Save as Render or set Color Management settings to raw when using Save As....

For anyone reading that needs clarification. Go to Render Properties and in Color Management change to None.

There is no None for Display Device in the newer versions of Blender.


text:
Is it possible to select Keyframe in graph editor using python?
Right now I am trying to make a loop animation, and I need to copy 1st keyframe of active fcurve and paste it into fcurve's last+1 keyframe using python script.  And this is the python script I am using right now.
Scene_Name = bpy.context.scene.name
current = bpy.data.scenes[Scene_Name].frame_current
endframe = bpy.data.scenes[Scene_Name].frame_end+1

# I need to select active F-curve's 1st keyframe here

bpy.ops.graph.copy()
bpy.context.scene.frame_set(endframe)
bpy.ops.graph.paste(offset='START', merge='MIX', flipped=False)
bpy.context.scene.frame_set(current)

it works fine but I need to select 1st keyframe of active fcurve manually before using this script.
Image below shows orange keyframes, and it is active keyframes. I would like to select those keyframes using python to make my script work automatically. Is it possible?

The graph editor does not expose its idea of an active fcurve to Python.  Instead you have to select the fcurve from the object's animation data's action and then edit that fcurve by copying the first keyframe and creating a new one in the last position.

it seems hard to control fcurves using python

You need to find the fcurve by some other means.  Here is an example where I want the Y location of the only action of the active object:
object = bpy.context.active_object
yloc = object.animation_data.action.fcurves[1]

Then you need to insert the new keyframe into the fcurve's KeyFramePoints data structure.  Here's a function that will copy the first keyframe to a new frame number:
def dup_first_keyframe(fcurve, frame_number):
    keyframes = fcurve.keyframe_points
    keyframes.insert(frame_number, keyframes[0].co[1])

and here's how to invoke it, to copy the keyframe from the start to frame 48:
dup_first_keyframe(yloc, 48.0)

But it is not possible to get the graph editor's idea of 'active fcurve', because that's a property of the UI and not the animation data of the object.

it works fine. thank you. you said it's not possible to get graph editor's active fcurve using python. Right now I am editing fcurve's multiple channels.for example there is a bone which has keyframes on X,Y,Z locations. When I edit X location, I need to copy and paste keyframes of X location channel so I need to get what channel I am editing.  I need script like active_channel = activefcurve.activechannel. I can't do that kinda thing using python?


text:
Can I delete all duplicated drivers of armature?
I separated some bones from a armature which has lots of bone drivers, and when I separated some bones, it made a new armature with old armature's drivers. After editing I joined old armature to new armature again, and here is a problem. It also merges old armature's drivers with new armature's drivers, then now all of this newly created armature's drivers are doubled. My driver editor is really messy and this armature's animation is really cpu intensive right now.
I would like to delete all duplicated drivers, but is it possible? Do I need to use python script or add-on?

I wrote this script and it works. This script deletes all duplicated drivers of selected armature.
If you know something better or find something wrong in my script please tell me.
import bpy

driver_list = list()
ob = bpy.context.active_object

for dr in ob.animation_data.drivers:
    driver_id = "Object name = "+ob.name+" Path = "+dr.data_path+"["+str(dr.array_index)+"]"+" Driver expression = "+dr.driver.expression
    if driver_id not in driver_list:
        driver_list.append(driver_id)
    else:
        print("Deleting Unwanted Drivers",driver_id,)
        ob.driver_remove(dr.data_path,dr.array_index)


text:
Question about limit distance constraint. This constraint can't use a cube shape as a target object?
I have a question about limit distance constraint.
I've read this page
https://docs.blender.org/manual/en/latest/animation/constraints/transform/limit_distance.html
it says sphere again and again. I would like to use a cube as a target object of limit distance constraint,but limit distance area made by target object is not cube shape, but spherical area. Limit distance constraint can't use a cube shape as its own shape?
And If it is only spherical area,is there any way to see the actual target object area? I guess it uses object's bounds area so I need to change target object's Viewport display option ? I see its spherical bounds, If I activate "Display as Bounds - Bounds Sphere". Is this the actual limit distance area?

No, it's not using object bounds, it's using the origin point. And since the origin has no faces pointing in certain directions like a cube, it's always a spherical distance. And displaying the object's bounds will do exactly that, display its bounds. And the bounds of an object are the maximum dimensions of the mesh, not the influence range of any modifier.

I see. Thank you..

Make a cube, make it non-rendering, bone parent it to something.
Use a shrinkwrap constraint on the limited bone targeting the cube.  Mode depends on limit distance mode you want: inside, outside, or surface.

Depending on your specifics, there may be other ways to do this (like 6 floor constraints if you want to limit distance/inside, or Chris's solution if you want to limit distance from parent or parent of parent) but when we're talking about a cube, a shrinkwrap is performant and without any interpolation problems.

Nice. Thank you for your answer.


text:
I need to reset rest_length of Stretch To constraints using python but this doesn't work
I need to mute all Transformation,Copy Location,Copy Rotation,and Copy Scale constraints to get pure rest_length number of Stretch To constraint, but there are lots of constraints so I need to use this python script.
I am using this python script. It resets selected bones' transformation and mutes Transformation,Copy Location,Copy Rotation,and Copy Scale constraints, and saves processed bones' names and constraints' names.After that it resets all rest_length of Stretch To constraints and re-activate Transformation,Copy Location,Copy Rotation,and Copy Scale constraints again.
But this just mutes Transformation,Copy Location,Copy Rotation,and Copy Scale and enable them all again. Seems Stretch Constraints are untouched.
Do you know why?
import bpy

context = bpy.context
for b in context.selected_pose_bones_from_active_object:
    b.matrix_basis = Matrix()

names =  set()
for b in bpy.context.selected_pose_bones:
    for c in b.constraints:
        if c.type in ["TRANSFORM", "COPY_ROTATION", "COPY_LOCATION","COPY_SCALE"]:
            c.mute = True
            names.add(b.name)
            names.add(c.name)

for b in bpy.context.selected_pose_bones:
    for c in b.constraints:
            if c.type == "STRETCH_TO":
                c.rest_length = 0.0

for b in bpy.context.selected_pose_bones:
    if b.name in names:
        for c in b.constraints:
            if c.type in ["TRANSFORM", "COPY_ROTATION", "COPY_LOCATION","COPY_SCALE"]:
                if c.name in names:
                    c.mute = False

I updated script. this is much better. it just resets "Original Length" and make it have edit mode bone length. Select bones in pose mode and execute the script.
import bpy
import math

# Ensure the active object is an armature
armature = bpy.context.object
if armature.type == 'ARMATURE':
    # Get the currently selected bones
    selected_bones = bpy.context.selected_pose_bones

    if selected_bones:
        for pose_bone in selected_bones:
            bone_name = pose_bone.name

            # Switch to Edit mode to access the rest pose bone data
            bpy.ops.object.mode_set(mode='EDIT')
            edit_bone = armature.data.edit_bones[bone_name]

            # Calculate the length between the bone's head and tail
            length = (edit_bone.tail - edit_bone.head).length

            # Switch back to Pose mode to modify the constraint's rest_length
            bpy.ops.object.mode_set(mode='POSE')

            for constraint in pose_bone.constraints:
                if constraint.type == 'STRETCH_TO':
                    # Set rest_length to the length in the rest pose
                    constraint.rest_length = length
                    print(f"Bone '{bone_name}' rest length set to: {length}")
                    break

        # Return to Pose mode
        bpy.ops.object.mode_set(mode='POSE')
    else:
        print("No bones are selected.")
else:
    print("Active object is not an armature.")

This is an interesting way to do this, but I wonder how essential the muting function is. For my own uses I have a muscle deform rig that has a lot of stretch-tos and I'd like to have a button that pops up when the rig is in rest mode and I can just reset all of them at once.

Sometimes other constraints changes bone's position so muting them all is needed.


text:
Mirror expression
How can I rewrite an expression?
I have this expression written by Leander
min(1, max(0, Rest - CL) / max(0.001, FL-CL)) * 0.1

It drives a variable bone from 0 to 0.1  using to other bones as variables.

You can see my original post which was solved by Leander
Driving average values with limits in blender
I changed his code alittle by replacing the self.bone matrix. to a variable bone called "Rest" so that I can rotate the armature and hopefully have all the drivers follow along. However after parenting the bones to the big bone in edit mode  i rotate the bone and i get a result where once the bones rotation reaches 180 degrees the bones withthe drivers applied suddenly change position. this is very much undesired

So can anyone suggest a way to stop the drivers from moving once they pass the -/+ threshold. I have tried some absolute pythin expression namely
min(1, max(0, abs(Rest) - CL) / max(0.001, FL - CL)) * 0.1 <br>
 min(1, max(0, abs(Rest) - abs(CL)) / max(0.001, abs(FL) - abs(CL))) * 0.1

but to no avail. Does anyone have any ideas?


text:
How to Twist a Procedural Material?
I'm trying to figure out how to twist a procedural material applied to a mesh.
I have a hollow cylinder like a tube (the two end cap faces are deleted) with a noise texture applied to it.
My nodes are:

Texture Coordinate - Generated output to a Mapping Node, Vector input.
Mapping Node - Vector output to Noise Texture, Vector input.

On the mapping node, I can see that the Rotation ordinates will rotate the texture on the surface of the cylinder. The length of my cylinder runs down the Y axis, so as I rotate the texture on the Y axis it rotates around the barrel of the cylinder. So far so good, but the problem is that it equally rotates the texture around the cylinder barrel all along its entire length.
What I want to do is to fix the material's rotation on one end of the cylinder, but rotate it around other end so that it twists or spirals down the length of the cylinder like the rifling in a gun barrel.
Is there a way to tell Blender "on that end of the cylinder the material's rotation is 0, and on this end it is 360 degrees (or 720, or -180, or whatever)?
This seems as if it'd be a piece of cake, but I'm just not seeing it.

Are you using the texture node editor. If yes you can add a rotation node and plug in a gradient texture node. Otherwise if you're just using procedural textures within cycles I don't know of any answers.

While @DuateFarrajotaRamos's answer will seem to work for small angles of rotation, it only approximates rotation and will not achieve 360 degree rotation mentioned in the question. Instead, you can apply a rotation matrix to the actual vectors concerned.
A solution is mentioned as part of this answer https://blender.stackexchange.com/a/77638/29586 - where the X/Z coordinates are rotated based on the Y coordinate using the following nodes :

This works by splitting the Vector into separate X,Y,Z coordinates and applying a rotation using matrix multiplication as :
X = x.cos(angle) + z.sin(angle)
Z = -x.sin(angle) + z.cos(angle)

Varying the Twistiness input will vary the rotation. The Twistiness is measured in Radians rather than degrees so 2*pi radians is a full rotation (360 degrees) - just type '2*pi' into the value node and Blender will automatically calculate.
Note also the Subtract color mix node at the start. This is set to mid-grey (0.5,0.5,0.5) to convert the Generated coordinates ranging from 0.0 to 1.0 into the range -0.5 to 0.5 so that the origin - and centre of rotation - is in the centre of the mesh.
For clarity, here's the complete node setup :

Note that I've removed the 'green' element from the first Subtract MixRGB node. This is to leave the origin of the Y channel at the edge of the mesh so that one end is not affected by the twist (otherwise it twists from the middle). The Subtract and Divide nodes at the end (after the Noise texture) are there simply to increase the contrast of the Noise texture and isn't related to the twisting.
And here's the result :

Blend file attached

Ah yes good point,  Rotation matrix are something I've always wandered how to do, but my limited math knowledge did not allow. I'll use this for future  reference, upvoted, thanks.

Ok, this looks fascinating, and I can't wait to give this a shot, and now I want to build the abstract EM waves from the other post too. I can see that you're using the converter and math nodes to build the rotation equations. Where I'm hitting a brick wall is the node titled "Twistiness."
I don't find it anywhere. Is it a custom node, or a group of nodes that you saved out? The Attribute input can access something called "Pointiness," (also on the Geometry input) but I don't find your node anywhere. Any hints?

Sorry for the confusion and lack of explanation. It's an Input Value node which has been renamed to Twistiness via the properties panel - it is confusing when the heading changes. I'll upload a Blend file with it already set up so that you can play around with a working version.

@Jendulus_Blendulus Answer updated with a complete material - without renamed nodes. Hopefully it's clearer. Also included animated example of the twisting in action and Blend file.

Thanks hugely. This completely did the trick with maximum flexibility. Being able to just type in different multiples of pi into the Input Value (twistiness) node is so perfect! This absolutely nailed it. I can't thank you enough!

As mentioned by Nils you can do this by mixing two different texture coordinates.

There is no direct built-in way to "mix" texture coordinates in Cycles nodes, but since the three XYZ axis are essentially like the three RGB components, and cycles makes no intrinsic distinction between the two data formats, you can use a Color Mix node to combine different texture coordinates.
The advantage of this is you can also use a texture to mix them differently across an object surface.
So if you create a black and white gradient across your cylinder's Y axis you can use it to mix between rotated and non-rotated texture coordinates.
Just plug the original Generated texture coordinates to one of the Color sockets of a Color Mix node and the same Generated texture coordinates run through a Vector Mapping node to the second Color Socket.
Use the gradient texture to mix the two, then control rotation through the Vector Mapping node.

I believe this will only work for small angles. For the 360 degree rotation you'll need to apply a rotation directly to the coordinates rather than using the Mix node. The mix node will produce distortion - see the back inside face on your animated example.

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


text:
Precise Mechanical Rigging of two arms connected by a rod
https://youtu.be/86DtgBiUDvI
I have done this using the y-rotation of the Blue rod to drive its z-location. The Top rod is driven by the z-location of the Blue rod.

As you can see, the animation looks imprecise, and the calculation behind it is also not intuitive (for one, the reverse control using $asin(x)$ does not work). Sure I could tweak things to fit, but I'm instead looking for some method to precisely rig these bodies intuitively. So far I have known these methods for mechanical rigging: a) Constraints b) Drivers c) Armatures and d) Physics.
My questions:
a) Is there any way to actually rig (complexity does not matter)
by simply constraining the bodies with regards to each other without actually calculating any of the mechanics of motion that the setup will entail?
b) Are there other methods that I have not mentioned above?

After a lot of trial and error here's what I could come up with.
It is not perfect and will glitch out at extreme cases, but otherwise works for the most part.
It relies on a system of three empties and relations between them.

The $Start$ $Empty$ - Has a Location constraint to prevent it from going anywhere away from $-0.90$ to $0.90$ in the $X$ axis

The $End$ $Empty$ - Has a Location constraint to prevent it from going anywhere away from $-0.90$ to $0.90$ in the $X$ axis and $0.2$ to $1.8$ in $Z$ direction. Additionally it as a Limit Distance constraint set to On Surface preventing it go further away than $1.8$ from $Start$ $Empty$

Lastly $Tracking$ $Empty$ is parented to $Start$ $Empty$ and has a locked track to the $End$ $Empty$.

The $Upper$ $Arm$ also has a Copy Location on $Z$ axis only from $End$ $Empty$so it keeps position correctly automatically

Thanks. This was not exactly what I am trying to achieve, but it helped a lot. I think I'll be able to expand from here.

This solution is actually kind of a hybrid of the other two answers.
The main Spherical empty drives the rotating bar's x position by a range via a driver.

The base point of the rotating bar is at the bottom of the bar (as seen when it is vertical.)
The other empty is set opposite to the basepoint, and parented to this bar.
The top horizontal bar is set to copy the "Y" location of the parented empty.
The rotating bar has a constraint to match that of the main spherical empty.
Lastly the spherical empty just has a Z-Rotation constraint to limit the min/max to -174.5°/-5.5° respectively.
Please Note:
This solution is not accurate, as it does not obey the cosine/sine ratios. It is strictly linear based on angular rotation of the empty.

Easy enough fix:
The overall bar dimensions in my case are 2.0 units overall.
So the radius (1.0 in my case) is super easy for me in the driver.
just replace the driver formula listed with this:
cos(var)*RADIUS

FOUND IT

The basics of it:
The empties of the scissor hinge were left in the same location, less the center one as it was no longer needed.
The top Left one was parented to the one on the bottom right of the scissor assembly.
The top bar's y location follows the top left empty's y location with the copy location constraint.
The bottom right one then gets two contraints to follow the rig below as follows:
it uses the copy rotation and copy location (x) contraints targeted to the empty directly below it.
The rig at the bottom is just three empties the Parent being the one the forms the 90° degree corner point amongst them.

Actually, this is exactly the method I used to create my demo. I drove the z-location of the central rod (C) with the (length of C)*sin(y-rotation of C). I've mentioned this in the question.

I believe that there may be a constraint that could solve this and get rid of the driver in this solution. I need to experiment a little more though. I'll append the answer if I can find anything good.

This answer is (partially) a cheat!!

The relative movement is correct, but the bottom rod is moving and the above gif is done moving the camera.
Without the camera, here is the result:

How it is done:

The top empty is parented to 3 of the top vertices of the white rod
Same principle for the bottom empty with the bottom vertices of this rod

Each horizontal bar (blue and green), have a driver constraint: their Z position is assigned to the corresponding empty Z position

This is all for the rod/bar movements...
Now the camera which is faking the vertical stability: its own vertical (Z) position is constrained by the bottom empty:

I'm sorry, but this won't work for me. This mechanism is part of a bigger structure and I need mechanical fidelity. Anyway, the "3 vertices" idea was pretty helpful. Thanks.

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


text:
Dynamic Paint is slightly shifted
I'm using dynamic paint to simulate a marker on a paper using true-to-life dimensions. The brush is set to use proximity (distance 0.001) and I notice that the resultant paint is offset a couple vertices to the xy direction.
(1) Is this something that can be fixed? I have tried adjusting it to use mesh for paint, I have adjusted falloff, projection, the brush geometry (cone and sphere), and subdivided the canvas and nothing corrected it.
(2) If this is not something that can be fixed, how can I compensate with the shader? The vertex color node does not have any inputs that I could do a transform on.
Here's a demo of the issue:

Shifted paint:

Fixed Paint:

Plane dimensions: 0.1 by 0.1
For the paint to come out correctly, i had to translate the entire brush geometry by 0.001 in every axis before calculating the dynamic paint, then i reverted it after, i did the translations with geometry nodes.
Brush Nodes:

If your brush has a scale different from one, you will need to divide the translation by the scale:

If your brush has a rotation, you will need to rotate the translation by the inverse rotation of the brush:

In large scales, the offset would be practically imperceptible, but at smaller scales, like a canvas with centimeters, the offset starts to be very visible, some smaller brushes will not even paint the canvas, since the raytrace would start too far from them.
The problem cause, i tested it, but only a single time:
/* a simple hack to minimize chance of ray leaks at identical ray <-> edge locations */
add_v3_fl(ray_start, 0.001f);

This line of code in the file dynamic_paint.c seems to translate raytrace origins by the vector (0.001, 0.001, 0.001) when using a mesh type brush. When i removed it, the expected behaviour appeared.
I tested before and after removing the code line, but did it only one time since Visual Studio doesn't like to build things fast in my PC.
If someone could test it, the code line is in the following method:
/*
* Paint a brush object mesh to the surface
*/
static void dynamic_paint_paint_mesh_cell_point_cb_ex(void *__restrict userdata, const int id, const TaskParallelTLS *__restrict UNUSED(tls))

Here's the file i did for this:

Edit:
I tested again with and without the code line:

I found that using "Image Sequence" format for the canvas instead of vertex was a far simpler solution that solved this problem (or at least made it easier to work on).
I'll leave this question unanswered as there may be a better solution that someone may find.

I used image sequence for dynamic paint and that shift is still there. Really don't know what's going on.


text:
Why is Blender not procedural?
best example, changing the vertices after you add a circle, same with cylinder, sphere segments and so on.
I think it is in the most 3D software like Maya, C4D and Houdini of course.
Has it something to do with the implementation/coding?
Best, Joseph

This is a very general question for this site, it may not be considered appropriate here.. but fear not! It's a good question, that hasn't passed  the developers by .. This might be a good starting point  for your exploration of Everything Nodes.. central to the strategic plan for Blender.

Blender can actually be very procedural. I use blender sort of as a free cad program, it isn't designed for it but it works well enough that i have been doing it professionally for the last 3 years. When I started I used a vertex-based workflow, it was tough because it was slow and destructive, it wasn't easy to go back and make changes. However, the real procedural stuff comes when you use modifier stacks. Fo me they have been huge time savers. they are non-destructive as long as you don't hit apply, they allow for tons of reversible and changeable procedural modeling or generation.


text:
Blender freeze after hair particle system
really strange but im not able to duplicate the particle system from the left wing to the right wing without crashing blender.
I used ctrl + m, x to mirror the wing, maybe some bug here? Also used https://blenderartists.org/t/boundary-aligned-remesh/1149739 to remesh the wings.
i was not able to reproduce the error.
Best, Joseph
https://blend-exchange.giantcowfilms.com/b/m4nGKg4D

copied all objects into a new blender file, now everything works fine again, where is the bug?

If the color in the Viewport Shading is set to Random it will crash, if it set to Material everything works fine.


text:
How can I keep space between geometry node instances made on curve whose control points are moved by empties?
I need to do "Array" and "Curve" modifier type thing by geometry node. Curve needs to be moved by empties. And the result is the 1st picture and problem is when I move empties instance objects can't keep its space between them and they have undesirable space. I would like to do something like 2nd picture. When I move empties, object moves but they keep initial space. Just like geometry node instance only moves on curve.
How can I achieve this? I added blend file so check it please.

I assume you are using a 'curve to points' node to generate the points for the instances? If you have it set to 'Count' it will generate as many points as you tell it and divide them equally along the curve. If you set it to 'Length' it will separate the point a specified length and generate as many point as needed to fill the curve. If you are deforming the curve you probably need the second one.

Side Note: The provided file is crashing Blender 3.6.8.

Please add new information (like gif, pictures, text) by editing your question, not by posting answers. This a Q&A (Question at top, Answers after), not a track of discussion.

(Using Blender 3.6.8)
The approach implemented in the following GN graph is:

To trim the curve to make its length proportional to the user-defined spacing (dark red part).
To spawn on points instances picked in a collection, as many times as required (dark green part).
To spawn on the last point a specific instance (dark blue part).

Setup
1. A BezierCurve is added in Object Mode. In Edit Mode, its control points are "hooked" to three empties, used as manipulating handles. The middle one is animated up and down.
2. In Object Mode, one Cube is added at the world origin, then duplicated. This copy is rotated by 45 degrees around its Z axis, remaining centred at the world origin. Both cubes are gathered in a Collection. These are picked in alphabetical order. So their name is edited to control which one is instanced on even indices (the first one), and which one is instanced on odd indices (the second one).
3. In Object Mode, one Sphere is added at the world origin. (NB: Transformations must be "applied" to these objects (cubes and sphere) to spawn).
4. In Object Mode, one Single Vert is added at the world origin. The GeometryNodes modifier is attached to this object. Its Input are:
4.1. Curve: the curve on which to spawn other objects.
4.2. Last: the object to spawn at the last index.
4.3. Collection: the collection containing the objects duplicated along the curve.
4.4. Count: the number of objects to spawn, excluding the last one (labelled $n$).
4.5. Length: the distance between two successive spawned objects (labelled $\lambda$).
Trimming the curve
1. The Geometry of the input curve is recovered through an Object Info node.
2. Let $L$ be its Length, evaluated with a Curve Length node. It is assumed that $L \ge \lambda$. Let $N$ be an integer such that $N+1$ is the maximum number of points along the curve separated exactly by the length $\lambda$. Let $l$ be a length such that $l \lt \lambda$. $N$ and $l$ are defined by the relation $L = N \lambda + l$.
3. Consequently $N$ is computed as the truncated part of $\frac{L}{\lambda}$.
4. The input curve length is reduced to $N \lambda$ using a Trim Curve node.
5. Eventually, $N+1$ points are interpolated along the trimmed curve with a Curve to Points node set in Count mode. It is returning a Rotation vector per point, which aligns the Z axis of an object with the local tangent to the curve.
6. For subsequent operations, the number of duplicated objects is limited to the Minimum between the user-defined value $n$ and the computed value $N$ to not exceed the length $N\lambda$.
Spawning duplicated objects from collection
1. Duplicated objects are spawned by an Instance on Points node.
2. The Selection of the points sampled along the curve to use is based on a Less Than node comparing these points Index with $n$ (or $N$ if $n \gt N$). As Index value starts at 0, it yields that exactly $n$ points with an Index value in the range $[0,n-1]$ are selected.
3. Individual objects to spawn are picked from a user-defined collection. This behaviour is controlled by the Pick Instance check-box and by the Instance Index socket. As it is left unconnected, the point Index is used to choose which object to spawn. Because there are only two objects in the collection, the first one is used for even indices (starting at 0) while the second one is used for odd indices (starting at 1).
4. Instances are recovered from the collection using a Collection Info node. The Separate Children socket is controlling that only one object at a time is picked, not the whole collection.
5. The Rotation vector output by the Curve to Points node is directly connected to the Rotation input socket to align the Z axis of the spawned object with the local tangent to the curve.
Spawning the last object
1. The last object is spawned by an Instance on Points node, its Geometry being recovered through an Object Info node.
2. The Selection of the point along the curve to use is
such that its Index is Equal to $n$ (or $N$ if $n \gt N$). As Index value starts at 0, it means that it is the $(n+1)^\mathrm{th}$ spawned object.
3. No Rotation is applied because it is a sphere.
Resources

Blender file:
About curve tangent, see: Align Instances to Curve with Geometry Nodes

it works nicely but when I move end point of the curve, mesh moves strangely because of real time curve action? Please see my new gif image which explains what I mean. I need to animate curves using armature bones so can I avoid this movement?

I uploaded new gif image on my new answer post. please see it.

it works perfectly. I need time to understand what you did. I will ask you later, is it ok? It's just hard to understand geometry node.

I check your node. I understand blue and green nodes but I can't understand brown nodes. Why Dive Truncate Multiply nodes are needed?  What Trim Curve and Curve to Points nodes did?

Thank you. I will read them all.

I tried armature solution and added another curve and Spline IK to move geometry node curve points and keep their distance.
https://i.imgur.com/6IH8WwL.gif
It works sort of but if you know anything better please tell me.
Blend file is here.

new gif image for StefLAncien
sphere instance moves back and forth when last curve point comes closer to 2nd curve point.
https://i.imgur.com/vaGMpLW.gif


text:
How to change selected nodes width in node editor using python?
I am trying to select one node in node editor, then select same type of nodes and change width of all selected nodes using python, this script select same type of nodes but it cannot change its height and width. What should I do?
for area in bpy.context.screen.areas:
    if area.type == 'NODE_EDITOR':
        an = bpy.context.active_node
        type = an.bl_static_type

        amn = bpy.context.active_object.active_material.name
        nodes = bpy.data.materials[amn].node_tree.nodes

        for n in nodes:
            if n.type == type:
                n.select = True
                n.height == 159
                n.width == 1000

hello ! please be advised overriding builtin keyword type is not recommended and can lead to funky bugs. Cheers

thank you but I can't understand what "overriding builtin keyword type " means. I want to avoid glitches.

see https://stackoverflow.com/questions/10568087/is-it-safe-to-use-the-python-word-type-in-my-code

I see. I will avoid "type" as a variable. thank you.

Considering you can have only one active object and one active material, you can without going through areas:
# find active object
obj = bpy.context.object
# find active material
mat = obj.active_material

# find active node
nodes = mat.node_tree.nodes
active_node = nodes.active

# then loop over the nodes, checking for their types
for node in nodes:
    if node.type == active_node.type:
        # and change select state and width
        node.select = True
        node.width = 600
        # but you cannot change the height
        #node.height = 300

Of course, you may add some checks in this code in case no active element exists at a step or another.

it works! thank you. only active node's width and height can be changed then..

you can change width of any node... what do you mean?

I mean, yours goes through active_material path but mine isn't. That's why I can't change node's width? amn = bpy.context.active_object.active_material.name  nodes = bpy.data.materials[amn].node_tree.nodes If I touch nodes data from this path,node data can not be edited?

never mind. it should be n.width = 1000,not n.width == 1000. thanx lol.

I think an = bpy.context.active_node may throw an exception in your code.

ok. I will check.


text:
can cos() function have more variety in terms of animation movement?
I always use cos() driver expression to make simple loop animation.
1st animation curve is baked result of cos(frame/5) of driver expression.

And I think it's too predictable and it needs to be 2nd curve, which has randomness on X axis(timing)and Y axis(key frame value).  Is it possible to make 2nd animation curve using cos() function? Y axis randomness is what I need right now but X axis randomness can be useful too. I would like to control both randomness separately.

Do you want to use these waves to animate object positions? Geometry nodes can do this, and so can scripts.

I use it to move bones. It makes character's simple movement like idle animation and breathing.  Is it possible to let cos() have more variety?

Yes, it's available in the driver, I'll provide info later.

tbh this is not a Blender question, but a mathematical question

Goal 1: Move the min/max point up/down of a cos function

Assume you want to move first minimum point -1 on t = pi, then the function of t in (0, pi) be $1.5*cos x-0.5$

Simair, the second function: $2.2*cos x+0.2$

t = frame   function                y
0 ~ pi      1.5 * cos(x) - 0.5      1 ~ -2
pi ~ 2pi    2.2 * cos(x) + 0.2      -2 ~ 2.4
2pi ~ 3pi   1.8 * cos(x) + 0.6      2.4 ~ -1.2
3pi ~ 4pi   1.1 * cos(x) - 0.1      -1.2 ~ 1
... loop

thus,
expression = 1.5 * cos(frame) - 0.5  if frame % (2*tau) < pi else (2.2 * cos(frame) + 0.2  if frame % (2*tau) < tau else (1.8 * cos(frame) + 0.6   if frame % (2*tau) < tau + pi else 1.1 * cos(frame) - 0.1))

Result:

With speed Factor:
# 1/20 speed
# speedFac = 0.05

expression = 1.5 * cos((frame*speedFac)) - 0.5  if (frame*speedFac) % (2*tau) < pi else (2.2 * cos((frame*speedFac)) + 0.2  if (frame*speedFac) % (2*tau) < tau else (1.8 * cos((frame*speedFac)) + 0.6   if (frame*speedFac) % (2*tau) < tau + pi else 1.1 * cos((frame*speedFac)) - 0.1))

Goal 2: Move the min/max point left/right of a cos function

Simair method,
t = frame           function                        y
0 ~ 2pi/3           cos(1.5 * x)                    1 ~ -1
2pi/3 ~ 44pi/21     cos(0.7 * (x + 16 * pi / 21))   -1 ~ 1
44pi/21 ~ 281pi/84  cos(0.8 * (x + 17 * pi / 42))   1 ~ -1
281pi/84 ~ 117pi/28 cos(1.2 * (x + 23 * pi / 28))  -1 ~ 1
... loop

expression = cos(1.5 * frame%(117*pi/28))  if frame%(117*pi/28) < 2*pi/3 else (cos(0.7 * (frame%(117*pi/28) + 16 * pi / 21))  if frame%(117*pi/28) < 44*pi/21  else (cos(0.8 * (frame%(117*pi/28) + 17 * pi / 42))  if frame%(117*pi/28) < 281*pi/84 else cos(1.2 * (frame%(117*pi/28) + 23 * pi / 28))))

With speed factor:
expression = cos(1.5 * (frame*speedFac)%(117*pi/28))  if (frame*speedFac)%(117*pi/28) < 2*pi/3 else (cos(0.7 * ((frame*speedFac)%(117*pi/28) + 16 * pi / 21))  if (frame*speedFac)%(117*pi/28) < 44*pi/21  else (cos(0.8 * ((frame*speedFac)%(117*pi/28) + 17 * pi / 42))  if (frame*speedFac)%(117*pi/28) < 281*pi/84 else cos(1.2 * ((frame*speedFac)%(117*pi/28) + 23 * pi / 28))))

In theory, as the function gets more complex, it becomes more random
Other method
$\cos\left(x\right)+2\cos\left(2x+2\right)-3\cos\left(3x\right)$

On the other hand, animating with keyframes is also a good option, it has some function like noise modifier.

thank you I am gonna break down your expression so it will take some time. one more question I always use  custom properties to change animation speed and its intensity like
animation_speed = 0.5
animation_Intensity = 0.1
cos(frame/animation_speed)*(animation_intensity)
I need to use those variables, but how can I combine yours with those variables?

Replace frame with (frame*speedFac). View the answer.

Intensity: multiply k by the function, k*f(x) if a > b else k*g(x)

It seems working fine now but I may ask you something later. thank you.


text:
how to animate flower petals using bones?
I would like to animate petals or weeds like this images. If arrow comes closer, petals open, or weeds move away from the arrow.
What is the best way? I need to use those bones, so shape keys can be used.
I tried to make it using damped track constraint, but it's really hard to control, so I am trying other way.

you can use drivers for this. e.g. you could add a beziercurve which drives a follow path of an empty which is IK object of each weed end bone. all you have to do then is add a driver to offset of the follow path with a simple math formula depending on the distance. and add a driver which rotates the armature with beziercurves depending on the arrow.

would be nice if you would have shown what you tried so far...

possible result: [1]: https://i.sstatic.net/MHXVi.gif

it looks nice. how did you make it?  you did somehting like this video? https://youtu.be/imbIsNAvUpM what I want to do is like when weeds contact something like a ball I want them to fall like my image 2.

as i wrote in the comments, that's how i did it.

You can use drivers as recommended by Chris, or you can use the Transformation constraint:
First create the armature with the controller and the chain of bones, give a Copy Rotation to bone 2 and 3 with bone 1 as Target:

Select the controller bone, open the N panel, put your mouse over the Transform > Y location, right click and choose Copy as New Driver:

Then select the first bone and in the N panel right click on the Z rotation value and choose Paste Driver, the value will turn purple:

You can change the driver parameters: Open the Drivers editor, open the N panel > Modifiers, create a Generator, and play with the X^1 value in order to increase or invert the influence of the controller:

You cand also use the Transformation constraint:
Give a Transformation constraint to bone 1, in Local Space/Local Space, Map From > Location and set the Y location to 0 and 1 (or whatever value in local space), Map To > Rotation and set the Z Source Axis to Y (as it is the Y location of the controller that will determine the Z rotation) and choose the Max Angle of rotation:

Here is what it gives when you move the controller:

Now just duplicate the chain of bones in Edit mode and rotate them with CtrlR.

I tired both. transformation constraint is the easiest way. It can be tweaked easily. I always forget how my driver expression works, but transformation constraint tells me what I did, I will use it. thank you.

Other answers here are fine, but my personal way to do this would be via locked track and copy rotation constraints.
First, we'll need to set the axes of our bones so that they're pointing at the center point.  We can do that by snapping cursor to our control bone and then recalculating roll to cursor.  Now all of our bones' +Z axes are pointing at the control:

We'll give each petal root a locked track constraint, lock X, track +Z, targeting our control.  We can do this on one bone, and then use copy constraints to selected to apply this to all roots:

Now we can give our child petal bones copy rotation constraints, local->local, targeting their roots:

Now, when we move our control bone, our roots will rotate along their X axes to track it, and their children will bend in and out to follow:

I did same kind of thing using damped track, but it makes bone's z axis look controller so when controller bone gets closer to petals, petals close. and when controller goes far from petals, petals open. it's not intuitive. when something like a bee comes closer to petals I want them to open. because petals controller copies this bee position.

so I made aim bone and controller bone. this aim bone is the target of track constraint, and when controller bone goes closer to petals, it makes aim bone moves away from petals to open them, but this setting is hard to tweak so I am trying other ways now. anyway I don't know that bone roll can be edited using 3D cursor. I am gonna use it.


text:
how to get bone location of edit mode?
I need to get bone's location in edit mode. Is it possible?
I found this, but it only works when I choose armature. I need to get bone's location without activating any armatures.
bpy.context.object.data.bones["BoneName"].head_local

Find the bone in the armature in bpy.data rather than in bpy.context.  The position of the head and the tail, relative to the parent are given as head and tail.  The positions relative to the armature are given by head_local and tail_local:
import bpy

armature = bpy.data.armatures['Armature']
bone = armature.bones['Bone']
head = bone.head
tail = bone.tail
head_local = bone.head_local
tail_local = bone.tail_local

Substitute the name of the armature you want for 'Armature' in the first line and the name of the bone for 'Bone' in the second line.
If you want world coordinates you have to transform the bone's local coordinates based on the position of the armature in world space.

it works fine. Thank you!