Select geometry from UV/Image-selection (Update: Now with script)

Is there a way to select 3D geometry (3D Mesh Edit mode) from uv-selections in the UV/Image Editor?

I come across this situation quite often and I wonder if there is a quick way of doing this.
Lets say I have an UV-mapped mesh and just selected a few UV-faces in the UV/Image editor that I can’t find in the 3D-view. Is there a way to make transfer the selection I made in the uv-editor to the 3D-view?

Dunno if I explained this clear enough … i can make pictures if it isn’t :slight_smile:

Werner

If I understand, you can chose Select->Active Face Select in the uv image editor, and then click on the face, and it will be outlined in the 3d view.

Yes, I know of that. The main problem with "Active Face Select"is that it only highlights (not select) the selected face and that it is only for one face. Also if the face(s) is/are hidden inside the mesh it’s a pain to find them all :frowning:

The problem is that often I have a whole bunch of faces in the UV image editor that I want to have selected in the geometry window edit-mode to do stuff with them. I have not found a way to do that yet.

I really wonder if I’m the only one who ever though this would be a good thing to have?

Werner

I see. What I do is select the face I cannot find in the uv, and then look for it in the 3d. You will know it is close to something you can see.

Then in the 3d in I use the B to box select, or BB to select a group of faces and press H to hide them. Then I can usually find the hidden face/faces.

It is cumbersome, but it works.

Hi,

“active face select” or (key C) in UV/Image editor does switch between whole face and single vertex selection. It helps working in the UV editor, but it’s just a selection making shortcut.

As it is, the selection hierarchy is from 3D to 2D, what you’ve selected in (3D) Face select is accessible in (2D) UV select, not the other way around. I do agree, it would be helpful to switch dependency sometimes, especially when looking for some hidden faces. :yes:

Regards

i think in both the UV and 3D you can B box select as well as in that face select mode shift-select multiple faces. but you are correct; that does not select faces. in fact, only UVs for selected faces are shown in the UV window when you enter UV Face Select mode. there is no way presently to do other than highlight faces by selecting them first in the UV window; because you are in UV Face Select mode not Edit mode in the 3D view. When you return to Edit mode, you revert back to the faces originally selected before entering the UV Face Select mode.

That’s all so true, but the problem is this: Sometimes it’s hard to see the relation between model and UV-map for some tiny parts.

If you know what you’re looking for on the model, it’s easy. Select in UV face select and matching UVs get highlighted in UV edit window.

But the other way around? Imagine there are some UV coordinates you’d like to locate on your model? You could try to assign a different texture (or none at all) but there’s no way to synchronize between UV edit and UV select with the editor first. Other than the tiny red and green edge on the active face, that is…

Regards

Thanks to all for the answers and explanations. So it is as I suspected, and I now know that I’m not alone with this thing … I could just have missed a ‘hidden’ feature after all :slight_smile:

A function like

  • Select -> Geometry from (selected) UVin the uv/image editor would help a lot here, but I suspect that’s best done with a python script rather than by bothering the main devs with it :wink:

Werner

Wow that script was easy to make :slight_smile: Critics, and Suggestions are welcome.


#!BPY
"""
Name: 'Select faces from UV selection'
Blender: 244
Group: 'FaceSelect'
Tooltip: 'Uses your selection in the UV Editor to select the same faces in the mesh editor.'
"""
__author__ = "Werner Hoehrer"
__url__ = ("blender", "elysiun")
__version__ = "1.0 2007-06-25"

__bpydoc__ = """\
Uses your selection in the UV Editor to select the same faces in the mesh editor.
"""

# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Werner Hoehrer 
# Thanks to Campbell J Barton for his scripts that I used as a template.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------


from Blender import *
import bpy

def main():
    sce = bpy.data.scenes.active
    ob = sce.objects.active
    
    if ob == None or ob.type != 'Mesh':
        Draw.PupMenu('ERROR: No mesh object in face select mode.')
        return
    me = ob.getData(mesh=1)

    if not me.faceUV:
        Draw.PupMenu('ERROR: No mesh object in face select mode.')
        return

    faces = [f for f in me.faces if f.sel]
    print "INFO", len(faces), "selected faces found in edit mode."
    
    counter = 0
    #for face in faces:
    for face in me.faces:
        if (face.sel):
            for uvvert_sel in face.uvSel:
                if not uvvert_sel:
                    face.sel = 0    # unselect face in edit mode.
                    counter = counter + 1
                    break

    print "INFO", counter, "faces dropped."
    Window.RedrawAll()

if __name__ == '__main__':
    main()

EDIT2: The script is now located in face edit mode: Select -> Select faces from UV selection

Is there a way to have it in “UV” as well?

Werner

Hi

the script works nicely, thank your very much for the effort!

Regards

The next script - invert the selection in the UV/Image editor (faces or vertices):


#!BPY
"""
Name: 'Invert Selection'
Blender: 244
Group: 'UV'
Tooltip: 'Inverts the current selection in the UV/Image Editor.'
"""
__author__ = "Werner Hoehrer"
__url__ = ("blender", "elysiun")
__version__ = "1.0 2007-06-25"

__bpydoc__ = """\
Inverts the current selection in the UV/Image Editor.

You can choose if the selection of faces or the vertices should be inverted.
i.e. no partly selected faces are left when choosing "Faces".
These faces are are simply ignored and handles like unselected faces.
"""

# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Werner Hoehrer 
# Thanks to Campbell J Barton for his scripts that I used as a template.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------

# See also http://www.blender.org/documentation/244PythonDoc/Mesh.MFace-class.html#uvSel

from Blender import *
import bpy

def main():
    sce = bpy.data.scenes.active
    ob = sce.objects.active
    
    if ob == None or ob.type != 'Mesh':
        Draw.PupMenu('ERROR: No mesh object in face select mode.')
        return
    me = ob.getData(mesh=1)

    if not me.faceUV:
        Draw.PupMenu('ERROR: No mesh object in face select mode.')
        return

    result = Draw.PupMenu("Invert what?%t|Faces|Vertices")
    
    if result==1:
        # Invert faces
        for face in me.faces:
            new_uvSel_selected = []
            new_uvSel_unselected = []
            everything_selected = TRUE
            for uvvert_sel in face.uvSel:
                if not uvvert_sel:
                    everything_selected = FALSE
                new_uvSel_selected.append(1)
                new_uvSel_unselected.append(0)
            
            if (everything_selected):
                face.uvSel = new_uvSel_unselected
            else:
                face.uvSel = new_uvSel_selected
    elif result==2:
        # Invert vertices
        for face in me.faces:
            new_uvSel = []
            for uvvert_sel in face.uvSel:
                new_uvSel.append(int(not uvvert_sel))
            face.uvSel = new_uvSel
    Window.RedrawAll()

if __name__ == '__main__':
    main()

Does anybody know what group I need to use to get the script into the “Select” menu in the UV/Image editor?

Werner

Does anybody know what group I need to use to get the script into the “Select” menu in the UV/Image editor?
Invert can already be found in the select menu.

I ported “Selection from UV selection” to c. The patch can be found at https://projects.blender.org/tracker/index.php?func=detail&aid=6884&group_id=9&atid=127 . Feedback, improvement ideas and testing is appreciated.

Uhm, in 2.44 the UV/Image Editor doesn’t have any option to invert the selection. The “UV face select” mode in the 3D view has one though, but that isn’t really what my script does :).
Maybe the cvs version already has this? And does it also check for faces vs. vertices like i built into the python script above?

Cool :slight_smile: Unfortunately I can’t test it, but I fully support its including in the main code :slight_smile:
See also the comments by ideasman42 in this thread.

Werner

Maybe the cvs version already has this? And does it also check for faces vs. vertices like i built into the python script above?

I referred to the svn version. It just inverts selection status of each vertex. Expanding the functionality might be possible too.

It may be possible that whole selection concept could be reviewed at some point (selection modes to uv/image editor?). Improvement ideas for new selection tools are of course welcome. I am interested in seeing proper use cases and specifications for them.

I though so :slight_smile: Ok, i’ll have to wait for the next version or use one of the pre-builds then to chek it out.

It may be possible that whole selection concept could be reviewed at some point (selection modes to uv/image editor?). Improvement ideas for new selection tools are of course welcome. I am interested in seeing proper use cases and specifications for them.
One very basic example of a non-vertex inversion of a selection in the uv/image editor is this:

  • There are two connected faces
  • You select one of them
  • “Inverse” the selection …

With “Vertex Inversion” you now only have part of the other face selected (1 or 2 vertices). From your description i suspect this is in svn already.

With “Face Inversion” you now have the other face selected (including some vertices from the initially selected face) -> you can test this with my python script. Think: inverse selection behaviour in 3d mesh edit mode (face selection mode)

Of course in most situations there are a lot more faces/vertices making the second way a lot more useful (prevents you from manually deselecting unwanted vertices)

Selection modes in the UV/Image editor like in mesh-edit mode like you mentioned would be the better solution I think though.

Werner