Skip to content

Import of certain meshes produces error with Maya vertex color importer #8

@Polymega

Description

@Polymega

With the .maps I've tested so far, they've been importing into Maya by-and-large without issue (including retaining vertex color information). However, for ap34.map, I receive the following warning in Maya and the geometry imports as a single mesh with no vertex color information intact:

# Error: RuntimeError: file C:/Users/John/Documents/maya/2022/scripts\ObjVColorMaya.py line 216: Can't read vColor! # 

Through some additional tests, this is only happening when I import the Opaque Mesh master group from the tool. If I import any of the Transparent or Decal master groups then it imports correctly, with vertex color information and separate groupings intact.

I'm not sure what's causing the import error for this particular map, but it might very well be an issue with other maps I haven't come across yet.

For that RuntimeError mentioned above, here is the portion of code relating to it:

    def vColorApply(self, objName, vColor):
        mSel = om2.MSelectionList()
        mSel.add(objName)

        mDag = mSel.getDagPath(0)
        mfnMesh = om2.MFnMesh(mDag)
        vtxCount = mfnMesh.numVertices

        if len(vColor) == vtxCount:
            mfnMesh.setVertexColors(vColor, range(vtxCount))
        else:
            mc.error("Can't read vColor!")
            return
        mc.polyOptions(mDag, cs=1)

And attached is the Python script in its entirety.
ObjVColorMaya.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions