2
$\begingroup$

I am exporting an fbx with tangents, but I am getting this error on export for some of my mesh objects: enter image description here

These errors are not referring to the object name, instead the mesh name found in the object data properties panel. It seems this cannot be searched in the Outliner, which only searches object names, which are not the same as the mesh names in my case. Is there an easy way to find these objects by mesh name or select them via python?

$\endgroup$
5
  • $\begingroup$ "It seems this cannot be searched in the hiarchy" Why not, what happens when you do? $\endgroup$ Jul 31 at 23:34
  • $\begingroup$ The hiarchy only searches objects, so only objects come up. Mesh names aren't consistent with all and in this case all my object names. Thanks for the question. $\endgroup$
    – Zak Nelson
    Jul 31 at 23:43
  • $\begingroup$ For example, 'Plane.017' does not show up in my outliner because I have a mesh with that name, but not an object with that name. $\endgroup$
    – Zak Nelson
    Jul 31 at 23:49
  • 3
    $\begingroup$ In the outliner you can search by any data type that affects the 3D view, including but not limited to object, object data, materials and even modifiers or particles. If you are not seeing those they either don't exist in the current scene, current view mode, or are otherwise being filtered out by some other outliner display setting $\endgroup$ Jul 31 at 23:53
  • $\begingroup$ Having evaluated the answer, it seams this is a potential bug in the fbx exported, because the mesh names it listed don't exist in my scene. It was the right about the number of incorrect meshes, but not their mesh names. $\endgroup$
    – Zak Nelson
    Aug 2 at 15:41
5
$\begingroup$

Select Mesh Objects with ngon faces.

XY Problem. The issue with the exporter is ngons ie meshes with faces using more than four vertices.

Rather than search for anything by name, instead will search by trait. Here is an example script to select all mesh type objects with 1 or more ngon faces in their data.

import bpy

context = bpy.context
scene = context.scene

for ob in scene.objects:
    ob.select_set(
            ob.type == 'MESH'
            and any(len(p.vertices) > 4 for p in ob.data.polygons)
            )

Evaluated mesh,

If applying modifiers is selected in the exporter, doing same on evaluated mesh

import bpy

context = bpy.context
scene = context.scene

dg = context.evaluated_depsgraph_get()

for ob in scene.objects:
    ob.select_set(False)
    ev_ob = dg.objects.get(ob.name) # hidden obs not in dg
    if ev_ob is None or ev_ob.type != 'MESH':
        continue  
    faces = ev_ob.data.polygons
    ob.select_set(
            any(len(f.vertices) > 4 for f in faces)
            )

The next thing to consider will be how to deal with the ngon faces, eg could poke or triangulate, ngons to make them tris.

One option would be to append a triangulate modifier instead of select

    if any(len(f.vertices) > 4 for f in faces):
        ob.modifiers.new("Tri", 'TRIANGULATE')
$\endgroup$
4
  • 1
    $\begingroup$ This works! Thank you for this! $\endgroup$
    – Zak Nelson
    Aug 2 at 15:24
  • $\begingroup$ For some reason, this only seams to be working when i copy and paste into another scene, then run the script. Otherwise, it seams to highlight several random objects. I'm not a great coder and don't know why this is. $\endgroup$
    – Zak Nelson
    Aug 2 at 16:16
  • 1
    $\begingroup$ Try now. Made an edit when realized a hidden object is not in depsgraph. Forgot to deselect non meshes. (Prior to this would have left their selection unchanged) $\endgroup$
    – batFINGER
    Aug 2 at 16:28
  • $\begingroup$ It seemed to only select the meshes on the first run of the script, but not on later runs. $\endgroup$
    – Zak Nelson
    Aug 2 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.