text:
How to ask Python if a sensor is activated, BGE?
I am a total beginner with python combined with BGE.
I wrote that:
import bge

def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner

    if MessageSensor.positive or MouseSensor.positive:
        MessageActuator.activate

main()

it doesn't work, what's wrong?

To markup script for bse, using blender text editor: select all; hit tab (tabs all one right, the markup for code),; copy; then paste here.  Back in blender, shift tab tabs all back one right.

"It doesn't work" can mean anything from "it blows up my computer" to "I get this error message" to "nothing at all happens, it's as if my script isn't there". You'll have to be more specific and give actual details about what you expect to happen, why you expect that to happen, and what you're observing.

@batFINGER to markup code (after it is pasted in the post) select it all and press ctrl + K.

I strongly suggest to open the blender console before starting the game. It will show you all errors your code is getting.

Clearly  MessageSensor & MouseSensor & MessageActuator are undefined. And the controller is the one how activate de actuator.
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
MessageSensor = cont.sensors['NameOfSensor']
MouseSensor = cont.sensors['NameOfSensor']
MessageActuator = cont.actuators['NameOfActuator']

if MessageSensor.positive or MouseSensor.positive:
    cont.activate(MesageActuator)

You are accessing the sensors and actuators wrong. Assuming you have mouse senor named "Mouse" (the default name), a message sensor named "Message", and a a message actuator named "Message" all on the same object the corrected code below will work.
cont = bge.logic.getCurrentController()

if cont.sensors['Message'].positive or cont.sensors['Mouse'].positive:
    cont.activate(cont.actuators['Message'])

You access the the object that everything is on with bge.logic.getCurrentController() then the sensors, controllers, and actuators are all in their own lists. You simply specify them by name, or position.
You really should look through the Docs for bge.logic (all the logic bricks are in the logic section.)

But I have to ask why do you need that? If all you need is to activate an actuator when either senor is true, then just use an Or controller.

It is true that it is possible to do with the elements integrated in the game logic editor, but I'd like to start learning to do things with python to create more complex things later on, so I'd like to use python. But thank you for your answer.


text:
Only part of the object is being scaled
I'm trying to shrink a specific section of my design, which originally, I made like this:

When I use the shrink tool, I get this:

But from what I can tell when I open CURA, it's almost like I'm shrinking the inside and not the entire stem of the object? It looks like there's still an outside layer of the stem that isn't being shrunk, and I'm not sure what I'm doing wrong.

It looks like you don't have all of the vertices in the stem of the glass selected. You may have "Limit Selection to Visible" turned on.

Doesn't look like the "limit selection to visible" box is checked, from what I can tell.

It looks like you don't have all of the vertices in the stem of the glass selected.

Did you really have to resort to CURA to see that you had (selected and thus) scaled only a part of the intended vertices...?!? it seems quite evident in the picture...

As pointed out int he comments above, you don't have the entire stem of the glass selected. To select it all, press Z to enable wireframe view. This will let you select through the mesh as well, not just what you can see. Then use the box select tool with B to select everything you want. Change back to solid view again with Z and the scaling will work as you expected.

source: Stack Exchange

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

sort: votes


text:
Fold a plane. then fold again
Imagine a piece of paper and you fold it in half and then fold it again. that's what I am trying to do and cant. If I use bones the influence of the bones won't allow me to because I need 2 bones to control the same area. If I try shape keys it just deforms the mesh if I try to make it in multiple steps or does the wrong animation because it draws the shortest path instead of rotating from a point like a piece of paper would.

Hinge bone armature.
In the second part of this answer I wrote a script to make an armature, can be used here
import bpy
from mathutils import Matrix, Vector
from mathutils.geometry import intersect_point_line
import bmesh
context = bpy.context

def hinge(armob, ob, pb, face):
    arm = armob.data
    # add a bone from edge center to face center
    face.select_set(True)
    edges = [(l, f) for l in face.loops for f in l.edge.link_faces if not f.select]

    for l, f in edges:
        e = l.edge
        b = arm.edit_bones.new(f"Hinge_{f.index}")
        b.parent = pb
        pt, dist = intersect_point_line(
                f.calc_center_median(),
                e.verts[1].co,
                e.verts[0].co,
                )
        b.head = pt
        b.tail = f.calc_center_median()
        vg = (
                ob.vertex_groups.get(b.name) or
                ob.vertex_groups.new(name=b.name)
                )
        vg.add([v.index for v in f.verts], 1, 'ADD')
        hinge(armob, ob, b, f)

def make_armature(ob, face_index):
    me = ob.data
    bm = bmesh.from_edit_mesh(me).copy()

    face = bm.faces.active
    bpy.ops.object.mode_set(mode='OBJECT')
    bpy.ops.object.armature_add()
    arm = context.object

    mw = (
            ob.parent.matrix_world.copy() if ob.parent
            else ob.matrix_world.copy()
        )

    ob.matrix_parent_inverse.identity()
    #ob.matrix_world.identity()
    ob.parent = arm
    ob.matrix_parent_inverse = ob.matrix_world.inverted()
    ob.vertex_groups.clear()

    arm.matrix_world = ob.matrix_world
    bpy.ops.object.mode_set(mode='EDIT')
    b = arm.data.edit_bones[0]
    b.tail += face.calc_center_median()
    b.head += face.calc_center_median()
    hinge(arm, ob, b, face)

    bpy.ops.object.mode_set(mode='OBJECT')
    for pb in arm.pose.bones[1:]:

        pb.rotation_mode = 'AXIS_ANGLE'
        pb.rotation_axis_angle = (0, 1, 0, 0)
    ob.modifiers.clear()
    mod = ob.modifiers.new(
            "Hinger",
            type='ARMATURE',
            )
    mod.object = arm
    bpy.ops.object.mode_set(mode='POSE')
make_armature(context.object, 0)

With the mesh in edit mode, select one face, Run the script, creates an armature, with root bone at that face.

Now with the armature in pose mode Shift select the two bones going same way to fold. Can Alt change the property of one to change same property  all selected. Type in 180 to fold in half.

Now the slightly tricky bit because the script wasn't designed to do this... Shift select the two bones going the other way. Change the axis of one by negating the X axis (1 -> -1) this will ensure both spin the same way for this fold. (Alternately one to 180 and one to -180 degrees, will do same.)
Now same as before press  Alt and change the angle, and rotate to 180.

Holly shit this is amazing. It works so well I am about to cry. thanks, man. I had to do another fold and it worked by changing to -1 also this great!!

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


text:
"Shadow" showing on vertices of model
There's a shadow showing in vertices, how can I make this disappear?
Seems like something is wrong with the model.

"Seems like something is wrong with the model." Your topology. There is a huge ngon, Blender can't fill it properly.

i dont understand why..
blender fill properly when all the vertices was with 0 on Z cordinates.. but after when i chance the Z cordinates of some vertices this happen..
Sorry, im beginner

Ngons only work when vertices on the same plane. If the vertices is not in a plane, it will be very difficult to determined your face by simple algorithm

In order to display n-gons they need to be triangulated because video cards draw triangles only to simplify calculations. When the n-gon is automatically triangulated it so happens that there is an edge where you see the 'shadow' that's why it is visible there and that is why your solution works - it includes triangulation without any edges going from one side to another.

Now i get it, thanks man

hey guy i use ALT + F to fill and works better

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


text:
Emission Pass bug while creating an automation script for PBR bake passes
I am a newbie to scripting and coding in general so this might be a stupid question. I am trying to design an automation script for SimpleBakes addon to automatically select the necessary PBR bake passes for an object based on the properties of Principled BSDF as it iterates through each material of the object.
This includes:

Turning on metallic pass if the metalic value of Principled BSDF is anything other than 0.
Turning on Transparency pass if the transmission value of Principled BSDF is anything other than 0.
turning on the Emission pass if the Emission color of Principled BSDF is anything other than black (0, 0, 0, 1) [[ This is where my issue arises]]
turning on the Alpha pass if the alpha value of Principled BSDF is anything other than 1.

here is my script in it's entirety:
import bpy

m=0
bpy.context.scene.selected_col = True
bpy.context.scene.selected_rough = True
bpy.context.scene.selected_normal = True
bpy.context.scene.selected_metal = False
bpy.context.scene.selected_trans = False
bpy.context.scene.selected_emission = False
bpy.context.scene.selected_alpha = False

for m in bpy.context.object.material_slots:

    if m.material.node_tree.nodes["Principled BSDF"].inputs[4].default_value != 0:
            bpy.context.scene.selected_metal = True

    if m.material.node_tree.nodes["Principled BSDF"].inputs[15].default_value != 0:
            bpy.context.scene.selected_trans = True

    if m.material.node_tree.nodes["Principled BSDF"].inputs[17].default_value != [0, 0, 0, 1]:
            bpy.context.scene.selected_emission = True

    if m.material.node_tree.nodes["Principled BSDF"].inputs[19].default_value != 1:
            bpy.context.scene.selected_alpha = True

As you can see in the script, all these passes should be False by default at the beginning of the script. The issue I am facing is the emission pass keeps turning on for each and every object regardless of whether it has an emissive material. it is as if all the objects have their emission colors set to values other than black which is very much not the case.
Why is this issue arising, have I mistyped the syntax for activating on colors other than black? Any help regarding this would be greatly appreciated.


text:
What is wrong with my viewport?
I just installed Blender 3.5 and my viewport is completely wrong.
I can't find anything similar to my issue anywhere.
I've installed AMD ProRender plugin.

.

Not sure if it's a hardware issue either.

*GPU Radeon RX550/550 Series
Discrete VRAM 4096 MB
GDDR5 1500 MHz Graphics
Radeon RX550/550 Series GPU
Radeon RX550/550 Series Discrete
VRAM 4096 MB GDDR5 1500 MHz
Driver Version 22.20.27.09-230330a-390451C
AMD Windows Driver Version 31.0.12044.3
Direct3D API Version 12.0
Vulkan™ API Version 1.3.217
OpenCL™ API Version 2.0
OpenGL® API Version Not Available
Direct3D® Driver Version 9.14.10.01523
Vulkan™ Driver Version 2.0.233
OpenCL® Driver Version 31.0.12027.9001
OpenGL® Driver Version 23.03.220823_1f70af4
Windows Edition Windows 10 Professional (64 bit)
Windows Version 21H2*

Thanks

Try adding another layout in the top
press the + button next to scripting
general
layout
check if it works


text:
Glitches / Artifacts appear when animating model
I have this character that I need to animate for a major project but I get these errors as I move around the bones. Wondering why this is happening and if there is a fix. Thanks

The mesh looks very dense because of these artifacts. Is this a sculpted character model? How have you weight-painted it?

Yes, it is sculpted and is a quite dense model. though it has far fewer vertices than it once had because of another error. Most bones in the model are paired via automatic weights.

Have you considered a retopology? A low-poly mesh gives you better performance and deformation, and it's easier to texture and weight-paint.

This look like your bone weights are going abruptly from 1 to 0 so the vertices are sheared at the interface


text:
Product modeling
This is Smit from India. I am stuck somewhere while modeling a product. It is not so complex but I am new in Blender so I am finding difficulties rn. Looking forward to having a solution.
Product description:
It is a cube with round edges.
It's length, width and height are different (not much difference).
It is a little broad from the bottom (/_\ kinda look like this).
It has 3 holes on the sides. Headphone jack, type C and a hole for button.
Major issue:
Somewhat dense mesh.
Boolean cutting.
Clamps in cycle render.
Confused with subd modeling.
I haven't make it using subd modeling and the mesh has become slightly complex but when I tried subd modeling method, I couldn't make it. Found the above issues.
Thanks.

Sorry but this is not a tutorial site and you should only ask about one issue for each question. You haven't given any details of how you got to the stage you are at or what problems you are actually having. Read https://blender.stackexchange.com/help/how-to-ask and try again.

Hi Please use a title that reflects the content of the question. It should be descriptive but succinct, unique and identifying, summarizing the issue so that users can at a glance understand what your post is about. Use the [edit] link below your post and avoid anything not strictly essential to the post. Remember, your title is the first thing potential visitors will see, and makes your question findable for future users. See "What is the problem with posting an image or link and asking “How do I do this?""

It might be helpful to people trying to help you if you uploaded an example blend file to the site https://blend-exchange.com and add that link in the question.


text:
Material Animation vs Motion Animation
I am working with 30-50 objects which have significant motion keyframing as well as even more significant color keyframing unique to each object. A lot is trial and error on the color keyframing so I am frequently undoing or removing a portion of the scripting I use to keyframe the colors. The problem I am having is that I cannot distinguish the motion from the material keyframing in the timeline or dopesheet. There must be a way to filter either of these pages so that you're only looking at the material keyframes yes? Help appreciated - Thanks!

Have you tried using the channels' searchbar?

Admittedly I don't understand channels but I tried to see if the search filter would allow me to differentiate motion versus material keyframes on the same objects and I can seem to do that. When I search, the results aren't really what I would expect. Seems like I may be missing something obvious as I would think this is a necessary feature for complex projects.

Here is an example of two objects, with each a different material with different keyed properties:

You have different ways to isolate keys or curves.
Selection
By default, the option "Only Show Selected" should be ON:

With this option, only the keyframes/curves from the selected object or element will be visible in the corresponding animation editor. You can find this option in the dopesheet and curve editors, but not in the timeline.
For material nodes, you need to first select the object containing the material, then select the specific node in the shader editor.
Keys and curves can be easily messy if you disable that option. And it is the primary way to filter your animation editors.
But, when working on multiple objects, or on objects and materials simultaneously, it might be interesting to disable that option.
Channel options
Each channel (and sometimes their groups/parents) have some options available:

Five icons, five effects:

Pin: Toggle keeping the channel displayed regardless of header filters (like selection). You also need to toggle it on the parent channels, if applicable.
Eye: Toggle the channel's keys/curves visibility in the editor
Wrench: Toggle the channel's curve modifiers
Checkbox: Toggle the channel's animation's effect (like a mute)
Lock: Toggle the editability of the channel.

You can click each individual icon one by one, or use some operators that can toggle, activate or deactivate them, even when multiple are selected.
You can find these operators in the Channel menu, with their associated keyboard shortcuts:

Channel search
The channel search bar allows you to search for words contained in channels, but not channel groups, not objects.
Notice for example that all the channels from a shader property have the name of the property and of the node between parentheses. While objects' transform channels don't.
That means you can isolate a specific name of shader property, of shader node, or even all shader properties with just a parenthesis:

Custom channel groups
As mentioned above, some channel groups do have their own channel options, but some don't:

But you can make your own custom channel groups, which will have the same options. Select some channels, for example your shader properties neatly filtered with the search bar, and use the menu Channel > Group Channels or hit ⎈ CtrlG:

Channels will not change parents if not custom. But it still helps.


text:
How can I save animations for reuse later?
I have my character all rigged up and I made a basic walk cycle. Now it's time to animate the character climbing a short cliff face. After that he'll walk a short distance, jump and fly away.
Is there a way to save animations for later reuse, similar to the pose library? That would allow me to do the walk animation once, save it, then reuse it after the character climbs the cliff. Or do I need to animate the walk twice? What if I want this character to have the same walk again in another scene?

one possibility is to export it as e.g. fbx file or any other format which can handle animations.

have you looked into the NLA Editor?

You can use the Asset Browser to store and import actions. Even though for now the way to do it isn't as handy as it could be ; you can't just  RMB > save an animation into a new file, and importing the animation to a scene isn't just a simple drag'n'drop like other assets.
I will use one of my projects as examples:

Two characters with each an armature, and a prop with an armature.
Saving the animation
In Blender, animations are stored in "actions" data-blocks, these are what we can save and import later. Think of it as a video clip containing your keyframes.
You can see them in the Dopesheet editor set to Action Editor Mode:

Or in the Outliner set to Blender File Display Mode:

It has some caveats to be aware of:

