text:
Filling holes in a mesh
I'm currently designing a space window, shown in this picture

Currently I got this far:

So I have  problem with filling the smaller Windows,
I want to fill them em with these windows just like in the picture, but I cant really do it. How should I do this?

If you don't need continuous connecting topology, nor a single non intersecting object, just create a separate circle mesh object and let it intersect the frame inside

I didnt quite understand that.

Just create a new separate object shaped like a circle

In most cases it's better to think ahead before you model something. More difficult to do with less experience. I would approach it this way (I'm sure there is more than one way to model this).

Add a circle with 34 vertices
In Edit Mode, extrude it four times by pressing E and S (Scale)
Then extrude one more time but instead of scaling, Left Click (LMB) and then press ALT+M > Collapse.

Then select the following faces and Extrude up:

It's hard to tell from the reference image but if the window has a conical shape:

Select the following interior Vertices > Enable Proportional Editing > choose a Falloff type (I choose Linear)
Grab them and select an axis to move them on (I used G+Z)
Control the number of vertices effected with the mouse wheel

Thanks for your answer Dontwalk! Is there any way i could make these limiters between the smaller windows an perfect linear objec just like in the picture?

@user5339049 - You can move the Edge Loops by pressing CTRL + "E" > Edge Slide. I would also delete half of the vertices and use the Mirror Modifier with "Clipping" selected.

you make it seem so easy :D  Do you know any good starter tutorial?

There are a lot of tutorials out there. This site has some quality ones https://www.blenderguru.com/ There is also YouTube. Happy Blendering!

These are very good, basic and short tutorials https://vimeo.com/nhirsig/videos

I got another feeling about what your question: to me, it seems you wish to have a solid block of "glass" filling exactly those holes.
You can have them "easily" without reconstructing your mesh from scratch.
First, You need to "get the hole" from your current mesh.
In editmode, you need to select one of the interior "face rings"

you can do it manually, here I used a keyboard combination (SHIFTALT) while right clicking on that face

then you need to duplicate this part of the mesh (ignore the tool that shows CTRL pressed, that was the screen capture...)

and then separate it (as another separate object) (again, ignore the tool that shows CTRL pressed, that was the screen capture...)

that's it: now the new object is selected, the wheel is no more.

now in edit mode, you need to add a bottom and top face to this face ring

starting from the bottom one, again, you can select the edge ring manually or use a key combination (ALT) while right clicking on that edge

now you simply create a face filling  that bottom edge ring

getting this

then you do the same for the top one

getting this

now getting back to object mode, and hiding the "window frame" you see the new object:

Note: it could be better to recalculate normals (in edit mode select all and press CTRLN).
Now you just need to assign a glass material to it. You can copy it for each other hole (maybe join all copies as a single object) and you should be done!
Note: a comment above telling you can do this as an "intersection" is quite right, but that needs a boolean modifier. In this case it could be faster, but it needs some experience, and you may prefer the steps above.
In any case here is what you need: "another "disc" (here painted blue) crafted to be used in the boolean difference (not intersection) to let the window frame to "cut" six windows from the blue disc.
Here is the disc

Now we put it "into" the window frame

next we add a boolean modifier to the blue disc, ad "difference" and as a target, the window frame object

That's it. Now, if you hide the window frame object, you see the object resulting from the boolean.

Applying the boolean modifier (use the "apply" button) will make this a real mesh, and not a boolean difference anymore.

You could also add a window without remaking the whole mesh. This method isn't optimal, but it's simple, if you want to use it.

Add a circle
Scale it to the appropriate size
Place it in the window holes.

You're done! :)
Notes:

You can make the window a part of the same mesh by going into edit mode before adding the circle.
If you want to add curve to the window, make a small circle (selecting triangle fan might be best), and extrude, then scale, to make a "loop cut" in the circle. Now you have geometry to curve.

Example:


text:
Round the coordinates of a model that outputs to a text file?
Alright I have this:
import bpy
import decimal

blenderCipher=open('C:\\Users\\Nathan\\Desktop\\t.txt','w')

selected_objects = sorted(bpy.context.selected_objects, key=lambda obj:
obj.name) #Sort objects

for obj in selected_objects:

    xloc= obj.location.x #X coordinates of object

    round(xloc,2) #Round X coordinate to 2

    blenderCipher.write(str(xloc)) #write coordinates to text
blenderCipher.close

Although it still doesn't output rounded.

Round just returns a rounded version of your variable, it doesn't change the variable. Your code should read something like:
xloc = round(obj.location.x, 2)

source: Stack Exchange

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

sort: votes


text:
Enable Alpha & Specular Color for textures through python
how would I go about using the script below to enable specular color and Alpha to all textures in a scene? I've tried various bpy.data.THING none have worked. Below is just the last thing I've tried before asking this.
for mat in bpy.data.MaterialTextureSlots:

    mat.use_map_color_spec = True
    mat.use_map_alpha = True

To set MaterialTextureSlot.use_map_alpha on all texture slots on all materials.
    import bpy
for mat in bpy.data.materials:
    for ts in mat.texture_slots:
        if ts is not None:
            ts.use_map_alpha = True
            ts.use_map_color_spec = True

Thanks, but this is only working on one material's textures and then errors out, any ideas?
also I had the spec color backwards it should be use_map_color_spec

whoops, forget to check for empty slot.

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


text:
Delete only outer vertices from faces in a faces-and-edges-selection selection
this is a one shell mesh that is not water-tight, in edit mode.

The selection was performed as it follows: Select All; Select Boundary Loop; Select More (3 times); Select Less (3 times).
The objetive is to delete the vertices inside the red loop so that the border of the mesh is smoother. Any idea how to do it?

Welcome to bse.  Watertight? Consider looking at the bmesh module   For mesh above I would search for boundary vertices that are only used in one triangle face and remove them..

Deleting faces works just fine
Script here:
import bpy

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

bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.region_to_loop()
bpy.ops.mesh.select_more()
bpy.ops.mesh.select_more()
bpy.ops.mesh.select_more()
bpy.ops.mesh.select_less()
bpy.ops.mesh.select_less()
bpy.ops.mesh.select_less()
bpy.ops.mesh.delete(type='FACE')

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

Does deleting only the faces leave unwanted edges and verts?

everything conected to the unwanted verts is removed

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


text:
select by !=1 scale
I need a script to check have my mesh XYZ Scales with !=1. Here my Sample:
import bpy
for obj in bpy.context.selected_objects:

    if obj.scale[0] !=1 in obj.scale:
        print("found x")
        obj.select = True

    elif obj.scale[1] !=1 in obj.scale:
        print("found y")
        obj.select = True

    elif obj.scale[2] !=1 in obj.scale:
        print("found z")
        obj.select = True

    else:
        print("no failed scales found")
        obj.select = False

The script does not work properly. What am I doing wrong?

What do you mean "script does not work properly" ? It is working for me

for example when bpy.ops.transform.resize a object or is it a instance from other

I see no bpy.ops.transform.resize in your script anywhere

i have no idea to use resize in this script. I trying other example, but he deselect my objects:
import bpy
scal = bpy.context.object.scale
vect1 = (1.0, 1.0, 1.0)
for obj in bpy.context.selected_objects:
    if scal != vect1 in obj.scale:
        print(scal)
        obj.select = True

    else:
        print("blubb")
        obj.select = False

Your if statements are testing if a boolean value matches any of the three float values in the scale property. Comparing a boolean value to a numeric value leads to False matching zero values and True matching non-zero values.
You only need the first part of your test -
if obj.scale[0] != 1:

You can also combine the three tests as
if obj.scale != Vector((1.0,1.0,1.0)):
    print('This is scaled')

As you want to deselect the objects that aren't scaled you can cut your script down to
import bpy
from mathutils import Vector

for obj in bpy.context.selected_objects:
    if obj.scale == Vector((1.0,1.0,1.0)):
        obj.select = False

Note that you are looping through selected objects so obj.select is already set to True you only need to deselect the objects you don't want.

Following your comment (above the question), you can use Vector from mathutils library.
Vector class allows to use comparisons, to shorten the code to:
import bpy
from mathutils import Vector

unity = Vector( (1, 1, 1 ) )

#From the current selection, keeps selected objecst which scale is not unity
for obj in bpy.context.selected_objects: obj.select = unity != obj.scale

In some cases you may have precision problem (float value are sometimes approximation). To avoid that, choose an 'epsilon' limit above which scale is considered to be 1.
epsilon = 1e-8
for obj in bpy.context.selected_objects:
    obj.select = (unity - obj.scale).length_squared > epsilon

Maybe an option for using obj.matrix_world.to_scale() to give the "visual" scale, for a case where an object is being scaled with say a copy transform constraint.

If you want to select objects with -1 scale too, then selection should be changed to obj.select = (unity - obj.scale).length_squared > epsilon + obj.matrix_world.is_negative

I think this is what you are aiming for:
import bpy
selected = bpy.context.selected_objects
i = 0
while i < len(selected):

    if selected[i].scale[0] != 1:
        print(selected[i].name + ' found x')
        selected[i].select = True
        i = len(selected)

    elif selected[i].scale[1] != 1:
        print(selected[i].name + ' found y')
        selected[i].select = True
        i = len(selected)

    elif selected[i].scale[2] != 1:
        print(selected[i].name + ' found z')
        selected[i].select = True
        i = len(selected)

    else:
        print('no failed scales for ' + selected[i].name)
        bpy.ops.object.select_all(action='DESELECT')
    i += 1

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


text:
Code reverting to original mesh
Is there any way to use code to revert back to an original mesh? I am currently manipulating and scaling measurements of a mesh through various iterations (representing different individual animals). The dataset is very large so I created loops so only one function is called to run through all of my data. However, after each individual iteration the mesh needs to be reset to the original before the next measurements are manipulated. Is there any way to do this.
I've pasted my code below (I am only using 8 whales in this sample set to see if the code works before entering my large dataset). I expect the "undo" statement would fit in beneath the print statement in line 32. Thank you in advance!
import bpy
import bmesh
import numpy as np

obj = bpy.context.active_object
totallength = [1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9] #scaling factors for the length of each whale
whale = [0,1,2,3,4,5,6,7] #creates a placeholder for each individual whale for the code below
vgrp = ['Reye','Reyepecmid', 'Rpecant', 'Rpecpost', 'Rdslfinant', 'Rdslfnmid', 'Rdslfnpost', 'Rmidkeel', 'Rkeel', 'Ranus', 'Rmidkeelanus', 'Rpostanus', 'Rend'] #names of vertex groups being manipulated
sfac = np.arange(1,11.4,.1) #list of all scaling factors for vertex group and whale (the first 13 numbers correspond to the 13 vertex groups of the first whale)
whalesDims = np.zeros((8,2)) #a temporary array of all the whale surface areas and volumes

def scale(vgrp,sfac): #scale vertex group of name vgrp based on scaling factor of name sfac
    bpy.ops.object.mode_set(mode='EDIT') #set program in edit mode
    bpy.ops.mesh.select_all(action='DESELECT') #deselect any previously selected vertex groups
    bpy.ops.object.vertex_group_set_active(group=vgrp) #set vertex group active based on name in vgrp
    bpy.ops.object.vertex_group_select() #select active vertex group
    bpy.ops.transform.resize(value=(sfac,sfac,sfac)) #resize vertex group by sfac
    bpy.ops.object.mode_set(mode='OBJECT') #set program in object mode

def scale_whale(a,whale,vgrp,sfac):
    bpy.ops.object.mode_set(mode='OBJECT') #set program in object mode
    for w in whale:
        bpy.ops.transform.resize(value=(1,totallength[w],1)) #resizes the length of the whale (only the y axis) based on an index in total length corresponding to the index in whale
        for v in vgrp:
            scale(v,sfac[vgrp.index(v)])
            if sfac[vgrp.index(v)] == 12:
                sfac = np.delete(sfac,[0,1,2,3,4,5,6,7,8,9,10,11,12]) #delete first 13 numbers in sfac so next iteration will move on to the next whale
        bm=bmesh.new() #needed to calculate volume and area
        bm.from_object(bpy.context.object,bpy.context.scene) #needed to calculate volume and area
        volume = bm.calc_volume() #volume of whale
        area = sum(f.calc_area() for f in bm.faces) #surface area of whale
        print ('whale',w,'surface area = ',area, 'volume = ',volume) #print surface area and volume with each whale
    whalesDims[w, :] = (area,volume) #add the area and volume to an array
    print(whalesDims) #print out the list of whale areas and volumes
    return(whalesDims) #return the list

Could get very slow with large sample size  Rather than undo could copy original mesh copy = obj.data.copy() and swap it in and discard after, for each iteration.  Or I think you could do this all in bmesh and just about avoid bpy.ops altogether.  Can you provide a sample whale?

@batFINGER I think that could work! I'd be happy to provide a sample whale, but how would I upload the file? I'm very new to Blender and this website so I'm not sure how I could most effectively load the mesh.

@batFINGER I apologize for the radio silence. Unfortunately I cannot upload my .blend file, for some reason the above mentioned site won't allow it. Is there another way I can send you my model as an .stl or something? I'm not sure if messaging is permitted on this site but if there is a way to private message it to you here let me know.

it is only 669 KB, I even tried to compress it to 104 KB and that would not upload. Again, I'm new to blender so perhaps it is a simple fix, but I'm not quite sure what the issue would be with uploading a simple file. I apologize for the confusion!

That website worked! Although I am not sure where it is posted here is the link. http://pasteall.org/blend/index.php?id=48432 and here is the url for the code I posted http://pasteall.org/695336. Let me know if you can access it via these links.


text:
Distance fading for whole object
i have created a dithered and stepped distance fading effect similar to lod transitions in video games.
the parameter is controlled by the camera's texture coordinates. (basically a gradient attached to camera)
this unfortunately results in vertices closer to the camera fading in first. see image:

is there any way to keep this "distance to camera" value consistent for the entire object?
like calculate the distance of the object's origin from the camera?
or sample the current texture coordinate system form one vertex for the entire object?
one solution would be to use drivers. see image:

the issue with this is that drivers don't change for object instances, like geometry nodes scattering.
any help or ideas would be greatly appreciated
SOLUTION
the second answer in the linked duplicate question, camera x, y and z position are added with a driver since there is only one camera.

it unfortunately doesn't, both answers affect the vertices of the object individually and not object as a whole.


text:
Physically accurate water shader
I'm a bit tired of faking it and I'd like to craft a physically accurate water shader in cycles that works in most situations with minimal tweaking.
I haven't found a solution yet and i'd appreciate help.
Some properties the water shader has to have:
Glass- like appearance in small quantities

Volume and green tint in low depth

Blue colour underwater, darker the lower you go, reflective surface at top,
Ability for volumetric rays, even with sun

Snell's window

What i know is impossible with cycles: caustics
I have figured out some of these but can't make them work together.
Render times are not an issue, i just want to create an all purpose water shader, i don't intend to use it all the time.

the green tint is usually made by the sea floor or the algae, it's not a specific property of the water

The volumetrics are mostly an effect of tiny particles floating in unclear water and are only a minor property of the water.

@Tareyes The green tint is most definitely a water thing. Water absorbs the red wavelengths the most. Red things look greenish then blueish the deeper you go. Colors get desaturated also.

A single shader with all absorption effects will be unnecessarily heavy and lead to noisy scenes in situation where volumetrics will have negligible visual presence, unless you use additional tricks to filter by ray length that add extra complexity to the material

Most (all?) of those effects can be easily replicated using the standard Principled Shader and Principled Volume shader, with the surface shader providing the IOR and surface interactions (eg, reflectivity, refraction, etc.) and the volume providing any scattering and absorption (but at a suitably low density).
At small scales the volumetric effects are negligible, making the water appear almost clear, the skewed absoption colours (set it with higher Blue, medium Green and low Red) give the different colors at different depths, the scatter can give volumetric rays and the IOR (again) will give 'Snell's window' effects when viewed from within.
This just needs something like the following (note the low Roughness, high Transmission, low(ish) volume Density, blueish volume absorption). I've also added Displacement for adding distortion to the surface.

You might want to tweak the settings slightly to get realistic behaviour with a specific scale - you should always ensure you model at 'real world' scales to ensure it's more physically accurate. In particular, the absorption and scattering (so the volumetric density) will be sensitive to scale.

Thanks. One issue with this is that the volumetric rays will be uniform and lack detail. The displacement, which would drive the detail in the volumetrics in the real world, does not affect the rays, making the volumetrics look like fog glow. Is there any way to accurately add that detail?

@Walter I think what you are referring to is effectively the caustics, projected through the volume - so it would be extremely computationally intensive (and you did kind of exclude caustics). To implement that effect would be back to faking again, which you wanted to avoid. However, one option to achieve this would be to fake the 'rays' at the light source, rather than relying on the caustics from the distorted surface - to achieve that you would need to vary the emission strength based on some noise that you could then vary to introduce movement of the rays, faking the effect.

Here is a faked caustics + rays water material, description has a tutorial you don't have to buy anything. I am not affiliated with this person just found it in my search.


text:
Show the "Adjust Last Operation" popup when executing node tool with python
I am running a node tool with python, but when it's executed, the Adjust Last Operation panel isn't showing up.
class SelectEditOperator(bpy.types.Operator):
    bl_idname = "object.edit_select"
    bl_label = "Edit Brushstroke"
    bl_description = "Select Brushstroke from vertex and edit"
    bl_options = {"REGISTER", "UNDO"}

    def execute(self, context):
        bpy.ops.geometry.execute_node_group(asset_library_type='LOCAL', asset_library_identifier="", relative_asset_identifier="NodeTree\\Edit Brushstroke")
        return {'FINISHED'}

There is an undo argument for geometry operators which works with operators like Add Cube, but simply adding , True at the end of the node tool operator doesn't seem to work.
my node tool has inputs,

which show up when i execute the operator from the menu,

but not when i execute it with python.

Hello, try adding bl_options = {"REGISTER", "UNDO"} to the class definitions

In addition to Gorgious suggestion, it is also because your operator doesn't have parameters that need to be adjusted after execution.

@Gorgious oh i tested again turns out bl_options = {"REGISTER", "UNDO"} is enough for it to show up. But why would the OP need it to show up if there is nothing to adjust (since it is called Adjust last Operation)

Good point, I suspect this is a minimal working example and OP intends to add parameters to the operator. Thanks for the answer. Cheers

You won't see any Adjust Last Operation panel because your operator does not have parameters that can be adjusted after execution. In this example I added an adjustable parameter like  asset_library_type for example which you can adjust, default being LOCAL. Also as @Gorgious has mentioned you need to register the bl_options.
import bpy

class SelectEditOperator(bpy.types.Operator):
    bl_idname = "object.edit_select"
    bl_label = "Edit Brushstroke"
    bl_description = "Select Brushstroke from vertex and edit"
    bl_options = {"REGISTER", "UNDO"}

    asset_library_type: bpy.props.EnumProperty(
        name="Asset Library Type",
        items=[
            ('LOCAL', "LOCAL", "Local Blender file"),
            ('ALL', "ALL", "All"),
            ('ESSENTIALS', "USER", "User"),
            ('CUSTOM', "CUSTOM", "Custom"),
        ],
        default='LOCAL'
    )

    def execute(self, context):
        bpy.ops.geometry.execute_node_group(
            asset_library_type=self.asset_library_type,
            asset_library_identifier="",
            relative_asset_identifier="NodeTree\\Edit Brushstroke"
        )
        self.report({'INFO'}, f"SelectEditOperator Executed")
        return {'FINISHED'}

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

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

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

if __name__ == "__main__":
    register()

The parameter asset_library_type is just an example, changing the option from LOCAL to another doesn't work yet you have to fix that if ever you want to use this parameter. Or use another attribute as parameter. The point is you need to specify an adjustable parameter in order to see the Adjust Last Operation popup panel.

this works, but it exposes the asset library type parameter, which i don't need. the node tool does have adjustable parameters (socket inputs i made in the node editor with names i chose, and with automatically given data path names like "Socket_3") which show up when i execute it from the menu. how do i expose those parameters?

@Walter You can expose them using https://blender.stackexchange.com/q/317571/142292

ah thanks, that fixed it!

@Walter do you manage to show props for execute_node_group() operator? The link from Harry shows how to access node props, but only for modifiers, and not for operator nodes...


text:
Image Save UI Template
I want to add this UI template to my panel which can be found in the window when you are saving an image.

