Hello Michael,

Thanks for the support on this it is much appreciated.

I was not aware that I was using API 1.0, I have been reading the C++ docs
for my reference so I assumed it was the correct API. I will make the
switch to 2.0.

The selection of the UVs is just a visual test to check that I am getting
the correct number of borders so we can ignore that issue (I switch UV sets
to make sure in my tests)

The reason I am only counting UVs on seams is those are the only ones that
split the vertex when we use them in the engine. We are trying to
"guess-timate" the total vert count before we jump into the engine so the
artist can be as efficient as possible with their source maya files and
using the UVs for the time being can get us as close as possible.

Not all faces have UVs in uvSet that I can confirm for sure so the lists
are out of sync. What if I iterated the face vertices and checked each
vertex has UVs first and then cross referenced each list?


On 13 November 2017 at 00:46, Michael Boon <boons...@gmail.com> wrote:

> Hi Ben,
>
> I can't see your image, but I can run your code on a mesh of my own. In
> really basic tests it seems to work correctly.
> It's a bit tricky to read through. There's a fair bit of temp code in
> there, and things that are assigned and not used. Also, why are you using
> Python API 1.0? It's more difficult to use than 2.0 (unless you're more
> familiar with C++, I guess).
>
> There are a few ways it could go wrong.
>
>    - The most likely problem, I think, is that the code I gave you
>    assumes that every face has UVs. I said "Note that verts with no UVs will
>    not be counted at all this way. You might want to add a check that every
>    set has at least one element in it," and that the two face lists (from
>    getVertices and getAssignedUVs) will be identical. That was incorrect. If
>    any faces have no UVs, they will get a 0 in the face list from
>    getAssignedUVs and your vertex ID and UV ID lists will no longer 
> correspond.
>    - There's also the problem that selecting '{0}.map[{1}]' will select
>    UVs in the currently active UV set, which may or may not be 'uvSet'. You
>    can set the currently active UV set in script, or in the UV Editor.
>    - The basic idea of doing "totalVertCount = sum(len(s) for s in
>    vertUVIDs if len(s)>1)" seems flawed to me. You're only counting verts
>    that are on seams. How are you going to use that number?
>
> If you can get your image attached properly (I think the problem is at
> your end...), and confirm that your mesh has UVs for all faces in 'uvSet',
> we can build up from there.
>
>
> On Saturday, 11 November 2017 01:10:22 UTC+11, Benjam901 wrote:
>>
>> Hey Michael,
>>
>> I copied some UVs into a new UV map and tried the same method and to
>> highlight what was happening I am selecting the UVs.
>>
>> For the 2nd UV set however the method looks like it fails, when I select
>> the UVs it selects almost all the verts in the map.
>>
>> I amended the code to give me the additional vert count i.e. verts only
>> on seams adn the output for the 2nd map is 166 which is not correct.
>>
>> Can you replicate this error also?
>>
>> Code and screenshot is below:
>>
>> import pymel.core as pm
>> import maya.OpenMaya as OM
>> from itertools import izip
>>
>> sel = pm.ls(sl=True)[0]
>> selName = str(sel.nodeName())
>>
>> mSelList = OM.MSelectionList()
>> OM.MGlobal.getActiveSelectionList(mSelList)
>> sel = OM.MItSelectionList(mSelList)
>> path = OM.MDagPath()
>> sel.getDagPath(path)
>> fnMesh = OM.MFnMesh(path)
>>
>> vertCount = OM.MIntArray()
>> vertList = OM.MIntArray()
>>
>> uvCounts = OM.MIntArray()
>> uvIDs = OM.MIntArray()
>> #uvSet='map1'
>>
>> set2 = 'uvSet'
>> tempSets = ['map1', 'uvSet']
>>
>> additional = 0
>>
>> #for uvSet in tempSets:
>> fnMesh.getVertices(vertCount, vertList)
>> #fnMesh.getAssignedUVs(uvCounts, uvIDs, uvSet)
>> fnMesh.getAssignedUVs(uvCounts, uvIDs, set2)
>>
>> vertUVIDs = [set() for _ in range(fnMesh.numVertices())]
>>
>> for vID, uvID in izip(vertList, uvIDs):
>>     vertUVIDs[vID].add(uvID)
>>
>> totalVertCount = sum(len(s) for s in vertUVIDs if len(s)>1)
>> additional += totalVertCount
>> print additional
>>
>> totes = [i for i in vertUVIDs if len(i) > 1]
>> for i in totes:
>>     for j in i:
>>         pm.select('{0}.map[{1}]'.format(selName, j), add=True)
>>
>>
>>
>> [image: Inline images 1]
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/python_inside_maya/5rvHKbU9ipM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/5c8e3e30-ad49-4d04-ae11-
> 2a446fdf81dc%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/5c8e3e30-ad49-4d04-ae11-2a446fdf81dc%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Tel - +46 76245 92 90 (Sweden)
LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkUC4WT5aisVjHgAew7b8wugcZxKPtqGaVt23fMuELTR1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to