Actions store only keyframes
For now (it's planned to be changed in the future releases of Blender), each object animation is stored in a different action, and each object's data level is also stored in a different action. Which means in our case:

Animating an armature object and animating its bones will give you two different actions.
I have three armatures: Snow, Rain and the glass, that's three actions to store.
The glass root bone is constrained to the Snow's hand bone, I have to bake that constraint into keyframes (menu Pose > Animation > Bake Action, Enable Visual Keying and Clear Constraints.
If you make use of Custom Properties in your animation, they have to be created on the bones in the armature, not on the armature object.

Mark asset libraries
For now, marking actions as asset will not allow us to import them as actions, they can only be used for poses. We need to save the armature object instead.
Go in the outliner,  RMB the armature > Mark as Asset:

You know it worked because of the asset library icon added to the action data-block:

You can select multiple armatures and mark them as assets in one go.
You should also already be able to see that asset in the Asset Browser.

You could stop here, but you might instead want to save this externally.
Save as external files
You don't have to do that, but it's a common workflow to store only the strict minimum data you can in a different file: lightweight, less prone to data loss, easy to update.
For this, we can use the addon io_export_blend to save the asset externally:

↹ Tab into Object Mode
Select the armature
Menu File > Export > Blender (.blend) or  RMB the armature in the outliner > Export to .blend
Save your file with a nice name somewhere in your Asset Libraries

Once this is done, you can open the Asset Browser and go in the Unassigned catalog, you should see that action twice, one with the "current file" icon on it because it's in the current file, one without that icon because it's the one we exported to another file.

From there, since we saved the action externally, you can un-mark it as asset from the current file using  RMB > Clear Asset:

Good to know: if you use this addon, there is an option to mark as asset while you select the destination:

So you could in theory skip the asset marking-unmarkin and use that option instead.
Importing the animation
Drag the asset from the browser to the viewport, it should append/link (according to your preferences) the armature with the action.
Select the armature you want to import the action into, and in the Action Editor, select the action you imported in the Actions list:

Toggle on the shield icon next to the animation name. That gives it a "fake user" so it won't disappear when you close blender.
I used to create a cube to hold attributes I didn't want to disappear. I think many people did that and that may be why the toggle is called fake user. Just a guess :)


text:
How to export models without losing precision?
In Blender a coordinate might be 1.5. When exporting the model to Houdini, that coordinate becomes 1.500001. This is not consistent either, even with seemingly perfectly rounded coordinates using the Python script below in Blender, some coordinates still lose their precision when exported, which is breaking a Boolean operation in Houdini.
This does mostly work, but would not round 1.50001 to 1.5, for example:
import bpy

for c, obj in enumerate(bpy.context.selected_objects):
    for vert in obj.data.vertices:
        vert.co.x = round(vert.co.x, 1)
        vert.co.y = round(vert.co.y, 1)
        vert.co.z = round(vert.co.z, 1)

Interestingly, if I go through and manually re-input the coordinate, the precision is no longer lost. Blender is often displaying the coordinate at 1.50000, but internally it is 1.500001.
This is particularly problematic when using an array modifier, because apparently Blender can't keep adding 2 and it just needs to add an extra 0.000001 for no reason.
The boolean operation in Houdini is used to optimise meshes, and this precision error is causing them to be 10-20% larger than they otherwise should be.
I can't do the rounding in Houdini because some of the vertices aren't necessarily snapped to the grid.
Edit: Added a partial solution by rounding all vertices to the 5th decimal place in Houdini. This loses some precision, but arguably that is simply a degree of imprecision Blender adds but does not display anyway. Not sure if it will become a problem later. Here is the vex code that was placed in a point wrangle node:
@P = rint(@P*100000)/100000;


text:
Trying to get the right orientation matrix
So i'm using a importer that uses a matrix and changes the transform and when i try and import with my keyframe data the arms and legs are like backwards? Crossed not sure how to explain it. So i'm trying to see if i got the orientation right of this matrix. EDIT: This is coming from a
D3DXMATRIX
    correct_orientation = mathutils.Matrix([[1.0, 0.0, 0.0, 0.0], #left/right
                                        [0.0, 0.0, 1.0, 0.0], #front/back
                                        [0.0, 1.0, 0.0, 0.0], #up/down
                                        [0.0, 0.0, 0.0, -1.0]]) #flip inside/out?
armature.transform(correct_orientation)
mesh.transform(correct_orientation)

Please consider adding more info, eg images of rest pose, a pose bone and its transforms & what they "should" be ,.... as , It's hard to get a read on this from  information given. My guess is possibly require something like https://blender.stackexchange.com/questions/50101/swap-two-curves-in-the-graph-editor/50136#50136  since the axes have been changed. (and possible the sign for any axes axes that are inverted) .


text:
Can nodes use an objects x/y position?
I have a blender file where a sphere is orbiting a force field. I want it to be more red when it's closer to the center, and more blue when it's further. I already have the math figured out, I just need to know how to get x/y coordinates in nodes.
Here's the file:

You probably want to look into drivers. I think they can be used as input to node fields... but maybe not. If so, a driver would likely be your best bet.

@Matt What do you mean by drivers?

https://www.blender.org/manual/es/animation/drivers.html

Use the object info node connected to a separate xyz node:

authors: Магомед Магомедов

authors: Рустам Салихов

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


text:
Simple UV unwrap with unexpected results - 2.78
Pretty simple UV unwrap, not anything I'd consider complex but for the life of me I cannot understand the results. I have prepared a file with just the object in the state of unwrap - hopefully someone can figure out what I could have done? Not sure this is related to 2.78 but that is what I am using.
All doubles have been removed - just by the way, and scale was applied.

You have your vertices of the Uv Island pinned. Select the island with A in Uv Editor and press Alt+P or go to Uvs-->Unpin to unpin it. Then unwrap it (U-->Unwrap) and it's gona look fine.

Thanks Paul - not sure how or why I pinned all my verts, but glad you helped!

In my experience, this happens from time to time, mostly if you have "unusual" (from Blender's point of view) topology like the area where the trouser legs are turned up.
Just delete your UV map in Properties - Data - UV Maps, then try UV unwrap again.

Thanks Duarte - that's a helpful tip for next time I mess up!

authors: Анастасия Билибина


text:
Advice on how to approach scene involving zooming down to atomic scale?
The animation I'm planning involves zooming in on a stainless steel ruler all the way down to the atomic structure in a single shot which would involve passing through the following levels of detail:

Shiny brushed stainless steel ruler with numbers and markings as additional texture (photo realistic).
Etched depressions that make up the markings.
Scratches / pitting that make up the brushed texture.
Grain boundaries* (see note below).
Packing of atoms within the crystal grain.
Individual atom within a crystal grain (fuzzy ball of questions & confusion).

*note: steel at the atomic level consists of grains of crystal clumped together where the atoms that make up each grain are arranged in an orderly matrix, the grain boundaries are where the axis of the different grains don't line up.
So my question is what plugins and techniques can people suggest to accomplish this as painlessly as possible.
I'm thinking I may be able to approach it by modelling a large enough patch at each detail level to just fill up the camera and then somehow stealthily transition between the texture at the larger level and the detailed model at each stage as the magnification increases.
Alternately via the python API generating a dynamic texture dependent on the current zoom level of the camera something like a fractal texture [just spit-balling here - haven't even looked at the API yet].

related (context) : Powers of Ten by Charles & Ray Eames https://www.youtube.com/watch?v=0fKBhvDjuy0 one of the biggest zooms ever :)

Render static (or animated) images and composite them exactly like this: http://www.videocopilot.net/tutorials/earth_zoom/ its explained how. You can do this also inside Blender.

The problem won't real be the textures, but the camera clipping; increasing these won't really work, as there tend to be artifacts.

You will have to blend two shots together. Its most likely impossible to get the geometric level of detail at the atomic scale that will work for a macro shot. I would model the scene with the ruler, with some textures etc.
Then add some procedural textures for pits, scratches, etc. That way we can continue to zoom in without becoming pixellated.
Next model a completely different scene that is molecular in scale and have a zoom animation in both scenes that match up. Once your first scene gets close enough, start blending into the second screen. You could use the compositor, or maybe just a plane in scene 2 that has a texture of the rendered video from scene 1. As you get close in on scene 2, adjust the transparency of that image plane.
Good luck!

You could try changing the clipping on the camera object so that the bounds are very large, allowing for it to see things very far away AND close up, and making the whole ruler extremely large. You could also change the lens length of the camera with keyframes, to add to the zooming effect.
EDIT: This is a very hacky and clunky solution; see below.

That won't really work as bigger clipping ranges tend to generate more artifacts.

@cegaton maybe that can be solved by setting keyframes on clipping values?


text:
What is the difference between Unwrap and Smart uv project?
I'm trying to baking my high poly onto my low poly mesh. Should i use Unwrap or Smart uv project?
What's the difference between them??

"Unwrap" is when Blender will determine where each and every face should be located on your UV Image Editor, For example, If I were to unwrap an entire cube or sphere, it would look something like this:
As you can see, all of the faces of this sphere are stacked upon one another, fitting the entire frame of each face with the texture. But all of this can be solved if you Mark Seams on your object.
Smart UV Unwrap is when if you were to chose this option, you would be given 4 options to change and edit the way blender is going to analyze your mesh unwrapping;Angle Limit, Island Margin, Area weight, and Correct Aspect. You can tweak these options to see what you would prefer most and what you like best.
Ex.
In my opinion, I would go for the "Unwrap" because if you "Mark Seams" you can control the way blender unwraps your mesh in a much easier way instead of having to work with all those options in "Smart UV Unwrap."

Both options unwrap your mesh (creating 2-dimensional UV mapping coordinates for it).  In short: the Unwrap option is manual, while Smart UV Project attempts to automatically unwrap your mesh for you.
Unwrap [manual]

When you choose the Unwrap option in the UV Mapping (U) menu, Blender will attempt to unwrap the mesh splitting it using only seams you have already marked (with Ctrl+E > Mark Seam).  This gives you exact control over the pelt's graph.  You can then use the F6 operator menu (also found at the bottom of the left T toolbar) to adjust some settings relating to the exact shape of the pelt.
Smart UV Project

Smart UV Project is an automatic method of unwrapping a mesh.  If you choose this option Blender will try to automatically place new seams (it won't actually mark them on the mesh) and unwrap the mesh.  You can adjust the Angle Limit in the operator menu to try to minimize distortion.  Smart UV Project will also use any seams you have already marked on the mesh in addition to its own.
While Smart UV Project is quite a bit easier than UV unwrapping, it's automatic nature often produces less satisfactory results than manual UV unwrapping.


text:
Can I invert the Green channel of a Normal map in Blender?
Is it possible to invert the green channel for a normal map directly on Blender (without using nodes)? I'm exporting a mesh from blender to unity and the normal i imported gives me problem of color.


text:
How can i improve the quality of my baking?
This is my low poly hand

and this is my high poly hand

I bake the high poly onto the low poly with uv SAMRT PROJECT and this is the result

Now this is very bad i think . . . i would like to understand if this bad results depends on

it's my low poly too bad? Maybe should be more similar to the shape of high     poly?
it's my normal map? Maybe with the unwrap and mark seam could be better?
This is my normal map

it's my a problem of settings?
For the bake i used this one

EDIT
After UV SMART PROJECT and BAKING i did these steps:
I add new material and i don't change anything here so settings are

then i go in texture i click on new texture and then i add the image of the baking like that with these settings.

In the end in order to see the render i go on object mode - shading - GLSL then i use Ctrl + z

What is the size of your image that you are baking to? I think you should try doubling this, and try baking again. (eg. 800x600 > 1600x1200).

What are the settings of normal map assigning to the model ?

Im using 1024 * 1024 @Rick Riggs

Mr Zac you wanna know the settings of PNG normal map file?

I personally would lean toward focusing on my UV map & Seams (Which I think you already feel is the right answer). One variation to this though from my humble opinion, is that I would try to take it limb by limb, in terms of creating & mapping separate objects (also split front and back - You don't have to physically separate you can use vert groups). This would allow you to do most of your work through visual alignment in the viewport, then project from view. The reason for also splitting the limb front and back, would be so you don't project the top of your hand to the palm, etc...

Mr Zak I edit the question! I hope it's  clear and what you asked me

Yes now it is. The one problem which I can see is with mesh - its topology. It's not good in several areas, e.g. between fingers, between big finger and arm, probably not everything is visible. There are non-planar faces, ngons etc, which will lead to bad shading of mesh. Another thing - to increase amount of normal map effect increase Bias a bit

Thank you very much!!!! If i could ask you the last thing, how much should i increase Bias? From 0.001 to?
I know there isn't the perfect value but i really don't know how could works the change. Thank you again i really appreciate your effort!!


text:
How to remove certain part of the object name for hundreds of objects?
I am new to scripting and trying to find a way to remove the marketing_ prefix from a few hundred objects in one go. I can get the script below to work fine one the active objects but I cant figure out how to apply it to all objects in the scene or all selected objects.
import bpy
bpy.context.object.name = bpy.context.object.name.replace("marketing_", "")

How to do that for multiple objects? Any help is greatly appreciated.

For selected objects:
import bpy

for o in bpy.context.selected_objects:
    o.name = o.name.replace("marketing_", "")

Or for all objects in the scene:
for o in bpy.context.scene.objects:
    o.name = o.name.replace("marketing_", "")

Or for all objects in the file:
for o in bpy.data.objects:
    ...

Link to the docs: https://docs.python.org/3.7/library/stdtypes.html#str.replace

All objects in scene use  either [o for o in scene.objects] or [o for o in scene.collection.all_objects]

That works a treat Martin, thank you so much!


text:
Render image and mesurements?
Trying to figure out how I can get the mesurment tool in blender 2.8 to render with my image?

Blender 2.8 comes with a plugin pre-installed called MeasureIt. This allows adding Measurement notations as scene data.  You can then render the annotations separately and composite them back in. In order to get your measurements rendered, all you would have to do is:

Click on the Render button in the Render panel which is going to render your measurements as a separate image based on the active camera
Open up a new Compositor window or just switch the workspace to Compositing, add an Image as well as an Alpha Over node
Set the image for Image node to generated image by the MeasureIt add-on
Plug your rendering into the upper socket and the generated image into the background (lower) socket of the Alpha Over node

Note: MeasureIt is a large and complicated tool, some research is required. I'd suggest have a look into the manual: https://docs.blender.org/manual/en/latest/addons/3d_view/measureit.html or watch some time consuming youtube tutorials.

Kirbinator's solution is good! Solved my same question.


text:
Does Blender allow encoding to .webm?
I'm trying to export a mp4 video as a .webm, but the render animation does literally nothing.
Can someone tell me what I'm doing wrong or whether it's even possible to export as .webm?

Blender 2.81 has, or so the manual says, webm as an FFmpeg container.

Update 2
Lukasz-40sth is right Blender 2.81 has a WEBM container which eliminates all the previous issues. It also supports the Opus audio codec. These features were added by Dr. Sybren Stüvel based on FFmpeg which implements the container and codecs.

Update
While the output described in the configuration below does output a video that is playable by all major browsers, it doesn't follow the guidelines for WEBM. For instance the WEBM Container Guidlines specify that:

DocType element SHOULD be "webm"

However Blender's output has DocType set to matroska when using the Matroska container. I assume that SHOULD in this context refers to the meaning specified in RFC 2119, it's recommended but not a must. The file should therefore still be a valid WEBM.

Disclaimer: I'm not very familiar with video container formats, the following information may be inaccurate.
Blender 2.80 doesn't have a dedicated WEBM container, however WEBM is a subset of the Matroska container format that only allows a specific set of audio and video codecs. Therefore you should be able to produce a valid WEBM with the following settings:

Container   : Matroska
Video Codec : WEBM / VP9
Audio Codec : Vorbis

The output file will have the .mkv extension which you can rename to .webm.

When you have created your video in the VSE and then use Render Animation to export the video, it will be stored in the directory that is specified in the Output panel (for example in the screenshot it's /temp). Make sure that you're checking in the correct directory.


text:
How to add a custom menu item to the object menu?
Following code adds wm.save_homefile operator to the Render menu.
import bpy

def menu_draw(self, context):
    self.layout.operator("wm.save_homefile")

bpy.types.TOPBAR_MT_render.append(menu_draw)

Q: How can I add this operator to Object menu of the 3d View?

@batFINGER thanks for edit, but you don't help me, as i said, i really bad to make question, and my english is the worst,  we know that...

@batFINGER agradezco tus correcciones, pero realmente no me ayudan en nada, como dije anteriormente soy muy malo para hacer preguntas, y mi ingles es el peor, eso ya lo sabemos..

Related: How to add a custom object entry to the add menu?

Following code adds the open file operator and a label to three different places:
import bpy

def custom_draw(self, context):
    self.layout.operator("wm.open_mainfile")
    self.layout.label(text="Hello world!", icon='WORLD_DATA')

bpy.types.VIEW3D_MT_object.append(custom_draw) # Object menu
bpy.types.VIEW3D_MT_snap.append(custom_draw)   # Snap menu
bpy.types.TOPBAR_MT_render.append(custom_draw) # Render menu

https://docs.blender.org/api/current/bpy.types.Menu.html?highlight=prepend#extending-menus

I think it is time for the administrator, moderators and experienced people to review the way in which the forum works with the new members. There are almost 20,000 unanswered questions (mine for example), I understand that many are not "relevant", so I suggest integrating them in one place maybe "Top 100 Stupid (but necessary) question of blender's beginners).It is not my intention to disturb anyone, I simply try to contribute to the community and its smooth operation

What is the issue here?.  Is it instead of searching to find an answer,  as you've done, it should be answered  ASAP?  Please edit this answer to include relevant links and code formatting.

Did the formatting and added links to the docs so you have a starting point on how to do that: https://blender.stackexchange.com/help/how-to-answer

I still think that the BSE team has lost sight of a very important fact: BLENDER is a wonderful but very complex program. You can see some of your own answers from a few years ago and you will notice what I mean (I hope so). Things as basic as the button tooltips are absurdly hidden even in the manual, I only got to them after reading a lot of questions and answers. Anyway, thanks again for your attention

Nope, I don't get your point. Also, there is no "BSE Team", this site is driven by volunteers helping others in their spare time... Indeed Blender is a complex tool -> even more important to ask a clear and precise question in order to get help from others quickly  (see my edits, you're welcome btw.). I suggest, take your time, try to understand: https://blender.stackexchange.com/help/how-to-ask, show some effort and research and you'll most likely get an answer. Also if you have any concerns about this site, I suggest ask a question on meta: https://blender.meta.stackexchange.com/


text:
Where did the UV stretch option go in 2.9+?
I'm trying to look for it, older 2.8 posts show its on the Display side panel but it's not there anymore, does anyone know where it is?

It's an overlay.
2.8 series introduced the concept of Overlays, which are all the things that are drawn on top of your mesh in the 3D view or the UVs in the UV editor.
From the manual:

The Overlays pop-over configures the overlays that are displayed on
top of images. In the header, there is a button to turn off all
overlays for the UV Editor. This option also toggles the visibility of
UDIMs tile information. The options that are visible in the pop-over
depend on the UV Editor mode.

Stretch falls into this category.

Thank you, this solves my problem!

Thanks! I needed exactly this!


text:
How to create an empty per object in selection?
How can I create an empty / null / locator object using python? I'd like to create one for each selected object and then all empties should be parented or constraint to the selected objects, meaning that the rotation and position should be copied over as well.
I tried something along these lines but I can't get it to work properly:
import bpy

for obj in bpy.context.selected_objects:
    bpy.ops.object.empty_add()

Q: How to create an empty per object in selection?

Pull down the hidden window at the top of Blender and watch the Python it writes as you do the actions. Update your question with how far you get.

Related: https://blender.stackexchange.com/questions/202509/assigning-an-empty-parent-object/202546#202546

Update for 2.8 +
import bpy

for obj in bpy.context.selected_objects:  # Loop over all selected objects
    empty = bpy.data.objects.new(obj.name + "_Empty", None)  # Create new empty object
    obj.users_collection[0].objects.link(empty)  # Link empty to the current object's collection
    empty.empty_display_type = 'PLAIN_AXES'
    empty.parent = obj

If you want the empties to be the parents :
import bpy

for obj in bpy.context.selected_objects:  # Loop over all selected objects
    empty = bpy.data.objects.new(obj.name + "_Empty", None)  # Create new empty object
    obj.users_collection[0].objects.link(empty)  # Link empty to the current object's collection
    empty.empty_display_type = 'PLAIN_AXES'
    empty.location = obj.location
    obj.parent = empty
    obj.location = (0, 0, 0)

This is great but how can I parent the objects to the empties instead?

I think you forgot to add the transforms @Gorgious ... which is part of the question (even before I made the edit).

@brockmann Thanks, indeed if the empties are the parents the transforms aren't inherited automatically. Updated the answer

bpy.ops.object.empty_add()
You can call bpy.ops.object.empty_add() operator per object and pass the location, rotation and scale for each object as well:
Blender 2.8+
import bpy

for obj in bpy.context.selected_objects:
    # Create the empty using the operator
    bpy.ops.object.empty_add(type='PLAIN_AXES', location=obj.location)
    # Get the newly created empty
    empty = bpy.context.view_layer.objects.active
    # Set the size
    empty.empty_display_size = 20
    # Parent the object to the empty
    obj.parent = empty

Blender 2.7x
import bpy

selected_objs = bpy.context.selected_objects
for obj in selected_objs:
    # Create the empty using the operator
    bpy.ops.object.empty_add(type='PLAIN_AXES', location=obj.location)
    # Get the newly created empty
    empty = bpy.context.scene.objects.active
    # Parent the object to the empty
    obj.parent = empty

I think it's quite straightforward, tell me if you have problems

What if you want all the bones on the armature?

that's a different question, you should have stated it more clearly... Currently I'm not home, so i can't verify, but create the empty with the method i told you (except that you need to put the bone's position instead of the obj.position), then to parent them, add a constraint modifier on the empty and the set the bone as target

I am excited to use this, especially because empties allow you to place a collection instance on them. However, this python script is broken in 2.82a. Trying to go through the errors and update the script for compatibility.

@CobyRandal yes, this code was made for version 2.79, and from 2.79 to 2.80 the API was modified. In newer version the commands are a bit different, but the logic is still the same

So I have a working script that places an empty (with a collection instance) at all objects you select. It takes into account the selected objects and their rotations. I never got the parenting to work right though, which is why I have refrained from answering this question as of yet. Any ideas how to make parenting work like this in 2.8? The farthest I got was it made all instances children of the first object selected instead of each object at which they are placed like I originally wanted.

@CobyRandal See my answer for updated code. Add empty.instance_type = 'COLLECTION' and empty.instance_collection = bpy.data.collections.get('MyCollection') at the end of the loop to create a collection instancer


text:
AttributeError while changing the display units using python script
I have two questions both related to python scripting:
1) I want to set the units to mm, for that, I change the scale to 0.001 in both Scene and Display in the properties panel. When I copy the commands and run it as a script I get an AttributeError saying:

"AttributeError: 'SpaceTextEditor' object has no attribute 'context'"

In one of the answers, I understood that this just clicks the button in the properties editor and since we are running it from a script the line can be removed. But the next line, where you set the scale length, also throws an error saying:

"AttributeError: 'Scene' object has no attribute 'system'"

2) I want to scale an Ico sphere along the three axes, I change it in the properties panel but the code generated does not take into effect the changes in these values. Please find the code below:
import bpy
bpy.ops.object.delete(use_global=False)
bpy.data.objects["Camera"].hide = True
bpy.data.objects["Lamp"].hide = True
bpy.context.space_data.context = 'SCENE'
bpy.context.scene.system = 'METRIC'
bpy.context.scene.scale_length = 0.001
bpy.context.space_data.grid_scale = 0.001
bpy.ops.mesh.primitive_ico_sphere_add(size=1, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=3, size=1, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.context.object.location[0] = 20
bpy.context.object.location[1] = 50
bpy.context.object.location[2] = -14
bpy.context.object.dimensions[0] = 2  # changes not taken into effect (40 on UI)
bpy.context.object.dimensions[1] = 2 # (20 on UI)
bpy.context.object.dimensions[2] = 2 # (35 on UI)

I am new to blender and any suggestions would be greatly appreciated.

Error messages are pretty helpful in this case.

"AttributeError: 'Scene' object has no attribute 'system'"

Means that you can not access the scene's system property because there is none. In other words: the actual 'Object' (Scene in this case) has no attribute called .system so you can not access Scene.system.
Suggest using the auto complete feature (Ctrlspacebar) of the command line when searching for attributes:
>>> bpy.context.scene.u
                       nit_settings
                       pdate(
                       sers
                       ...
>>> bpy.context.scene.unit_settings.system
'METRIC'
>>> bpy.context.scene.unit_settings.scale_length
1.0

Note: Lines from the Info Area not always yield the 'correct path' to the attribute/property.

Thank you, this gave me a better idea on how to proceed.


text:
Fuse two separate objects
First I really need to clarify, I’ve watched people use the boolean method, but I swear I’ve seen people just able to drag an object into another and it automatically fuses without any interior meshes or extra work. Problem is, I can’t remember what it’s called or how to do it. Was this not a recent addition to Blender? I may be wrong.
Say I have a sphere and a cone and I want to make something resembling an ice cream cone, but I want the hidden half of the sphere to be gone (so that it’s 1 object, a semi-sphere and a cone attached to one another with no hidden geometry).
I don’t want to count vertices or do any extra selection -> deletion/vertices manipulation work to get this effect. I just recall seeing people drag one object into another. Say, they drag the sphere down onto the flat surface of the cone and the sphere geometry that enters the interior of the cone just disappears and the vertices where the two objects touch hook onto each other automatically.
Am I confused or is this something possible? If it’s possible, I assume it’s some sort of modifier that gets attached to the cone? This will seriously speed up my work flow, so if anyone has any answers that would be wonderful! Thanks.
—-
Edit: All of the answers are helpful, thanks! I likely saw someone using the Bool Tool addon. Ctrl + J and Convex Hull and Bridging will also be very helpful. I really appreciate the quick responses.

It's possible they are using the booltool addon.  With it enabled you can multiselect and do Ctrl + Numpad +/- to do a quick union/difference, and I think Ctrl + Shift + etc does the same but automatically applies the operation

Orient your meshes when they are still separate:

Join them with Ctrl + J:

Select the whole (joined) mesh in edit mode and select mesh > Convex Hull:

Resulting shape:


text:
How to create bones using world matrix
I am writing an importer of a new file format, which using a 4x4 world matrix to define bones
now I am using the 4th row column 1-3 to define the head of bone and the distance to the child's head to define the length of the bone. then the tail of the bone is calculated by
bone.tail = bone.head + Vector((bone_length,0,0)) * bone_world_matrix.to_3x3()

this can build the correct shape of the skeleton but the mirrored axis was missing
how can I using this data correctly? OR is there any python API can directly use the world matix when creating bones?


text:
how to make an addon with custom driver function
In my addon everything is working fine.... other than
bpy.app.driver_namespace["Driver"] = driver
It works if I enable the addon on starting blender, but once I save user preferences, then it seems to not run that line of code but everything else works fine, as far as I can tell
I have tried putting it in classes and in the register function but nothing works

Use a persistent load_post handler to register your drivers to the driver namespace.
import bpy
from bpy.app.handlers import persistent
from bpy.app import driver_namespace as dns

def driver(x):
    return x

@persistent
def load_handler(dummy):
    print("Load Handler:", bpy.data.filepath)
    #dns = bpy.app.driver_namespace
    # register your drivers
    dns["xdriver"] = driver

def register():
    load_handler(None)
    bpy.app.handlers.load_post.append(load_handler)

def unregister():
    bpy.app.handlers.load_post.remove(load_handler)

if __name__ == "__main__":
    register()


text:
How to create cell fracture in python
Firstly, I am new to Blender. I am actually working on to create a hemispherical model with cell fractured property.
1. I have done this work manually using cell Fracture add-on and now I want to automate using python.
2. I have written the code till particle implementation on the hemisphere. Now I want to create a cell fracture with those 100 particles.
I have attached the hemisphere picture and the final output needed. I have also attached the code. Please provide me an insight on how to do this using python.
Code till Particles in Hemisphere:
import bpy

# Draw hemisphere of 1 m radius
bpy.ops.mesh.primitive_circle_add(
    radius=1,
    enter_editmode=True,
    align='WORLD',
    location=(0, 0, 0),
    fill_type='TRIFAN',  # NOTHING  or NGON
    )

bpy.ops.mesh.bisect(
    plane_co=(0, 0, 0),
    plane_no=(0, -1, 0),
    clear_inner=True,
    )

# Particles
bpy.ops.object.editmode_toggle()

bpy.ops.object.particle_system_add()

bpy.data.particles["ParticleSettings"].count = 100

bpy.context.object.particle_systems["ParticleSettings"].seed = 1

bpy.data.particles["ParticleSettings"].frame_end = 1

Image: Hemisphere with particle feature

Image: Final output required with cell fracture

Thanks and Regards,
Sunag R A.

It is \`` for the code block (under esc key), your are using '` (beside enter key)

@HikariTW recommend tab formatting for code block (ie all of code block  tabbed one extra right)   Wrapping in three backticks often leave a residual  when copy / pasting.

@batFINGER But I prefer using explicit bracket for code since there is no standard tabbed lens and in some editor, block tab just don't do the work. (And the residual should be considered as parser and html implement method?)

Add particle system as suggested here Python and particle system
Make sure the cell fracture addon is enabled, and call the operator
bpy.ops.object.add_cell_fracture_objects()

Which uses defaults as mapped out in doc string
>>> bpy.ops.object.add_fracture_cell_objects(
bpy.ops.object.add_fracture_cell_objects(source={'PARTICLE_OWN'},
        source_limit=100,
        source_noise=0,
        cell_scale=(1, 1, 1),
        recursion=0,
        recursion_source_limit=8,
        recursion_clamp=250,
        recursion_chance=0.25,
        recursion_chance_select='SIZE_MIN',
        use_smooth_faces=False,
        use_sharp_edges=True,
        use_sharp_edges_apply=True,
        use_data_match=True,
        use_island_split=True,
        margin=0.001,
        material_index=0,
        use_interior_vgroup=False,
        mass_mode='VOLUME',
        mass=1,
        use_recenter=True,
        use_remove_original=True,
        collection_name="",
        use_debug_points=False,
        use_debug_redraw=True,
        use_debug_bool=False)
(undocumented operator)

Test code, produces result as in image above.
import bpy
from addon_utils import enable

# make sure cell fracture is enabled
enable("object_fracture_cell")

context = bpy.context

# Draw hemisphere of 1 m radius
bpy.ops.mesh.primitive_circle_add(
    radius=1,
    enter_editmode=True,
    align='WORLD',
    location=(0, 0, 0),
    fill_type='NGON',  # NOTHING  or NGON
    )

bpy.ops.mesh.bisect(
    plane_co=(0, 0, 0),
    plane_no=(0, -1, 0),
    clear_inner=True,
    )

bpy.ops.object.editmode_toggle()

# Particles

ob = context.object
ps = ob.modifiers.new("Part", 'PARTICLE_SYSTEM').particle_system
ps.seed = 1
ps.settings.count = 100
ps.settings.frame_end = 1

# cell fracture

bpy.ops.object.add_fracture_cell_objects()

Thank you so much..!! This gives me the clarity of coding in Blender and also the solution to my problem.

I was trying the code provided by the chosen answer on Blender 2.92 which was failing, the needed change is to use add_fracture_cell_objects instead of add_cell_fracture_objects.

Thanks for the heads up. The cell fracture in the version of 2.92.0 RC  I am using is still working as above.  What version of 2.92 did you notice change in?.

Any possibility of defining the size of each fracture area? this could be useful to create voronoi treemaps


text:
Remove button from Edit mode in Materials dissapeared
I dont know if im missing something but the remove button that appears in-between assign and select doesnt show anymore.

It might be something simple but i dont know what happened.

Am I crazy, or has there never been a remove button? I can't recall ever seeing something like that (though that shouldn't suggest I couldn't have missed something).

I'm the one feeling crazy, I used that remove button very frecuently and was there the entire time and all of the sudden disappears without me doing anything, and I tried to find out about what could have provoke it. but when i looked into it, it appears that no one has it (taking video tutorials for reference). And now feels like its like a Mandela effect.

Is there any chance you were using an addon that added extra buttons to the UI?

I dont recall using addons related to the interface, and theres nothing about it on the preferences tab.

Yeah, I dunno then. I'll admit - you've got me second guessing myself now, but I'm pretty sure I've never seen a remove button (and materials are one of my specialties).

I remember that it came handy when I had faces on a mesh that I didnt want them to be that specific material and just Select > Remove, but i dont know, i may be mixing it with the Remove button from the Vertex Groups tab.

You show the material list, there's no Remove button under the material list, you're confusing with the Vertex Groups list, no need for a Remove button in the material list, if you want to remove a material from a face, assign it to another material, even in 2.7 I don't see any Remove button

Well you could have an empty material slot and assign that to parts of mesh you don't want materials on. Though, in what context do you need parts of meshes with no materials?

Basically to remove a material there are two standard ways:

Either press the minus button '-' to remove the material altogether. The first material in the material list will replace it automatically (if there is one). You can also remove all materials, but clicking the minus button, until there is no material left.

Or just apply the other material onto the faces by selecting it in the list & pressing assign.

PS: Funny little convo you guys are having in the comments XD . No there was no remove button in Blender, atleast not after 2.8. Before that, I cannot say. Nor have I heard of an addon, that adds that functionality, unless its a obscure one.


text:
Rotate force around Z axis
I'm trying to create a hairline presentation of colliding force fields.
I want an object rotating around Z axis to carry it's force field around.
Is this possible? I see no standard method.

It is not really clear what you want to do... an object "to carry its force field around"? My first guess would be you want a force field parented to another object and this should be rotated on Z. So, select force field, Shift + select object, Ctrl + P > Set Parent to Object. Then keyframe the Z rotation of the object.

This is it! Thank you!

Answered in comments by @Gordon Brinkmann.

... So, select force field, Shift + select object, Ctrl + P > Set Parent to Object. Then keyframe the Z rotation of the object.

kindly include that comment in your answer. you can use the tools to quote  others.

Done and done! :)


text:
How to create a mesh of objects circling a sphere
I'm making an animation. Two planets - one in the center, the other one - smaller - orbiting it.
The large one needs to have satellites orbiting it, and these satellites need to be facing the small planet.

The network of satellites needs to be ordered in a sort of a mesh, let's say like that, in a kind of a plus-formation:

Would you be able to recommend a modifier?

yes! geometry nodes modifier!

@Chris Thanks!!

For the distribution of the satellites, I have used a cylinder with 2 side segments.
(Increase the vertex count to have more satellites) Took the same cylinder and rotated it by 90deg to have the plus you are looking for.
Now on these cylinders I have instanced the satellite object.
To align these instances to the other planet, we have to set the rotation value in the instance on points node in a particular way.
By subtracting the position of the instances from the location of the other planet, we get a vector pointing from the instance to the planet.
Now, using the Align Euler to Vector node we can use this created vector to align the satellites pointing towards the other planet.
(To animate the satellites around the planet just use a transform node right before the instance on points node and animate the rotation as you like)

That's a cool one @Akhay2005! I managed to work my way out of this by implementing a method from this vid: https://www.youtube.com/watch?v=a77tS9bukvU
@Chris Thanks for the tip!


text:
Recreate CSS effects in Blender?
I would like to do something like stroke-dashoffset in blender. You can see what I mean exactly here:
https://svgartista.net/
Being able to define fill/stroke gradients and stroke-strength is a must.
Ist there a tutorial I could use?

Hello, could you rephrase you question so it is immediately understandable which effect exactly you want to achieve ? You can embed images and screenshots in your post. Have you explored grease pencil and line art modifier ?

Hello and welcome. While files, images, and external videos or links may be helpful additions they should not be the only way to obtain information about your issue. Don't make understanding your question rely on downloading a file, watching a video or visiting an external site. Use the builtin tools to upload images or gifs, along with thoroughly explaining the problem in written form so it can be indexed and searched for thus helping future visitors with similar issues.


text:
How does instancing improve render times with Cycles?
I can understand why instancing reduces the amount of memory used since you don't duplicate the polygons of your scene, you simply reference them from multiple locations in the scene.
From a technical/hardware point of view (because I guess that's what it's going to come down to), how does it improve render times though? As long as you're not running out of memory without instancing, it shouldn't change anything?
Is it because instancing allows for a better use of the CPU/GPU cache since the exact same memory locations are accessed?

To my poor understanding, reading and loading/unloading data takes time. Calling for a new data load takes time. So the bigger and numerous you have, the more time it takes.

Forgot to mention: when rendering animation, data is loaded at the beginning of each frame, unless you enable persistant data which will load data only at the first frame but at the cost of a longer first-load time, memory overflow, and historically had some data corruption issues sometimes.

@L0Lock Makes sense. Maybe instancing doesn't improve render times "explicitly" in the end but only "implicitly" thanks to the reduction of data transfers. I can't really test it myself on a Blender scene unfortunately, I'm not that good of a Blender user...

Imagine yourself ordering printing paper online. Do you prefer to make 1 order of 100 pages, or 100 orders of 1 page? Also you pay the same amount of delivery fee per order.


text:
Blender Mesh has duplicated materials
I have a huge problem. I’m a game developer and currently trying to create a level with Lego buildings. So I export them as zmbx from mecabricks and import them to blender, combine the meshes (joined them into one) and then export it as fbx which I than can import into ue5. The problem is that the mesh has to many materials and nanite can’t handle a mesh with over 64 material slots (mine, a simple building, has around 650), each brick has a material, which is totally unnecessary cause the most of these materials have the same color/texture. They are called like „mb:o:234:199“, when the last number is the same (199) all these materials have the same color/texture.

And then for example other materials with the ending 134 are also the same … I saw that a lot of guys found a way to combine all materials into one. I tried some blender addons like creating an atlas, but for that you have to create a new uv map which my pc can’t handle because of the mesh (Rtx 3070ti ox, ryzen 7 5800x, 32gb Ram). And then I get a weird texture and the mesh is completely filled with random colors. I’m new to blender so I have no other ideas. Please help

What about grabbing the first occurence of a material with suffix :199 and then assigning this material to all other parts where another :199 material is used? You could then delete all materials except the first afterwards.

Before exporting, creating atlases, uv maps and so on you could reduce the amount of materials to only the necessary ones. Go over to the Scripting workspace and create a new .py file with the following script. Select your object in object mode and run the script:
import bpy

context = bpy.context
obj = context.object
mesh = obj.data

suffixes = [':199', ':44']  # add more suffixes

for suffix in suffixes:
    mat_slots = obj.material_slots

    basemat = None
    basemat_index = -1

    for index, slot in enumerate(mat_slots):
        mat = slot.material
        if mat and mat.name.endswith(suffix):
            basemat = mat
            basemat_index = index
            break

    if basemat:
        for face in mesh.polygons:

            slot = mat_slots[face.material_index]
            mat = slot.material
            if mat and mat.name.endswith(suffix) and mat.name != basemat.name:
                    face.material_index = basemat_index

        for i in range(len(mat_slots) - 1, basemat_index, -1):

            mat = mat_slots[i].material
            if mat and mat.name.endswith(suffix) and mat.name != basemat.name:

                obj.active_material_index = i
                bpy.ops.object.material_slot_remove()

This will assign the first found material with suffix :199 to all faces which have another material (not the first found) with suffix :199 and remove these material variations afterwards.
Edit: updated script to process multiple suffixes
Then it will process the next suffix (:44) and so on.

Thank you! I searched exactly for that! But there is a problem there aren’t only materials ending with :199. there are lots of material groups with the same suffix. Is it maybe possible to change that script, so it goes threw all materials and combine all with the same suffix?

Sure, thats what i meant with "improve the hard coded parts". I'll update my answer.


text:
Different Enviroment Map per object/layer. (Blender Engine)
I hope this hasn't been asked previously, I was unable to find a similar question.
Is it possible to have different Environment Maps that affect specific objects or a way to have different Environment Maps per layer?
As an example of the desired result I cheated a .gif from Photoshop. Of 1 scene with 2 different Environment Maps.

Thank you! ♥

By using multiple scenes you can get the different parts and composite them together. Have one scene that renders the background you want, then another scene for the object with the environment you want reflected on it's surface, render this scene with the background as transparent then composite the objects onto the background.

You could setup multiple scenes to get different reflections for each object. The object index can help to mask out each object when compositing.


text:
Example of creating and setting a Cycles material node with the Python API
I'm trying to set the properties of a Cycles material, which is linked to a Plane object, using the API.
So far this is what I've got:

Create a floor plane object:
bpy.ops.mesh.primitive_plane_add(radius=3, view_align=False, enter_editmode=False, location=(0, 0, 0))

my_floor = bpy.data.objects["Plane"]

Create the material for my floor, (I'm assuming it does not already exist):
my_floors_material_name = "Material"

#create the materials object
my_floors_material_object =    bpy.data.materials.new(my_floors_material_name)

#Enable 'Use nodes':
my_floors_material_object.use_nodes = True

Add a new node type from the list [types.ShaderNode][1]. I'd like to
choose the equivalent of node_groups["Shader Nodetree"].nodes["Anisotropic BSDF"]:
#create the input node
shinny_floor_input_node = my_floors_material_nodes.new(type='ShaderNodeBsdfAnisotropic')

#create the output node
shinny_floor_output_node = my_floors_material_nodes.new(type='ShaderNodeOutputMaterial')

#link the input and output nodes, on the node tree of my object
    my_floors_material_object.node_tree.links.new(shinny_floor_input_node.outputs[0], shinny_floor_output_node.inputs[0])

#this runs and returns
bpy.data.node_groups['Shader Nodetree']...NodeLink

Assign the floor material to the floor object:
#assign the material object, to the plane object
my_floor.data.materials.append( my_floors_material_object )

Unfortunately it does not work? Here's the floor I want to create, (the shinny one below the statue)

Here's what I get with my current script:

Seems like it should an easy thing to do, but I'm confused? Here's the a link that I used to get started, Control Cycles material nodes and material properties in Python
Thanks a lot for any help!

As last step you only have to assign the material to the object, see: http://blender.stackexchange.com/questions/23433/assign-a-new-material-to-an-object-in-the-scene?rq=1

Hey poor, thanks alot for the link :) I've added the last step as you advise, and I also found out how to create the materials object using the API from here, http://blender.stackexchange.com/questions/5668/add-nodes-to-material-with-python?rq=1 Unfortunately it still doesn't work ?

What exactly is not working? Error messages?

The code runs without any error messages. It just does not do what I expect/want it to do? Basically the material of the floor/plane object is unchanged from Diffuse BSDF, (the default), and not Ansiotropic BSDF ; which is what I want the script to do. When I run the script, in the the Surface panel of the material, the box for the Surface, is unchanged from Diffuse BSDF  to Anisotropic BSDF ??? So I think that's the problem?

Please check your output Node, it should looks like: node_output = nodes.new(type='ShaderNodeOutputMaterial'), creating shader code: https://gist.github.com/p2or/fbadce83877a36622720#file-create-anisotropic-py

Yes !! Thank you very much indeed, I think it works now. I just need to experiment with the default settings, but the basic material seems to be right now ;) How do I accept your answer as the best?

Sure, can you do it, or do you want me to do it?

Glad I could help :) Don't delete it, it's helpful for others too, I'll mark it as duplicate.


text:
Convert particle hair to anime-style mesh hair and keep all physics animation
Blender's hair tools are very nice for, well, making hair. I would like to convert hair that has been styled and animated into a mesh while keeping the animation. Export Blender Particle System Hair To Three.Js details converting hair to a mesh, but afterwards the hair is no longer animated by physics. Physics based animation is a must for me in this case.
I'm willing to consider other ways of making hair if I have to.

I think that you may use cloth simulation, but I'm realy not sure and I don't know how.

The short, and unsatisfactory answer, is that you can't right now. The closest you can come is converting the hair to mesh, then converting to curves and giving them a bevel and taper, and then run softbodies on the curves. This doesn't give very good results though.

It seems this guy has succeeded but I don't know how exactly since I have no python knowledge.


text:
How to round sharp edges of iregular mesh
I have an irregular mesh created with Boolean modifier of a 3D scan and two icospheres. The mesh has two sharp edges which I would like to round out:

I can smooth out the top edge using Smooth Vertex to something I could accept but the bottom edge does not get smoothed out enough to be called rounding.
My clumsy attempt to show what my aim could be is this - the red arrow points to what is only a part of what I'd like to get (it should be similar but all around the sharp edge):

I have tried using Bevel, Multiresolution, Subdivision Surface modifiers but cannot get enough of beveling (when I get any).
I also used Bevel in Edit mode but it creates ugly artifacts because the mesh is irregular.
I cannot do this by sculpting because this is only a part of a workflow aimed to process many of similar shapes.
I've read about 15 other question with similar subject but none of them offered a solution I could use.
The question is this: Is there a way to bevel the sharp edges that is not manual?
Info: I have cleaned up the mesh with Triangulate, Remove Doubles and have removed zero faces with Edge Collapse. The mesh passes the "Check all" test in 3D Printing addon with all tests 0 (except the Overhang Face, of course).
The file with the above sample is here:

Did you try subdivide smooth?

In order to smoothen those sharp edges most likely you'll need to change topology, at least in that area. Neither Bevel nor Subsurf won't work well with tiny and very distorted faces.

Blender is not a good tool to do what you want - it does not have the things you need. Download trial of Zbrush and run Polish pass over your shape or use the ZBrushes smooth brush that will smooth this topology correctly. In Blender you need to retopologize to do anything with this.

@Georges, yes, Subdivide Smooth only "rounds" the edge a bit. I'd like to round it more than that.

@Mr Zak & Jerryno, is there a simple way to change the topology of this thing?

@spacer Try to use remesh modifier or enable looptools addon and use Relax operation.

I know you said`not manually but proportional editing or sculpting is an option

@Denis, thanks, but neither worked. The Remesh messes up the (irregular but nice) mesh and the LoopTools Relax just spreads the vertices along the edge (I thought it might help the Bevel but it doesn't).

I don't think there's automated and fast solution as of now. I know of this WIP addon however it wasn't finished yet and there isn't much information about it. I also saw InstantMeshes which probably have import-export integration but I'm not aware of how good it works. Solutions in Blender mean retopo by hand.

Thanks @Mr Zak, the WIP addon looks interesting but I couldn't find anything except videos ...

You need first to simplify the mesh using Decimate modifier, here are the steps:
1- Use Decimate Modifier, set Ratio to a low value I used 0.042 for this example.

2- Apply the Decimate modifier, then go to Edit Mode, select the edges you want to Bevel.

3- Ctrl + B to bevel the edges, don't use Clamp, but keep an eye on those adjacent edges, a little overlapping will be correct next step.
4- Ctrl + V and select Remove Doubles, fiddle with the amount until you weld very close together vertices, in this example, I used 0.5.

5- Now add a Subdivision Surface Modifier, if you haven't set the shading to smooth yet, it's time to do. This is the final result, of course you can choose the parameters you need for the previous steps, I put the values according to what I think you're looking for.
Hope this helped, Happy Blending!

Thanks! Although it is not really what I can use (I need to keep the shape as close as possible to the original, except the edges, so I cannot decimate the mesh so much) it gave me an idea. I'll get back after I try it.

In this case, the only thing I can think of, is using a project knife, or a boolean, to cut the edge, but that will take some manual work.


text:
How to edit UI icons?
Blender 2.8 comes with a set of monochromatic icons which seem to be stored inside datafiles/icons/*.dat.
How can these icon files be edited/replaced with other/custom icons?
Where is documentation about the icon format and how to compile/generate these *.dat files?

Summary

Not official: based on own research. Edit: NOTE: icon_geom.blend being "not available" was accurate at the time of posting, but has later changed. Now that file is available on a separate repo (see below)
Two kinds of icon
I think that "the monochromatic icons", the small ones used in menus etc, are not present as separate files in the compiled releases of Blender because they are compiled in the binary code. By the way, they are not necessarily monochromatic: this isn't "forced" in the code, it's just a design choice made for version 2.80.
The ones that you find under datafiles/icons/*.dat, that come with the built releases, are the (usually colored) ones that are used, for instance, in the tool shelf (see pic below)

So which ones do you want to change?
To change the small "menu" icons
you will need to recompile blender from source after having updated the blender_icons16/*.dat and blender_icons32/*.dat files in the $SOURCE2.8/release/datafiles/ folder, and to do so you must first edit the vector image $SOURCE2_8/release/datafiles/blender_icons.svg

and then update and make the icons, roughly following this guide (a bit old but I think still valid)
To change the bigger "tool" icons
I'm not sure how to change the (usually) colored ones that are not compiled into Blender (i.e. the ones that are present as separate .dat files in the downloaded blender builds). They seem to be generated via this blender_icons_geom_update.py script that pulls the design from a icon_geom.blend file that is present in Blender's Library Resources SVN repository.
I've found this message that confirms that the process is currently not documented:

«Currently, it’s just a .blend file that generates the icons.

[...] Once we are more finished with the tools we will probably document how people can do this, if anyone wants to make new icons, or change them.»

William Reynish (billreynish), Apr 28 2018

Documentation?
There is anyway another script: blender_icons_geom.py that contains a documentation of the pixmap format which could be what you are looking for:
This is a simple binary format (all bytes, so no endian).

The header is 8 bytes:

:0..3: ``VCO``: identifier.
:4: ``0``: icon file version.
:5: icon size-x.
:6: icon size-y.
:7: icon start-x.
:8: icon start-y.

Icon width and height are for icons that don't use the full byte range
(so we don't get bad alignment for 48 pixel grid for eg).

Start values are currently unused.

After the header, the remaining length of the data defines the geometry size.

:6 bytes each: triangle (XY) locations.
:12 bytes each: triangle (RGBA) locations.

All coordinates are written, then all colors.

Please note
To answer your question I have just made a short investigation across the repositories and forums, but I have never tried myself to edit these icons.
One thing is for sure: if you do something like
cp brush.gpencil_draw.draw.dat ops.mesh.bevel.dat

the "bevel" tool actually becomes a little pencil (this proves that the "tool" icons are read directly from the datafiles/icon folder).

https://developer.blender.org/T64177#787946

hi Nicola! could you shed some light on the triangle RGBA locations? Some sort of documentation? How do those Triangles and their RGBA values that come later make icons ?

@ankii I'm not an expert of the matter, I just made some research at the time of answering this. sorry

For anyone implementing these .dat files from scratch, from this description, as I just did, note that if you use the offsets as described, you'll get "Corrupt icon: /tmp/my_cool_icon.dat Unable to load from file" .  The description is rather muddled so it's hard to describe precisely what's wrong about it.  It says  :0..3: ``VCO``: identifier. :4: ``0``: icon file version. :5: icon size-x. :6: icon size-y. ....  In any case, to make it work, just start the file with b`VCO\0' and then continue with the size-x etc. at offset 4 (not 5).

@anki if you start with 1 triangle and experiment with different test values, you'll get the hang of it. E.g. x,y values are always in range 0..255 (rather than 0..width and 0..height). Apparently x=0 and x=255 are the left and right, y=0 and y=255 are the bottom and top. I haven't been able to figure out alpha-- setting it to 255 makes it opaque as expected, setting it to other values does something but I don't know what (e.g. setting it to 0 doesn't make it transparent). I'm just sticking with alpha=255 (so, fully opaque triangles on fully transparent background, which is a bit limited).

@anki also size-x and size-y don't seem to do anything in my experience (I'm just using this for toolbar icons) but it's not completely clear whether they are ignored like start-x and start-y definitely are (see the c++ code that reads them ) so maybe safest to always use 255 for both of these.


text:
How do I add an .obj file from a relative file location?
I need help adding an .obj file via scripting. I've tried using this line of code, but I'm having issues importing the obj file:
bpy.ops.import_scene.obj(filepath="./example.obj")

I think the problem is how I define the file path, but I don't know how to fix it.

To make the path relative to the blender file use path = "//fileinsamefolderasblend.obj"

@batFINGER Can I specify a path relative to the script (not the blend file)?

https://stackoverflow.com/search?q=%5Bpython%5D+path+relative+to++script+

@batFINGER
dir = os.path.dirname(__file__)  (newline)  file = os.path.join(dir, 'example.obj')  (newline)  bpy.ops.import_scene.obj(filepath=file)
I tried this (from the search) and it also doesn't work. I have os imported.

Where, what is the script, how are you running it?  If blend file  is saved use as commented above to get path relative to blend file.  . If not saved then reverts to "." which is the folder from where blender is run.  eg if start blender from console from desktop folder this is where. If you are running from program  icon, possibly your install folder.  Recommend using pathlib import pathlib; print(pathlib.Path.cwd()).   If the script is imported as an addon then __dir__ above will work as expected.  If you are running script from main thread via text editor ...?

Agree with batFINGER Add how you are running the script.

You simply need to combine your relative path with the current directory, which you can get using the os library:
import os
bpy.ops.import_scene.obj(filepath=os.getcwd()+"/example.obj")

I recommend using os.path.join() to be on the safe side...

import bpy
file_loc = 'C:\Models\Model.obj'
imported_object = bpy.ops.import_scene.obj(filepath=file_loc)
obj_object = bpy.context.selected_objects[0]
print('Imported name: ', obj_object.name)

Result

How would I grab a .obj in the same folder as the script? (aka a relative path)

If you run it inside blender, I think it uses blender’s location, and you have to put a path in here, but I am not sure


text:
Transparency showing as black on a mix shader (multiple image textures)
First time here, still pretty new to Blender.
I have an object that I've applied an image texture to. The object is a can with a label that wraps around 90% of it. The object's "label" texture requires two different material types:

A moleskin-like material with low refraction for the "background" of the label.
A semi-flat metallic material for some of the lettering and design
elements on the label.

To achieve this, I used a principled BSDF and a glossy BSDF and fed them into a mix shader.
I then added another image texture of the label "base" (acting as a mask for the metallic elements to come through) and fed the color output into the factor of the mix shader.

This effectively achieved the result I wanted, however, the transparent portion of the image texture (the non-metallic one) is showing up as black. I tried playing around with a transparent BSDF and an additional mix shader, but I couldn't figure out how to get it routed to be able to get rid of that pesky black.

I've been scouring the web for solutions but haven't made any headway. Any help would be greatly appreciated!

In your current setup the shader cannot know where to apply the transparency. You should connect the alpha output from the image texture node to the alpha input of your principled bsdf. This will only work if your png has an alpha channel correctly setup.

I made sure my PNG had an alpha channel. I even went into the UV editor and switched around the alpha mode. When set to "straight" the black borders around the image do turn transparent (checkerboard) but when I plug the alpha output from the image texture into the principled BSDF's alpha input, nothing changes (that I can see). The black still remains. Is there something specific I need to do with my alpha when exporting the PNG? Thanks for the response!

Actually, I just figured it out! I noticed that after reconnecting the alpha in/out, the black area turned from having a slight highlight to completely black. So from there I went to my material properties' settings and switched the blend mode to "Alpha Blend" and it finally went away. Thank you for your help!

Don't add solved to your question title. Please add this is answer and accept it to help future visitors having the same issue. How this site works: https://blender.stackexchange.com/tour

Sorry about that. I wanted to mark Gorgious's response as the accepted answer, however, it was posted as a comment rather than an answer so I'm only able to upvote it. I read through the tour page thoroughly. If there's an alternative way to convert a comment into an accepted answer, I'm happy to learn as it's not mentioned anywhere in the page you linked.


text:
Why my final render is brighter than the preview in the viewport?
When I use the viewport to render, the result is different to the final render:

Viewport Render

Final Render
It's like the rendered image is brighter so I tried disabling the lights one by one to see if one of them is causing any problem. I also changed the light bounces from 12 to 1 but it made no difference. Neither Bloom nor AO or even changing the samples (from 128 to 64) makes a difference. I also tried rendering with 128 samples in the viewport and unfortunately it does not help.

Q: How to match the final render to the preview in the viewport?

@pijjoncha - if there is not any other light on side, it can be something with normal map or ... are you sure you use the same environment light (texture) with same rotation - for viewport and render? If its normal map (material setup) you can see if you hide a skull and try to add some another object like chrome sphere, from this object you can also see if envi match. Or post simplified blend where issue still persist via https://blend-exchange.giantcowfilms.com to let us see your setup closer.

Related: Which mode should i trust for lighting?


text:
How can I purge recently deleted objects?
import bpy

selected_objects = bpy.context.selected_objects

for obj in selected_objects:
    bpy.data.objects.remove(obj)
    for block in bpy.data.meshes:
        if block.users == 0:
            bpy.data.meshes.remove(block)

I need purge only removed mesh objects and leave the rest of the garbage untouched.

Batch remove.
In latter versions there is the ability to batch remove a number of ID objects in one fell swoop.
>>> D.batch_remove(
batch_remove(ids=(id1, id2, ...)
.. method:: batch_remove(ids=(id1, id2, ...))
Remove (delete) several IDs at once.
WARNING: Considered experimental feature currently.
Note that this function is quicker than individual calls to :func:`remove()` (from :class:`bpy.types.BlendData`
ID collections), but less safe/versatile (it can break Blender, e.g. by removing all scenes...).
:arg ids: Iterables of IDs (types can be mixed).
:type subset: sequence

Test script, remove the selected objects, then remove any orphaned linked data they  left behind.
import bpy
from bpy import context

purge_data = set(o.data for o in context.selected_objects if o.data)
bpy.data.batch_remove(context.selected_objects)
bpy.data.batch_remove([o for o in purge_data if not o.users])

To remove only lattices,  and their data if orphan, from selected objects.
import bpy
from bpy import context

lattice_obs = [o for o in context.selected_objects if o.type == 'LATTICE']
purge_data = set(o.data for o in lattice_obs)
bpy.data.batch_remove(lattice_obs)
bpy.data.batch_remove([o for o in purge_data if not o.users])

There may be a tricky way to do above with one call and one list.
Similar to  question code, if optimized to only loop the meshes after removing the objects.
import bpy
from bpy import context

for obj in context.selected_objects:
    bpy.data.objects.remove(obj)

for block in bpy.data.meshes:
    if not block.users:
        bpy.data.meshes.remove(block)

Second block code is what I needed. It delete all selected objects as I asked, but can I concretize to delete for example only Lattices objects and purge it data after

Isn't that the behaviour of  the  batch delete example above, if a lattice is in selected objects it is removed. If it's data is left an orphan it is also removed.  To filter selection to only lattices  [o for o in context.selected_objects if o.type == 'LATTICE']

sorry for the wrong explanation. So I have selected objects and I need to delete only Lattice and its data. Thanks!

Yes, Thank you!

Edited example in answer. Changed purge data to set (only one instance of each element) although it appears it doesn't fail with duplicates anyway.


text:
I'm searching retopology tools
What are the best free-blender tools in order to retopology a mesh? I'm using Mira tool during this period but i don't like it very much. Any advice? Please help me

Related: http://blender.stackexchange.com/questions/36525/how-to-easily-make-mesh-retopology , http://blender.stackexchange.com/questions/6253/how-to-convert-from-high-poly-to-low-poly

Thank you for the link but I have already seen that question . . . there isn't another free tools?

Retopoflow would be the best option, if paying for it is too hard you can find the source on github.


text:
What is the role of Auto-smooth?
I have noticed this: the "Auto-smooth"

I can't figure out what is its' meaning.
I understand that i can use it combing with the smooth shading.
For example:
A) FLAT

B) SMOOTH

C) SMOOTH & AUTOSMOOTH 30°

D) SMOOTH & EDGE SPLIT 30°

It seems that Auto-smooth works like the Edge Split Modifier, with the huge difference that doesn't add vertex and edge loop. My mesh from B) to C) has the same amount of vertex while mesh from B) to D) doubles the number. My question is:
Why there is this Autosmooth?
Could be useful for create hard edges in my low poly (it doesn't increase the number of my vertex) and let me have nice and clean surface for a possible bake with my high poly?
Thank you to anyone will help me!

https://www.reddit.com/r/blender/comments/2uqc8g/tip_use_auto_smooth_over_the_edge_split_modifier/
From this subreddit, it seems that the autosmooth should be used instead of the Edge Split modifier as a faster way than adding the Edge Split modifier.

Smoothing technics are also described and compared here https://www.blender.org/manual/modeling/meshes/smoothing.html

See http://blender.stackexchange.com/questions/734/how-to-smooth-shade-an-object-while-retaining-hard-edges

I see . . . Do you think autosmooth could be the solution for an hard surface low poly (like the one i uploaded above) in order to create nice baking? I can't figure out this shading problem and edge split add vertices, that's what i don't want to. Otherwise if i only use smooth shading (in my low poly) the final bake result won't be good. Any advice?

related: http://blender.stackexchange.com/q/26576/3710

With Blender 2.80 the use of the Edge Split modifier is deprecated in favor of new custom normals.
Custom Normals allow precise tweaking of normals beyond what auto-smooth can do
There's a lot more information in the Normals section of the recent documentation site. Although I'm not a big copy-n-paster, this is what it has to say about Auto-Smooth:

The Auto Smooth option is a quick and easy way to combine smooth and faceted faces in the same object.

In addition, when you use custom normals:

This has the side effect of enabling Auto Smooth, as that is necessary to use custom normals. Once you have custom normals, the angle threshold of the Auto Smooth behavior is disabled – all non-sharp-tagged edges will be considered as smooth, disregarding the angle between their faces.

Which brings us to the link to the documentation for Auto-Smooth:
https://docs.blender.org/manual/en/2.80/modeling/meshes/structure.html#auto-smooth

It's really just a simplistic version of the modifier, and is technically easier to use, but really doesn't offer many benefits over the Edge Split modifier.
From the Manual:

With the Edge Split Modifier we get a result similar to Auto Smooth with the ability to choose which edges should be split, based on angle - those marked as sharp.

So, the modifier adds the ability to manually specify which edges get split by marking them "sharp." But the modifier does not automatically set the mesh to "smooth" shaded.
Auto Smooth will work the same, regardless of what other modifiers you have in the stack, whereas the modifier will operate differently depending on what other modifiers are in the stack, and where it is placed among them.
As far as baking is concerned, you'll have to try it and see. It's unclear what that problem is, and it'd be a separate question anyway.

I'm sorry but I don't agree with you . . .  Autosmooth let me even mark manually edges with sharps, like the edge split modifier; the only difference is

won't  add vertices
wont' split vertices

If Auto Smooth uses the "sharp" setting, then the Manual is wrong.

Try and you'll see . . . even here http://blender.stackexchange.com/questions/734/how-to-smooth-shade-an-object-while-retaining-hard-edges @MrFlamey underlined this fact in his answer

I don't disagree with you. It just means that the Manual is wrong.

I misunderstood . . . my bad ^^

On a side note about the "won't add vertices" thing - many game engines/GPUs will split along hard edges so you do still get the extra verts in the end.

I think maybe U already solved this,
I was in a same situation today, And I solved it by my self.
The way is Just scroll down to [Geometry data] tab then try to clear these  datas.
It was works on my Blender v2.79 mac.
sry 4 my bad English.
I hope this will be UR help.
good luck.

Note that this will remove normals split in custom way which can be undesired as the object shading will change and one will need to rebuild it

I did not understand that question perfectly.Sorry I can not do anything.