The closest I could get is this using the "template_image_settings". But the color space part is completely different here. But in the answer to this question is told otherwise. Did something change in Blender so that's why it is different now? The post is only a little over 1 year old.
layout.template_image_settings(context.scene.render.image_settings, color_management=True)

The template you are using is for textures (input) you need the render settings or image save settings (output)

Which image is the 'input'? The first is from Image > Save As, and the other is from Properties > Output Properties > Output. Isn't both output? Just the first one is simple image save and the second is rendered image save?

The upper screenshot contains the settings of an image texture node in a material. Therefore color space is not the type you save as (filmic, etc) but the way it is interpreted by the node tree (non-color etc.) I have not looked at the templates, but you can probably edit the code manually, for example color_management=True, see if there are more optional parameters in the template.

So it doesn't matter what color space I chose on the first image, it won't affect the exported/saved image, right? Unfortunately the "color_management" is the only listed parameter. Also, there is a "Save As Render" checkbox, if I set it to True, the "Color Space" switches to "Color Management" (basically the second image).


text:
Using report in global function
I'm trying to figure out how I can do a self.report from my function which is triggered by the end of the texture bake event.
By pressing this button, it adds my "my_bake_bake_complete" function to the handler of the "object_bake_complete"- so right after when the texture bake is finished my function runs. After adding the function to the handler, in the next line, I call the default bake, so the texture bake begins.
class mybake_Bake(bpy.types.Operator):
    bl_idname = "mb.bake_button"
    bl_label = "My Bake Button"

    def execute(self, context):
        bpy.app.handlers.object_bake_complete.append(my_bake_bake_complete)
        bpy.ops.object.bake('INVOKE_DEFAULT')

def my_bake_bake_complete():
    self.report({'INFO'}, "Object bake complete...")

And this almost works without any issue, but the self.report part. The "my_bake_bake_complete" function is called correctly after the bake (I tested it with a simple print("") and it prints). I'm guessing the problem is with the context in the "my_bake_bake_complete".
Also, there is a type error in the console:

TypeError: my_bake_bake_complete() takes 0 positional arguments but 2
were given

Unfortunately, I have no idea what arguments and how they should they be passed.

What is self.report? Clearly, it's a part of some bigger code, but taken out of context it doesn't make sense.

I don't think it's part of a bigger code. As far as I know, it displays messages in the  Info panel and in the console.

no, this can not by itself display a report... this need interactive operator to be reported

"I don't think it's part of a bigger code." - where did you get this code from? Did you write it yourself? Did you copy-paste it from somewhere? If you got it from chatGPT, it's pointless to post a hallucinated code, instead explain what you mean by "report", do you want to print a message into console, or do you use some debugging library.

I don't know what was the original source where I found it, but it's also used in this video for example: https://www.youtube.com/watch?v=TgQ9ahMuDMw

I'd like to use it to give states about a function, like when it's finished or failed for some reason.

like lemon said. in python the self is only defined in a class. but in your case you just have a global function. You can only run the report function from inside an Operator. Now the problem is, when you start the operator from the function, the operator has no context.
A way to get this message to display after a bake has finished, is to initialize the bake yourself and then you have full control. Seems like your doing this anyways ("Auto bake:...").
import bpy

class BakeOperator(bpy.types.Operator):
    bl_idname = "object.bake_operator"
    bl_label = "Bake Operator"

    def execute(self, context):
        bpy.ops.object.bake()
        self.report({'INFO'}, "Auto Bake: Object bake complete...")
        return {'FINISHED'}

class BakePanel(bpy.types.Panel):
    bl_label = "Bake Operator"
    bl_idname = "OBJECT_PT_bake_operator"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Bake'

    def draw(self, context):
        layout = self.layout
        layout.operator("object.bake_operator")

def register():
    bpy.utils.register_class(BakeOperator)
    bpy.utils.register_class(BakePanel)

def unregister():
    bpy.utils.unregister_class(BakeOperator)
    bpy.utils.unregister_class(BakePanel)

if __name__ == "__main__":
    register()

Note you have to init everything from a UI button press, for the report function to work. This wouldn't report anything:
if __name__ == "__main__":
    register()
    bpy.ops.object.bake_operator()

Thanks for your answer, I updated the original post. I tried to give a more detailed and better explanation about how and what I'd like to do exactly. I hope its more clear now!

I'm a Python noob, so I'm probably explaining things wrong, but perhaps my uneducated explanations will be more understandable?
There are only three report() methods I know in BPY:

bpy.types.Macro.report
bpy.types.Operator.report
bpy.types.RenderEngine.report

The way I understand it:
You are making an operator, so it would make sense to make use of bpy.types.Operator.report. It is part of the operator type, so you must call it from within your operator's class. Hence, in the tutorial, it is indented inside the class and is preceded by self. (here's why you need self).
For this to be run at the end of your operator, all you need is to put it at the end of your execute function, just before return.
So, in other words, make a nice operator class with report at the end, a nice UI panel class to make you panel and button that allows you to run the operator, and finally the register/unregister functions to use all that in Blender.
Which is exactly soerensc_'s answer.

Thanks for your answer, @L0Lock! Unfortunately, putting the report at the end of the execute or after the bake line doesn't solve the problem. I think bpy.ops.object.bake('INVOKE_DEFAULT') is run on a different thread or something, hence the report would appear instantly, not only after the bake. It might work without the 'INVOKE_DEFAULT' parameter, but then I would lose the progress bar for the baking, which I'd like to keep, and the UI would also be frozen until the bake finishes, so it's not an ideal solution. Regarding the panel and the (un)register parts, they are fortunately 'done'


text:
Simple "UV Sphere" Normal Bake
I've tried to bake a Normal Map for a simple UV Sphere that you can create from the Mesh section. So I added two meshes and I put a Subdiv modifier to one of them as the 'high poly' mesh and I left the other one as default 'low poly'.
The break result is an empty purple texture. #8080FF
I tried to change the Extrusion and Max Ray Distance values but nothing other than somewhere a yellowish color appeared.
Before this, I baked a more complex mesh and it worked well, but not on this simple basic mesh.
Did you ever experience something like that? Any solution?
Here is the Blend file if anyone need it:
https://drive.google.com/file/d/17SNvxde4crIhbfxExFiVILiXhz9uZy_2/view?usp=sharing

Hello, I'm not sure to understand, you are baking a completely smooth sphere with another one, what 3D details is it supposed to bake?

Hey! The high poly sphere has almost 32k vertices, the low poly has almost 500. So I suppose the difference should appear on the normal map, shouldn't it? Between the two meshes. there is a clearly visible difference in the viewport.

what are you expecting to see? If you bake a very smooth surface with a rather smooth surface, you won't see a lot of things.

I thought I should see the difference between the 2 mesh on the normal map after the bake, even if it's not that big. But if that's it, thanks for the explanation!

you can begin to see something if you have a lowpoly that is lower in polygons (or shade flat) but I'm not sure how you want to use the map it will give, maybe give more details

Yeah, it's true, if I turn it to flat shaded it's clearly visible on the normal map, but on smooth it's just a clear empty purple map. Same on a very low poly (26 vertices) sphere. I just hoped it'll give some plus details.


text:
Ping-Pong Node Smoothing
How could I smooth out the top and bottom parts of the triangles?

Hi, Tsybe! as @Markus has commented below.. I thought the only reason you put the Greater Than  branch in your Q was to illustrate the function.. not actually to get the wave pattern...  sorry.. so as he says .. replace the Ping Pong in your tree with the clusters illustrated in my answer, and leave the rest as it is. That should work.

.. See Edit.. I've returned your (very neat and tidy! :D) .blend, with adjustments.

At its simplest, you could use Map Range to map the function from a linear, to a smooth, version of itself:

For more control, you could, for example, map the Ping Pong into a 0-1 range, through an RGB Curves node, and back out to its original range, after tweaking the shape:

Thank you for your answer, both of your results look pretty good! I've tried to replicate your nodes but unfortunately, something went wrong in mine. Now it looks like a simple Wave Texture node,  and there are no triangles anymore. I updated the post with the blend file, if you could take a look at it I would appreciate it!

@Tsybe R. Betts only posted a change, not whole node setup - he alters your x, but you still need to pass it to Math: Greater Than node, along with z as Threshold.

Thanks, @Markus.. will explain on OP.. :)


text:
Select vertices by their indices (by vertex id)
I want to select vertices by their indices (by vertex id)
Like a python script,so that i can write the vertex id into it, and run the script,and it would automatically select those vertices
there is already an answer (python script) ,but it only works with one vertex
when i tried with more than 2 vertices,it does not work :
How Could I Select a vertex by its ID?

I have modified the code from this answer to solve the problem, where I have replaced  if vert.index == index: to if vert.index in indices: where indices= [1, 2, ...]
example :
import bpy
import bmesh

indices = [1, 3, 4, 7, 8]

obj = bpy.context.object
me = obj.data
bm = bmesh.from_edit_mesh(me)

vertices= [e for e in bm.verts]
oa = bpy.context.active_object

for vert in vertices:
    if vert.index in indices:
        vert.select = True
    else:
        vert.select = False

bmesh.update_edit_mesh(me, True)

Another approach would be to remove the else: vert.select=False so that it only extends the selection, then manually de-select all if you want to start again.

same thing for the faces? face in faces ?

For blender 3.2 version, it seems the bmesh.update_edit_mesh(me, True)  should change to bmesh.update_edit_mesh(me)


text:
How to generate a full sprite sheet automatically
I've been wondering how to render all animation frames at once for a full sprite sheet, instead of having to change the camera manually 8 times and render each direction (with the file manipulations that ensue).
I've learnt how to rotate easily the camera by parenting it to an empty objet at the center of the set (cf. How can I export a blender model as a sprite sheet?) and rotate that object with discrete steps of 45 or 90°.
But is there a way to tell Blender something like, for example : "render frames 30 to 52 of the animation, then rotate the camera 45°, then render frames 30 to 52 again, and so on until the camera has rotated 360°".
Maybe a Python script is necessary ? But I don't know Python at all and I've no idea where to start...

Have a look at sprite render kit

Python appears to be the least desirable solution.  Repetition can be managed without explicit  Python. If you wanted to learn about Python then that would be a separate question.  If you want quick results you will not learn about Python for this particular task.  Blender has so many features and addons it takes time to know about some of them.

Consider using the NLA editor window to combine repeating animations with other animations.  It can hide unnecessary detail for some situations.
The NLA Editor allows the animation curves in the   animation to be explicitly repeated with a timeline to show synchronization.  Since you can specify the repeat range with frame numbers and not keyframes this control suits some users ideas better.  More Control and a steeper learning curve.  I am suggesting you search using the NLA Editor Window video tutorials.
In the image above the NLA Action Extents are explicitly specified with frame numbers.  Repeat Value is specified and can be seen as vertical divisions along a track.  So we see MarkerAction.001 and MarkerAction.002 are repeated 4 times and synchronized visually.  The more repetitions you have, the more valuable the NLA Editor becomes.

That's it! With a "repeat with offset" cycle on the camera rotation (thanks Mutant Bob), plus appropriate start frame, end frame and iterations in the NLA editor as said above, everything works perfectly, and I still don't know the first word of Python. Many thanks !

Perhaps putting a Cycles modifier on the animation fcurves so that the animation repeats for each of the different camera angles ( for 23 * 8 frames) would accomplish your mission:

The biggest stumbling block is making sure you have the right span of keyframes to control how many frames the cycle has.  You will probably find yourself adding keyframes at the beginning and ending of the loop (frame 30 and 53=52+1) to ensure that it loops correctly.

Thanks, that was really helpful to set the camera rotation! I just didn't know what to do with it next, but now that I know what the NLA editor is, everything works fine :)


text:
Mesh for each keyframe
Through the usage of a simulation framework, I have for each simulated time step a mesh (.ply format). This results in a collection of meshes. They represent an object deforming over time with each mesh representing a certain point in time. I know how to import these files but how can I easily and automatically animate the deformation given these files?
My question is similar to:  import series of meshes but in my case the number of vertices and faces in each mesh differ. Therefore I do not know if the solution is still valid.
Another similar question is: Can one create a video from sequence of meshes that you already have using blender? which offers the same solution: convert format to PC2 or MDD formats and use Mesh Cache but there it explicitly says that the mesh needs to have the same amount of faces and vertices throughout the entire simulation.

You might try the Blender add-on Stop Motion OBJ. It supports sequences of .PLY, .OBJ, and .STL files. It also supports geometry with different vertex counts from frame to frame.


text:
Shrinkwrap modifier not moving vertices to nearest target surface point
I am attempting to animate a book opening. In order to keep my pages attached to the book binding as it opens, I am using a shrinkwrap modifier on the page meshes which transform the bottom page vertices to the nearest surface point of the book binding.

the modifier works when the book is closed, but the page does not stay attached to the binding as the book opens. Anyone have an idea as to what is going wrong?


text:
How can i get bone global axis rotate
Below code is just get bone euler_Angles.
import bpy
pb = bpy.data.objects["Armature"].pose.bones["Bone001"]
rotate_x = pb.rotation_euler.x
rotate_y = pb.rotation_euler.y
rotate_z = pb.rotation_euler.z

But this angle show local axis.
And in blender, if bone rotate on global axis, properties shown rotate values as local.
How can i get global axis rotate?

From the world space matrix in dupe answer global_rot_euler = matrix_final.to_euler()  https://blender.stackexchange.com/questions/1283/how-to-get-world-space-matrix-of-any-pose-bone

also please don't ask the same question twice. https://blender.stackexchange.com/questions/136455/how-to-get-posebone-global-rotate


text:
How to duplicate an object in 2.8 via the Python API
I know how to successfully duplicate an object by using
bpy.ops.object.add_named(name = 'TemplateObjectName')

If the template object named 'TemplateObjectName' has animations, particle systems and modifiers attached to it, the previous call will create a duplicate object that also has those components. However, if I duplicate an object using
template_object = bpy.data.objects['TemplateObjectName']
new_object = bpy.data.objects.new('NewObjectName', template_object.data)
collection.objects.link(new_object)

how do I attach the template object's animation, modifiers, particle systems...?

Make copies of ID data with ID.copy()
For blender data ID objects ie objects in bpy.data.objects meshes in bpy.data.meshes actions in bpy.data.actions  the ID object has a copy method .
For a bpy.types.Object object copy, the copy will have the same transforms, parent, modifiers, constraints, animation data et all of the original.  All linked data will be same as original. eg if mesh of original is bpy.data.meshes["Cube"] so is the copy's.  Fortunately the mesh also has a copy method.
template_ob = bpy.data.objects.get("template")
if template_ob:
    ob = template_ob.copy()
    # link to collection if need be
    collection.objects.link(ob)

the copy ob has the same linked data as the original template_ob.data is ob.data is True.
    # assign a copy of the mesh to copy object
    ob.data = ob.data.copy()

Assuming we've checked original has an action then to make the action a copy of original's
    action = ob.animation_data.action
    # make it a copy
    ob.animation_data.action = action.copy()

To unassign
    #make it None (no action assigned)
    ob.animation_data.action = None

Or in one fell swoop, remove all animation data including actions and drivers
    ob.animation_data_clear()

Constraints and modifiers data are not linked. The copy has the same of each, including the same names, as original.  The vertex groups and target objects pointed to will be same as original, and may need to be adjusted.
To remove all modifiers and constraints on copy
    ob.modifiers.clear()
    ob.constraints.clear()

Duplicate Object operator. bpy.ops.object.duplicate()
can also use the duplicate operator.  As with operators they work on the context and selected objects, which if need be can be set within a script.
Alternatively with an override dictionary. Early testing and 2.8 appears much simpler on this front.
Test code (can confirm works as expected when run in python console on 2.8)
Duplicate an object template_ob with linked data
bpy.ops.object.duplicate(
        {"object" : template_ob,
         "selected_objects" : [template_ob]},
        linked=True)
ob = context.object # newly duped object

linked=False is the default.
Making a new object with copies of originals data.
From question:

template_object = bpy.data.objects['TemplateObjectName']
new_object = bpy.data.objects.new('NewObjectName', template_object.data)
collection.objects.link(new_object)

how do I attach the template object's animation, modifiers, particle
  systems...?

Strictly speaking this is not a duplicate. It is a new object that shares the originals data part.  Or similarly in your answer where it shares data part, and original action or copy thereof. Results will match in the simplest of cases,   ..and may be the answer you are seeking. However for others wishing to duplicate their objects in 2.8 using this method
Can they be assured that nothing is affected by not having  a property of original on the new object?

The action or driver may refer to data paths of properties on original that either,
will not be defined, or set to default on the new object.
Relations: modifiers constraints animations could require  the original having a certain parent or transform.
How to go about copying over the constraints / modifiers of the
original? What if they have drivers? Should target objects be duped,
Vertex groups? .

To reiterate, making a new object sharing some chosen DNA of the original is IMO not duplicating.  Obviously there's no need to write a script with all the options required to emulate ob.copy()  just like there's no need to use ob.copy() to add a new object with default settings, and only a few chosen attributes of ob
Putting the body of Porsche on your new car, and driving it like it's a Porsche, doesn't make it a Porsche, it may however achieve the result you are after

Thanks @batFINGER for your answers. They didn't just solve my problem, they also provided much needed general knowledge that I much in need of.

Thanks @p2or for your answers. They didn't just solve my problem, they also provided much needed general knowledge that I much in need of.

I have collection object is not define when running your code

Note that this is a complement of information for the already provided answers in case someone finds this post looking for a way to duplicate an object. Read the accepted answer to understand how one can do more than just duplicating an object.
cube = bpy.data.objects["Cube"]
cube_2 = bpy.data.objects.new('Cube 2', cube.data)
cube_2.location.y += 5
bpy.data.collections["Collection"].objects.link(cube_2)

Above is a simple example of the code needed in the default/generic template to duplicate the cube and have a new instance called cube_2 added to the default collection. I changed the location of the duplicate so we can see both cubes at once.

Only the mesh of original  object properties will be duplicated.  I imagine that cube 2's y location will be 5.  Not always 5 from original.  (Test on objects without identity transform).  Other object properties like modifiers and constraints will not be on copy.  (Appear to be answering question using code from question)

This is how you can duplicate the object: linking the original object's mesh data, and with/without linking the original object's animation data:
template_object = bpy.data.objects.get('TemplateObjectName')
if template_object:
    # Create the new object by linking to the template's mesh data
    new_object = bpy.data.objects.new('NewObjectName', template_object.data)
    # Create a new animation for the newly created object
    animation = new_object.animation_data_create()

    # Option 1: Linking action
    #-------------------------
    #Assign the template object's action to the new animation
    animation.action = template_object.animation_data.action

    # Option2: NOT Linking action
    #----------------------------
    # Assign a copy of the template object's action to the new animation
    animation.action = template_object.animation_data.action.copy()
    # Rename it if desired
    animation.action.name = 'NewAction'

    # Link the new object to the appropriate collection
    collection.objects.link(new_object)


text:
Import helper for error handling with confirm window?
I hope to add "confirm window", when user select file which not right extension in blender file selector.
I tried to use window_manager.popup_menu()
import bpy
from bpy_extras.io_utils import ImportHelper
from bpy.props import StringProperty
import os

def ShowMessageBox(message="", title="Message Box", icon='INFO'):
    def drawinfo(self, context):
        self.layout.label(text=message)
    bpy.context.window_manager.popup_menu(drawinfo, title=title, icon=icon)

class WIF_OP_ImportDazData(bpy.types.Operator, ImportHelper):
    bl_idname = "import_js.dazdata"
    bl_label = "Import Json"
    bl_description = "import rig data to adjust daz bones"
    bl_options = {'UNDO'}

    filter_glob: StringProperty(
        default='*.json;*.txt',
        options={'HIDDEN'},
    )

    def execute(self, context):
        filename, extension = os.path.splitext(self.filepath)
        if extension == '.json':
            rigdata = read_json(context, self.filepath)
            rigs = bpy.context.selected_objects
            set_custom_props(rigs, rigdata)
        else:
            print("Select json please!")
            ShowMessageBox("Select JSON please!!", "fail load", "INFO")

        return {'FINISHED'}

# test register and invoke
bpy.utils.register_class(WIF_OP_ImportDazData)

bpy.ops.import_js.dazdata('INVOKE_DEFAULT')

Though it work, but there is clear problem.
When user miss select json file, file selector close then return UI. message-box appear, but it located on where user clcik import button only when user stay mouse. then often miss message-box. (they disappear), user can not clear see, if import is cancelled or not. like this

So what I hope is, show message box on file selector. ideally I hope to use confirm window with custom message (not change UI, but keep file selector)
Is there good way to achive it?  I already try many things but still no success.
(try to call ShowMessageBox in invoke class method etc,,, )

Would seriously consider not using the menu popup here.  The fileselector is running as a modal operator and execute will pop back to call area.  Would suggest either only globbing for json files, or put your warning message, based on filepath,  in the draw method of the operator.

Hi batFINGER, yes I almost understand why it not work, and yes I can set globbing json only. but it is for user can easy find json (which saved with same name another format. and image)  then  would you show me simple code, of your second suggesiton?

Ah I see. I try draw operator, of may use custom label for info, under my panell ui.  thanks.


text:
How do I get the current directory without an open file?
I've done a lot of searches but unless I'm missing something obvious (and I may be) I don't see any answers that don't involve already having a Blender file open (and I understand how to do that).
What I'd like to do is in my script be able to access the current directory that Blender opens up to load in Blender files.  BEFORE any file is loaded.  Because that default directory is where I want to store a config file to read parameters for my script (which can be run even if they don't have opened a Blender file).
Does that make sense?  I can force a directory, of course, but I'd rather say to folks "just put the config in your default Blender directory" and then be able to find that file there.
All the answers seem to require first a file, like these:
bpy.path.abspath("//my/file.txt")
bpy.path.abspath("//my\\file.txt")  # on Windows, with backslash escaped
bpy.path.abspath(r"//my\file.txt")  # on Windows, using python raw string
bpy.path.abspath("//../file.txt")  # to go back a directory

but I don't have a file.  (And using the "//" alone gives me an error, although using two back slashes just gives me a single "\" as the result, which is NOT the current directory).
This seems stupidly simple but I'm feeling really dumb.

https://www.youtube.com/watch?v=tJxcKyFMTGo Corey's videos help me out a lot.

print(bpy.utils.resource_path('LOCAL'))   #Gives the default file locaton
print(bpy.utils.resource_path('USER'))    #Gives the blender installation location

You can use this as reference to go to other directories.

Shoot, here it is:
import os
os.getcwd()

But I looked for a couple of hours without luck.  Sorry, folks.

Those are not the same. //some/path.txt means "relative to the currently open blendfile". os.getcwd() will give you the current working directory, which isn't related to which blendfile is open at all (on Windows it'll most likely give you 'C:\\Program Files\\Blender Foundation\\Blender').

Yeah, I found that out later, but at least it gives me a workable place to point folks to that won't change on their systems (unlike the relative to currently open blendfile).  I guess there isn't just a "show default dir where I will open up Blender files" way, but that's acceptable right now.

That directory can't be written to by normal users, so it's rather pointless to send them there. Using os.path.expanduser('~') will give you the home directory of the user, which is much more likely to be what they want.

Thanks, doc, that does seem to be better (I added a \documents\ to the path because that's a directory all should have there).  This isn't so much for the world to use, so I wasn't too concerned about needing admin privileges, but it's definitely easier even for me not to have to invoke permissions each time.

If you want cross-platform support, you can't assume there is a documents folder there, nor can you use backslashes. Maybe that's relevant to you, maybe not ;-)

No, this is strictly a Windows program (the software it runs on is only for Windows).  But thanks.


text:
How do I Set Parent to Armature?
So I actually had this working, and without changing anything (or so I thought) it stopped working, and the error I get is just a "this won't work" without even pointing me to a line or anything.  Here's the code:
import bpy

#Set parent
bpy.context.scene.objects.active = bpy.data.objects['Armature']

ob= bpy.data.objects['Tuxedo Shirt']
arma = bpy.data.objects['Armature']

bpy.ops.object.select_all(action='DESELECT')
arma.select = True
bpy.context.scene.objects.active = arma

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

parent_bone = 'CC_Base_BoneRoot' # choose the bone name which you want to be the parent

arma.data.edit_bones.active = arma.data.edit_bones[parent_bone]

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

bpy.ops.object.select_all(action='DESELECT') #deselect all objects
ob.select = True
arma.select = True
bpy.context.scene.objects.active = arma    #the active object will be the parent of all selected object

bpy.ops.object.parent_set(type='BONE', keep_transform=True)

I know there are redundancies there, but it was how the code got built and I didn't want to alter anything from what was working.  And, yes, those are the right names of the mesh and bone (like I said, it was working just fine -- obviously I must have changed something but I have no idea what it was).

Well, I got it working, but I'm still not quite sure why it works now.  I started by getting rid of all the extraneous crap but where it was crapping out seemed to be at the bpy.ops.object.select_all(action='DESELECT') statement, which still seems to me to be harmless.  Anyway, here's the code that works:
import bpy

#deselect all objects
bpy.ops.object.select_all(action='DESELECT')

ob= bpy.data.objects['Tuxedo Shirt']
arma = bpy.data.objects['Armature']
arma.select = True
bpy.context.scene.objects.active = arma

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

parent_bone = 'CC_Base_BoneRoot' # choose the bone name which you want to be the parent

arma.data.edit_bones.active = arma.data.edit_bones[parent_bone]

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

bpy.ops.object.select_all(action='DESELECT') #deselect all objects
ob.select = True
arma.select = True
bpy.context.scene.objects.active = arma    #the active object will be the parent of all selected object

bpy.ops.object.parent_set(type='BONE', keep_transform=True)

I kind of hate it when it looks like magic and I don't understand why, but at least I'm not going to worry about it for now (if anyone has an explanation for it, though, I'd love to hear).


text:
Adding a color wheel to a UI panel that controls the color input of a cycles node
Okay so I am trying to add a color wheel to my custom UI panel to control multiple color inputs on different materials all at once, but I having a lot of problems trying to figure out what to do exactly and everything I have tried is giving me errors;

my idea was to add a driver to the color input of the node of the node using a custom property set to an array like this,

But when I try to use the custom property to control the driver it just says this

and I have run out of ideas of what to do, I'm still new to python and I am not really good at it.
Python script:
import bpy

class meshsettings(bpy.types.Panel):
    bl_label = "Fandroid"
    bl_category = "RigSettings"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'

    @classmethod
    def poll(self, context):
        try:
            return (context.active_object.data.get("Rig_Fandroid") == "armature")
        except (AttributeError, KeyError, TypeError):
            return False

    def draw(self, context):
        layout = self.layout
        row = layout.row()
        split = layout.split()
        col = split.column(align=True)

    def draw(self, context):
        layout = self.layout
        row = layout.row()
        split = layout.split()
        col = split.column(align=True)

        row.label(text="Model Settings")
        col.prop(context.active_object.data,'["Subsurface"]', slider=True, text="Subsurface Level")
        col.prop(context.active_object.data,'["OpenSubDiv"]', slider=True, text="OpenSubDiv")
        col.prop(context.active_object.data,'["EdgeSplit"]', slider=True, text="EdgeSplit")
        col.label(text="Material Settings")
        col.prop(context.active_object.data,'["LightBrightness"]', slider=True, text="Light Brightness")
        col.prop(context.active_object.data,'["BaseColor"]', "color", text="")

bpy.utils.register_class(meshsettings)

Is this the same question you have asked 11 hours ago, which is deleted now?

kind of, I now made it more clear and in the last post I had no idea what to do but now I have the idea of using the array and stuff, anyways I thought that it would be better to just remove the post than edit it and redo everything on it

For future ref: to format code select code block and hit control - K or hit the code button {}.  Is obj["BaseColor"] a list? a driver expects a float result.


text:
Animate Only Child Object
I'd like to modify a child object without affecting its parent, but whenever I add a keyframe to the child object even location, rotation, etc. it affects the parent object as well.
Could I solve that somehow?

it should not affect the parent, maybe show some screenshots or share your file

I've updated the post with the .blend file.

actually you've keyframed the scale of the armature and the armature is the parent of the object called child, so I'm not sure what you mean

I want to modify only the child object. I've selected it and in this case, I scaled it down. But not only the child object got modified but also the armature. Should I do something else other than selecting the object?

you've given the same animation to both the child and the parent (armature), so the problem is not that the child make the parent scale down, the problem is that the animation makes the armature scale down

yes, but if I remove the scale transform from the armature it also removes from the child object

of course as they share the same action, you need to give 2 different actions to these 2 objects

You've given the same action to both the child and the armature, if you switch the Dope Sheet to Action Editor mode and select the wand then the armature, you'll see that they share the same action. This action has some keyframes set for scale, so both the 2 objects scale down. It's not the wand that makes the armature scale down, it's the animation that is assigned to it:

If you want only the wand to scale down, duplicate the action (New Action button), remove the scale keyframes for the armature, keep them for the wand.

Thanks, it makes sense for me now!


text:
Interface floats in window after switching screen resolution
Operating system: macOS Mojave 10.14.2
Graphics card: Intel Iris Pro 1536 MB
Broken: 2.8 beta e57ee5934a30
Worked: 2.79
Problem: Blender window goes edge to edge, but interface only renders from the bottom left-hand corner to fill 60% of the screen. Mouse input corresponds to correct scale, but interface renders only in distorted area. Assuming it's graphics issue which can be solved by clearing an interface cache somewhere.
How to reproduce error:

Open Blender on regular-resolution display
Drag Blender window onto display with different resolution
Interface scale breaks (cannot be reset)

How do I completely reset how the interface is being rendered so I can fix this interface scaling issue?

Using beta version. My bad, @batFINGER. Same problem in both alpha and beta.

The only working solution to this is quite simple. Use the final version, not the Beta. To get that bug recognized as a bug, you just have to go to Blender's bug tracker, create an account and submit a bug report.

@metaphor_set Thanks, but not super helpful. This occurs in 2.79 too, so not a bug.

If you tried everything to fix it and there are no other users that report the behavior than most people would say "Dude, check your system, reinstall your OS". That's what I call "not super helpful". Seeing that you try to get it to work on Mac OS, which has a significantly smaller userbase within the Blender Community, I (as a software developer with quite some experience under the hood) just give the best advice there is: Reporting the bug does not only help you, but also others who might stumble over it in the future.

This seems to be a bug. This is considered off-topic on Blender Stack Exchange.
See: What questions should be definitely off-topic?
Also this is to be expected since 2.80 version is not yet released and beta builds are still experimental. The bug should be reported:

You should ensure that you are using up to date graphics drivers, which on Mac OS means you should run up to date OS(it seems yours is up to date already). Blender 2.80 builds are built daily as well, so you can check if the bug is fixed in later builds, but that has little chance of happening if it is not reported.
Other than that, it seems Mac OS is not a perfect environment for doing 3d work at the moment. OpenGL support was dropped by Apple so if this by any chance is caused by a bug in their drivers, it is not going to be fixed in the future. I know it's not pleasant, but you may want to consider using another OS maybe in some sort of a dual boot set-up. It does not seem the situation with Mac OS is going to improve any time soon, it seems it might get worse.

This occurs in 2.79 as well, so not a bug. Graphics drivers are completely up to date. Using daily builds. — You're right, macOS isn't the best platform since Apple deprecated OGL. Will have to see what I can do in the meantime.

It is definitely not a feature - it's a bug. There may be some bugs in any version.

Discovered the source of the problem: switching to screens with differing DPI. The difference between Retina screens e.g. 2015 MBP and 170 DPI Apple Cinema displays causes the Blender interface to break. Will report this on bug tracker.


text:
Joining 2 objects in Blender 2.8 loses UV mapping on 1
I'm a bit new at Blender, so this question might sound stupid, but I've tried every suggestion I can find here and nothing is working for this.
I have 2 separate objects with their own UV and material. I've named the materials and the UVs to be unique prior to joining them. I've made certain that both objects have both materials. But, as soon as I join them, both objects always try to use the same UV map. I've tried added vertex groups and assigning them prior and after joining, but that was no assistance, either.  Is there some basic step I am missing?

Blender file:
https://1drv.ms/u/s!At__F5mV_pKlgdFMYC3Ivy50t0VZZQ

A material uses the active UV map of the object if it is not specified otherwise. If you have the UV maps named differently, they are the active UV maps for each object when they are separate, however when they are joined the one from the active object becomes the active one for all the vertices of the new mesh. If the UV maps had the exact same name, they would be merged when the objects are joined.
It is probably best to just name the UV maps same so they get merged when joining, but if there was a reason to have them separate and at some point use one texture with both of them, they could be added together with nodes and since color values in Blender are 32 bit floats, Mix Color node can be used for this even though UV maps consist of coordinates and not colors.

I knew there had to be a simple answer! Thank you!

If more UV maps are linked to an object, the materials used by that object need to have an Input > UV Map node attached to the Vector socket of their textures, specifying which UV Map to use, so either of these:


text:
how to turn a square into a circle in 2.8
In blender 2.79 there was an ability "to circle", i believe, that took a series of vertices and made a circle with them. i am not finding that ability anywhere in 2.8, is it gone?

Related

Sorry I am not sure I understand your question. What do you mean create a circle from a group of faces? Or from a square (which is different)?
To create a new "Circle" primitive there is an "Add" menu just on top of the viewport. To "round up" a (decently created) geometry that already exists, which doesn't make a circle but a more rounded shape, you can use Subdivision Surface as explained by Nobimberg.

I believe that's a feature from an add-on, loop tools. I am not sure whether it is available in 2.8 but it should be, once the developer managed to update the code for the new 2.80 API

There was To Circle operator which had Shift+Alt+S shortcut in 2.79 and below. It didn't work quite reliably as LoopTools counterpart but it seems to me that's what OP is asking about

LoopTools addon has an operator 'Circle' that does this. Since the topic is on hold, I cannot answer but if you enable the Looptools addon, you will find the operator on the W key>Looptools>Circle.

Does this answer your question? How can I morph a flat plane to be a flat cirlce?

Let's say you have a plane like the one in the picture below, to transform it into a circle you want to use the Subdivision Surface Modifier.

To do this, select first your model, then select the little wrench icon you find on the left of the properties panel which is on the bottom right of the user interface (the one pointed by the red arrow in the second picture) then click on Add Modifier. You're going to see a dropdown list, select the Subdivision Surface Modifier from there.

Once you've selected it you're going to see something like in the second picture on your properties panel, while the plane will look like the picture below.

What you want to do now is increase the value of the View and Render properties on the modifier. These basically increase the number of subdivisions on your model: the first one is just for the viewport, the second is for the actual render of your model, if they are different your model will look different in the viewport and when you render it.
By setting both values to 3 I was able to transform the plane into the circle in the picture below, which I think is enough.

You're looking for To Sphere.
Go into Edit Mode, select the vertices you want to change, press Shift+Alt+S and move the mouse till you get the shape you want (or use the menu Mesh > Transform > To Sphere).

LMB  to confirm changes, RMB  to cancel.

You have to activate an addon called loop tools.

Could you expand on this answer, such as explaining how the loop tools addon will help, and how to use the circularize tool there? LoopTools is probably a better solution to the problem in the original question than the existing accepted answer, but your answer is a bit incomplete as is.


text:
Add-On Dev: Default of PointerProperty changes based on type?
I'm trying to make sense of something I've noticed while debugging.
When I add a property of bpy.props.PointerProperty with type=bpy.types.Object, the automatic default value (if nothing is specified for default) always seems to be None. Edit note: apparently there is no way to specify a default for pointers.
However, if I add bpy.props.PointerProperty with type=MyPropertyGroup where MyPropertyGroup is a custom class I derived from bpy.types.PropertyGroup, the automatic default is not None. Instead, it seems to be an allocated instance of the property group.
Is this normal behavior? As a programmer new to Python, I would expect the default to be None for all pointers, regardless of the type. I'm assuming the default is a valid instance for convenience?
If this is normal behavior, then is the instance of the property group some type of allocation that I need to delete? Or does that happen automatically?
Lastly, is there any way to define a pointer to a property group that defaults to None? Something that can be used to reference variable property groups? When I try to use the default= keyword, it reports it as invalid.
Appreciate any information on this

Don't confuse the PointerProperty with an actual pointer like in C or C++, PointerProperties only exist in Blender. Python is managed and has a garbage collector, there is (usually) no need to deallocate/free manually.

@rjg: Yeah, I had a feeling it was a Blender specific setup. I don't completely understand how referencing works in python, but is there a way to reference a property group using a non-property variable? I'm trying to process a hierarchy tree, where each object in the tree can override stuff. When they don't override anything, they reference their parent's data. When they do override, they reference their own data. But I'm not sure how to pull this off in Blender-Python (how to reference data without copying it).

I think the normal behavior of variable = property_group_var is to create a reference, rather than copy the data, but I'm not sure I understand why

If I understand the question right, then this is a basic principle of OOP. When you initialize and object, you create an instance of a class and assign a reference to that object to a variable. The variable itself is just a reference to the object, not the object itself. As such you can pass it into functions and the function can operate on the object or you can assign it to another variable, which will still point to the original object. You will explicitly have to copy the object, if you want to create a new object (or use a function that does). https://docs.python.org/3/library/copy.html

Well, I understand what references are, and how they work. But I'm not solid on Blender/Python referencing - specifically, why some types copy data on assignment while others (like property groups) seem to copy as references. I have a feeling I'm confusing myself because I keep thinking of property group variables as an instance of a class of data, when they are probably more like an iterator for a list. If that's the case, then all assignments in Python copy data, and none of them create a reference. Is that right? Blender is just emulating a reference using some type of lookup?

No that's not right. The normal case is that it's a reference. For example if you create a list x = [1, 2, 3] then assign the list to another variable a = x and assign a new value at an index a[0] = 3, you've modified the same object that x is referencing. Printing the values in the list will give you [3, 2, 3] for both variables.

Wow, okay. So assignment of any complex type will copy a reference by default, but all basic types copy data? If it boils down to that, I think I can keep it straight. Thank you for the help.


text:
Convert entire scenes from Blender Internal to Eevee
I would like to convert entire animated scene files from Blender Internal renderer (2.78c) to Eevee (any version). Is there an automated (scripted) solution to this? (Considering the suggestions I'm getting under "Similar questions" while editing this question, there is not, but I'll try it anyway - forgive my optimism.)
The scenes consist of linked-in characters and props, cameras, lamps, particle systems, animation etc. The materials are not node-based. There are hundreds of elements, so I just cannot do this manually.
(Background: I have been working on my animated series "The Hare of Cthulhu" since 2015, using Blender Internal and 2.7, and have completed around 40 minutes of animation. I still have another 30-40 minutes to go and would like to speed up render times.)

If you have Blender 2.78, try to see if the addon "Materials Utils Special" is included (it is in 2.79) if not, download the Blender 2.79 from Blender site and convert your materials to cycles (node base) using that addon and see if that helps a bit, if that works for you, just tweek a bit your materials and lights

Hi Emir, thank you for your ideas. I will try that.


text:
Geometry nodes affect instances with instancer data before getting instanced
So I'm making a flower field grow controlled by an empty with geometry nodes and I would like the flowers to open their petals during the grow animation at the edge of the empty. This would require Blender to change the rotation parameter of the petal instances before the entire flower gets instanced on points on the ground. Is this somehow possible? As the instancer of the petals doesn't know that there will be multiple flowers it seems like quite a hard task, I'm open to rearranging the nodes tho.
So I want to get the empty interaction data from here

Back to here and make the petals open while scaling them up

Blend file:
I hope you can help me, stay safe and have a great day ^^

Here are a few answers that might help you: https://blender.stackexchange.com/questions/271797/ and https://blender.stackexchange.com/questions/275954/

To achieve the goal, you would have to restructure some things here. You can only rotate the petals afterwards if you have access to these instances. Why this is so is explained here: https://blender.stackexchange.com/questions/274557/why-is-there-a-red-line-when-i-try-to-connect-one-node-to-another

Well, thanks for the suggestions ^^
It's now nearly impossible to still implement it tho, as I'm now using multiple different flowers and instance the collection.


text:
Bug with local camera function
I have a problem when I try to use the function local camera with lamp. The view just gets blurry. You can see it on the gif-image. Anyone come across this?
GIF: https://i.sstatic.net/naYY0.jpg


text:
Low Poly Art Deep Zoom Animation
I am interested in playing with blender to do some low poly stuff, I just like the style of it. Anyway my question is how are things like deep zoom handled in low poly.
Let's take a tree or grass. In the low poly style the leaves or the grass is handled by a single basic mesh object of some sort.  But let's say you want to zoom into the tree or down into the grass to focus on a bird or and any or something. Suddenly the individual leaves or even blades of grass relevant. How is the transition handled.
Can be in reverse what if you want to do an extreme pan out to show a planet (okay not realistic because you wouldn't model a full planet in detail in the first place). But the point is even if you modelled at low poly at a specific scale as you pull out you loose that style because it become to much detail.  More realistic example if you model leaves of a tree and pull out you wouldn't quite maintain the low poly look.
I don't think particles are helpful so just looking for a starting point to do some studying before I dig into the project.

You can create a high-poly mesh and animate the collapse ratio of its decimate modifier to reduce the polycount while the camera is zooming out.

Original Mesh

Mesh with decimate ratio of .016.
Learn more about the decimate modifier here: https://docs.blender.org/manual/de/dev/modeling/modifiers/generate/decimate.html
As for leaves, I'm not sure. It's hard to do a seamless transition between a bunch of individual leaves and a solid "block" you'd see in most low-poly renders.

Thanks. I can play around with it.  As long as it stays a single mesh it looks like it wouldn't be an issue. Like you said the problem is when you split between what looks like a single mesh to something that would be a bunch of smaller objects.  I assume this is actually a problem with higher poly as well in some circumstances.   The decimate looks interesting though, thanks.


text:
How to create a UV layout image?
I want to export my texture and i want to display on it also the UV layout
(Like on this image ) :

How can i do that ? I can do this in blender or this can be done only in an image editor software ?

You can export the UV map

and then overlay it onto the image texture in an image editor

I did that but the exported Uv Layout is not thick enough. When i put it over the  texture i almost  cant see it.

Look at the export options. You can increase the transparency which I believe is around 25% (not at my computer)

I already tweeked that valeu.Is not enough even if i decrease the transparency to 0


text:
There is a way to instance two rigid body objects with hinge constraint between then using AN?
I want to make several instances (clones) of a simple rigid body setup: two rigid bodies linked with a hinge constraint. Each one of the instances need to bend by the hinge in its proper individual way. Using the particle system, I managed to make it, but the problem is that all instances behave like the source setup.
In Cinema4d it is very simple, just set up the bodies and hinge and put it into the cloner or emitter object and it is done.
Is possible to solve this problem using Animation Nodes ? (I managed to clone the rigid bodies but the hinge constraint does not work)

You can achieve this with the help of animation nodes and particles here is a similar tutorial link: youtube.com/watch?v=G1ysjPeLKSQ

When you instance the object using the Copy Full Object option of the Instancer node, you are copying the constraints of the source object to all instances. And the constraints data for all instances will be the same. So all you have to do in this case is to update the data of the constraints. Consider the following example where we instance a group of cubes having a Damped Track constraint, after instancing, all cubes point to the icosphere because it is the target.

What we can do now is instance the icosphere and set the instances as the targets of the constraints of the cubes. The Object Attribute Output node can be used.


text:
extrude region (vertex normals) direction problem
Following tutor4u video making a mic (part 2) I came upon extrude region vertex normals for the mic stand bracket.
Selecting extrude region vertex normals I attempted to add .1 and enter, but the extrude only moves down in the z direction. Also when I click on extrude region vertex normals with my mouse and slide the mouse over the working window the extrude begins (downward in the z direction) by my just moving the mouse in any direction on working window.
The video does not show any problem like I'm having, I'm sure I have all settings the same as the tutorial. I'm using Blender 2.79 (same as tutorial) only I'm using a mac computer, tutorial appears to be windows OS. I also made sure that I have no vertex duplicates.

Can you please edit in a link to tutorial, and perhaps a picture of your mesh in edit mode.  Quite likely it can be fixed by selecting region (or all)  and flipping normals. Or without changing normals, to go in other direction negate the displacement, (-0.1).

As one option try to use Alt+S to scale along normals after extruding faces. Note that scaling might work only if there aren't any other faces already etruded

If  your Pivot is set to 'Individual Origins', you can indeed get AltE > 'Faces Along Normals' in 2.8, or AltE > 'Region Along Vertex Normals' in 2.79, to fail as shown.
With the Pivot set to any other value, it works as expected.
This does seem like, at least, inconsistent behavior.. I haven't looked to see whether it's already been mentioned to developers.

Your solution was correct. When I changed pivot point the 'Region Along Vertex Normals' action was the same as the tutorial. I'm glad to get over that hurdle in learning Blender.

@duane 'features' like this are rare in stable builds -  the devs are doing a great job. You're unlucky to have run into one.


text:
How would I build a twisted water slide?
I can't seem to find a tutorial or explanation as to how to do it - I start off with a cylinder and don't really get anywhere.

Something like this.
Any advice?

I think the Screw modifier might be the solution

Better use curves for something like this, at least for start, then you can convert to mesh, but please try to include the image in the question rather than keeping it as a link, question quality as it is now is very low, and might get flagged and removed.

yes you're right, array + curve modifers, so you have the joints

Using the Add Curve:Extra Objects shipped add-on, create a Spiral, Archimedes, 2 anticlockwise turns, type: Poly. Cut off the ends appropriately, and E extrude the new ends to make the straight sections.
Adjust the native Full bevel of the curve in its data tab, for depth and resolution. (object data tab > Shape and Geometry panels. Shape: 3D, Fill>Full.. and Geometry: Bevel>Depth and Bevel>Resolution)
In Object Mode AltC convert to mesh, then assign and apply a Solidify modifier
K with C and Z make a cut through the pipe, constrained to 45 degrees. Delete surplus faces and CtrlE > Bridge Edge Loops to repair the rim. Find or create a few edge loops round the outside skin, and Ctrl B bevel them to the width of the joints. With the new face rings selected, E extrude, right-click to cancel transform, AltS scale the extrusion along its normals.

Then you can add a Bevel modifier by angle (segments 2, profile 1.0) to sharpen edges, and add a Subdivision Surface modifier.. unless you just want to stick with low-poly, and Auto Smooth by angle in the slide's data panel.

Thank  you so much for this, but I must be missing a step between 2 and 3.  I press Alt+C and add the Solidify mod, but the mod says 'Faces need for useful output' and there arn't any faces.

If you're in 2.8, the 'convert to mesh' shortcut is not  Alt-C, but in the right-click menu on the object.. is that the problem? Have you succeeded in creating a mesh?

okay, after creating the spiral, and converting the mesh (by right clicking > convert to mesh), then using the solidify mod, I get this: https://pasteboard.co/I8yzOpS.png

@Chud37  Ahh.. Step 2 is what creates the tube.. that's done by giving the curve a bevel in its object data tab > Shape and Geometry panels. Shape: 3D, Fill>Full.. and Geometry: Bevel>Depth and Bevel>Resolution. I'll try to make the answer clearer.

Aah thanks, that's perfect, I got it now!


text:
Matching blender dimensions to paper cutout
I just discovered that you can export your blender model as a paper model, that you can later cut out.
https://blender.stackexchange.com/a/2353/75504
Github: https://github.com/addam/Export-Paper-Model-from-Blender
Home page: https://blenderartists.org/t/export-paper-model/476597
I tried it and for some reason no matter what I do the dimensions in blender don't match with the real model. Is there a way to deal with this, or do I have to just accept it?

I dont know why people are closing your Q, but would be better to change title. There is no issue with blender, but with specific blender addon.

There is an add-on for blender specifically for making paper models - https://blender.stackexchange.com/a/2353/75504 - Scroll down a bit for the github link for 2.8

@ChristopherBennett I think he is referring exactly to this addon

Maybe the reason of the problem was unapplied scale. Object mode > object selected > Ctrl+A > Scale. It can mess up measurements in Blender if unapplied, especially if it was uneven before applying (eg. 0.2 by X; 2.5 by Y axes)

@vklidu I voted to close re lacking detail and clarity, eg a link to the addon, perhaps description of an attempt and the expected result vs "real" result. and yeah the title.  Possibly harsh, flitter between commenting, editing and voting to close.

If this is about an add-on, can you change the title, or at least put an add-on tag?

@batFINGER you are right, just for a new contributor -I dont see notification to improve Q ... probably it cames after closing? Will check the system.

Will find noobs toe the line better if you beat them with the close stick.... (lol)  Most important IMO is the link, others who read this question who are interested  and henceforth desire to know more about paper folding can find the link to the addon  searching the comments above. .. and suggested edit to the question.  (Forgive me, it's late)

@batFINGER I agree, if Q wouldnt be asked better, close it :)

Sigh, edited.  Hopefully it is the addon in question 8^)-

@Duarte Farrajota Ramos - batFinger already added the details it seems to me improved enough. Isn't it?

Tried with a Cube and seems to be working.
But there is one thing that could be good to discuss with developer of this addon on Blenderartists

Cube

Object Dimension set 0.2 m
Object Scale is always better to have a 1 (Apply Scale Ctrl+A)

Addon

press Unfold
or select edges press Mark as Seam and press Unfold

Export (or skip for now)

Model Scale 1
Page Size 1 m

When export window popups go to options (right up gear icon)

it seems addon does not respect export setup from 3Dview
by default addon change scale automatically to fit A4 paper format

change scale to 1
if format is not enough for unfolded object it warns you

change paper format, addon will inform you if it is enough

emu (author) is going to care about mentioned functionality https://blenderartists.org/t/export-paper-model/476597/478?u=vklidu


text:
Operator bpy.ops.object.modifier_add.poll() failed, context is incorrect. How to apply modifiers to an .obj file?
I' m trying to add some modifiers to an imported .obj file but I have several issues. The code that I' m running is:
import bpy

#Element selection and removal
bpy.ops.object.select_all(action = "SELECT")
bpy.ops.object.delete(use_global = False)

#Model loading
full_path_to_file = "path"
Obj = bpy.ops.import_scene.obj(filepath=full_path_to_file)

def surface_refinement(Render,Vista):

    bpy.ops.object.modifier_add(type = 'SUBSURF')
    bpy.context.object.modifiers["Subdivision"].render_levels = Render
    bpy.context.object.modifiers["Subdivision"].levels = Vista
    #bpy.context.object.modifiers["Subdivision"].quality = 3
    bpy.ops.object.shade_smooth()

Render = 2
Vista = 1

surface_refinement(Render,Vista)

The error occurs at bpy.ops.object.modifier_add(type = 'SUBSURF')

Found an answer with an explanation for the error how-to-apply-all-the-modifiers-with-python. This is for applying the modifiers but should be easy to tweak it for adding modifiers also

Ditch the operators.
Operators return a set indicating the success {FINISHED} or failure {CANCELLED} of an operation.
There a chance that import has imported nothing (and after delete all active object is None) or that the current active object is not a mesh (a "subsurfable" type)
In which case there is no context object and poll will fail.
However test script below ditches all but the import obj operator.
Most importers (check first)  select newly created objects ie they are members of context.selected_objects after the operator has run. . Have added note about not adding code for deleting all objects to question code, really not that important either way but could be a bit sticky for  a new user tryings it out before realizing.  Thank goodness for undo... anyway I digress
How to add modifiers using python script and set parameters?
Using python to set object shading to 'smooth'
Here is test code, adds a subsurf modifier and smooth shading to all newly imported mesh objects.
import bpy

# FWIW Dislike this in question scripts
#
'''
bpy.ops.object.select_all(action = "SELECT")
bpy.ops.object.delete(use_global = False)
'''
# will deselect instead.

bpy.ops.object.select_all(action="DESELECT")
#Model loading
full_path_to_file = "foo.obj"

def surface_refinement(obs, render_levels, view_levels):
    for ob in obs:
        if not ob.type == 'MESH':
            continue
        ssm = ob.modifiers.new("SubbyO", type='SUBSURF')
        ssm.render_levels = render_levels
        ssm.levels = view_levels
        me = ob.data
        me.polygons.foreach_set("use_smooth", (True,) * len(me.polygons))

# test call
render = 2
view = 1
bpy.ops.import_scene.obj(filepath=full_path_to_file)

surface_refinement(bpy.context.selected_objects, render, view)


text:
Keyframe the ocean modifier time property
I'm using blender 2.8 and i'm just now starting to code in blender and i'm trying to set a keyframe to the Time value in ocean modifier using python
import bpy
bpy.ops.mesh.primitive_plane_add(size=2, enter_editmode=False, location=(0, 0, 0))
bpy.ops.object.modifier_add(type='OCEAN')
bpy.context.scene.frame_set(1)

Use keyframe_insert
Two things here,

Add modifiers with Object.modifiers.new(...) returns a reference to
the modifier
Add keyframes with keyframe_insert(datapath) method.  Set the value, insert the keyframe.

Test script
import bpy
context = bpy.context
bpy.ops.mesh.primitive_plane_add(size=2, location=(0, 0, 0))
ob = context.object
om = ob.modifiers.new(name="Ocean", type='OCEAN')
# (frame, time) pairs
data = ((1, 1.0),
        (10, 3.0),
        (100, 33.0),
        )
for f, t in data:
    om.time = t
    om.keyframe_insert("time", frame=f)

thanks it worked perfectly


text:
CMU bvh animations and rigging
I am wondering if i could get some tips from the wonderful people of this group. Does anybody have any experience working with CMU Mocap animation?
I am currently working with bvh files.
I have a rig already setup(rig assembled by a add-on called auto-rig pro) to which i am trying match the bones of my rig to the bvh. Auto rig pro has a remapping function for bvhs which I'm using but i get errors with this. The most common is twisted limbs and jittery animation.
I'm confused about the rotation of these bones and how to fix them of if i should use ik or fk when remapping.
Also I am researching how to fix the rest pose of the bvh armature, so that the mapping of the bones would result in a better animation but that lead to errors.
I tried using @batFINGER's script for resetting poses and all the post he did so far but I'm getting nowhere or at least i don' think I'm following it right.
Can anybody help? Thank you.

My link is for two rigs with  same bone structures. My bvh addon "mocap madness" which was basically targeted to CMU is a long way on the back burner.  Often addons (if hosted on github for example) have an issues page.  It appears the wrists may have a 90 degree roll. Consider posting a simplified blend to http://blend-exchange.giantcowfilms.com.  Include bvh rig, target rig and say 10 to 20 frames of an action where issue occurs.  Also, welcome to BSE. Upvoted (cos it's a good question, not just cos i got a mention  lol. (If I've used the wrong link please change)

Thanks for the reply. I changed the link because i was talking about the post for just changing the rest pose. the bvh and my rig have way different structures. i tried searching on the add-on’s github page to no avail. i can send you the blend but i don’t know how much info you will get because of the auto rig add-on. The add-on I’m using is basically like the mocap remap tool that you can find on the plugin page. Everytime i remap the bones the errors happen

Here is the blend file.

I have been wrestling with similar problems and I may start my own question, but in the spirit of cooperation and helping this is what I have found:

Rigify and Blender rigs do not work with CMU (without fixing the problems you mention)
Daz 3D rigs also import via FBX unreliably. The best way to get Daz characters into blender for animation is to bring them in via .dae (collada) and then exporting via obj or fbx and use mixamo for animations and for auto-rigging.
You can then retarget mixamo rigs using "bvh retargeter" to CMU - though not reliably. (https://diffeomorphic.blogspot.com/p/bvh-main.html)
N.B. you often get errors "rot & scale" when using bvh retargter. Do not use "transform rot and scale" - ONLY transform scale, otherwise you will get messed up results.
If using MB-LAb, it has it's own bvh importer and they work well with ACCAD bvh - but not so well with CMU. Do not use bvh retargeter.
If importing from MakeHuman, make sure to use the CMU skeleton.
Do not use FBX from MakeHuman to Blender, use the .mhx2 MakeHuman format and get the add-on for Blender for importing MakeHuman assets. You will get a perfectly compliant rig for CMU and BVH retargeter works perfectly with it.

Further notes;

The "rest pose" can look messed up, even though the "pose mode" works fine. I don't know why. In fact, avoid rest mode altogether unless someone else can bob and up tell us what it is useful for and when and why to use it.
Often the bvh's come with a T-pose at the beginning of the animation - it's best to use that, say for adding assets to a character.
"Daz Friendly" bvh's from cgspeed repository don't seem to work - in any configuration I can find, including with Daz 3d studio itself.
If you are struggling to parent an object to your character, you have to be in object mode with the armature in pose position then; object>select armature>switch to pose mode>select bone>parent to bone.

I hope this helps someone. I sure could have used this a week ago. It's a pretty convoluted situation.


text:
Control Cycles/Eevee material nodes and material properties using python?
How can I define the different properties of an Cycles/Eevee material? Such things as glossy, glass, diffuse, RGB-color, emissive via python scripting?

Here is how to change material properties, you can see all of them here or see the python path when you hover over in the UI on some material attribute:
    import bpy

    # get the material
    mat = bpy.data.materials['Material_Name']
    # change its parameters - example viewport diffuse color:
    mat.diffuse_color = (1,0,0)

Here is how to manipulate material nodes and thus the material look itself:

Get the nodes:
  import bpy

  # get the material
  mat = bpy.data.materials['Material_Name']
  # get the nodes
  mat.use_nodes = True
  nodes = mat.node_tree.nodes

  # get some specific node:
  # returns None if the node does not exist
  diffuse = nodes.get("Diffuse BSDF")

Create driver:
  # insert driver to roughness
  driver = diffuse.inputs[1].driver_add("default_value")
  var = driver.driver.variables.new()
  var.name = "variable"
  var.targets[0].data_path = "PATH"
  var.targets[0].id = "Target_Object_Name"
  driver.driver.expression = "variable"

  # remove driver
  diffuse.inputs[1].driver_remove("default_value")

Keyframes:
  # insert key frame to roughness at frame 10
  diffuse.inputs[1].keyframe_insert("default_value", frame=10)

Create nodes, here are all the node types you can create (look for subclasses):
  # remove specific node
  nodes.remove(diffuse)

  # clear all nodes to start clean
  nodes.clear()

  # create emission node
  node_emission = nodes.new(type='ShaderNodeEmission')
  node_emission.inputs[0].default_value = (0,1,0,1)  # green RGBA
  node_emission.inputs[1].default_value = 5.0 # strength
  node_emission.location = 0,0

  # create output node
  node_output = nodes.new(type='ShaderNodeOutputMaterial')
  node_output.location = 400,0

Link nodes:
  # link nodes
  links = mat.node_tree.links
  link = links.new(node_emission.outputs[0], node_output.inputs[0])

  # get specific link
  from_s = node_emission.outputs[0]
  to_s = node_output.inputs[0]
  link = next((l for l in links if l.from_socket == from_s and l.to_socket == to_s), None)

  # remove links
  links.remove(link)

As before hower over node atributes in UI to see the python paths

I have thousands of objects for which I need to update their materials' nodes/links using Blender's Python API. I am pretty new to nodes stuff in Cycles and I haven't been able to wrap my head around how I can do that. I wonder, could you please take a look at my question here and see if you can post a solution?

@Amir You need to know the names of the nodes you need to update. I added info how to get specific links to edit them. Now you should be able to put it together. You can try this on some easy example with just 2 nodes, then on your example. If you encounter something that doesn't work or you get stuck, let me know, I will help you further with what that is.

Thank you for your comment. I posted an answer to my question

Instead of node_emission.inputs[0] and node_emission.inputs[1], one can also write node_emission.inputs["Color"] and node_emission.inputs["Strength"], which could improve clarity.

If you right-click on any value in Blender, there's an option called 'Copy Data Path'. If you select this and paste the result you will get the Python command to change the value.

Here is a repo that does exactly what you want. It has a ready-to-run python script that can be run from the command line in the background without opening the blender GUI. It creates a water material on a surface mesh for a convecting bubble - this is done with 2 different shaders and mixing them using a mixer shader. The script loops through the different files and renders the images as jpeg. The images are also there in the repo. Just clone the repo and run the command given in the README file in the terminal. This scripting was done with Blender v2.78.
https://github.com/nataraj2/BlenderScripting


text:
Blender 2.9 - script how to add a material shader nodes tree?
In blender 2.9, I got a selected object and need to add a new material in a new slot with a script addon. I need some examples for doing a material shader nodes tree in 2.9
Ex: How to adding some nodes like diffuse - glossy mix shader, doing the links setting parameters etc.. may there are some web link to help with that  for 2.9?

Nothing changed really for 2.9... https://wiki.blender.org/wiki/Reference/Release_Notes

How to assign a new material to an object in the scene from Python?