As you’ve found, there’s no easy way to do this. The suggestion posted by JRoC is probably as good a way as any.
However, in case it’s of interest, here’s a way to check for groups in an OBJ file, using just zscript. (A dll would be quicker!) I found there are issues reading strings when the file size gets large (over about a million polys), which is why I split it into chunks. (I’ve not managed to find out what restriction causes ZBrush to stop reading the string.) Also I use a rough-and-ready method to start reading in the middle of the file as ZBrush always writes the faces after the vertices.
This is a bare bones solution which doesn’t do any error checking. It would be probably sensible to export the lowest res, if there is one.
It doesn’t check for parts. That would involve using Auto Groups in a similar way to JRoC’s solution. It’s perhaps also worth pointing out that you can have groups and parts together!
[IButton,CheckGroups,“Check a mesh for PolyGroups”,
//set export options (should be reset after)
[IPress,Tool:Export:Qud]//export quads
[IUnPress,Tool:Polypaint:Colorize]//don’t want polypaint exported
[IUnPress,Tool:Export:Txr]//don’t want texture coords exported
[IUnPress,Tool:Export:Flp]
[IPress,Tool:Export:Mrg]
[IPress,Tool:Export:Grp]
//export the OBJ
[FileNameSetNext,“output.obj”]
[IPress,Tool:Export]
//load into memory
[VarSet,fSize,[FileGetInfo,“output.obj”,1]]
[VarMul,fSize,1024]
[VarMul,fSize,1024]//file size in bytes
[VarSet,fSize,INT(fSize)]
[VarSet,bytesToMem,1024]
[VarSet,pnts,0]
[Mesh3DGet,0,pnts]//number of points
[If,fSize > 65536,
[VarSet,fOffset,INT(pnts*25)]//approx total bytes for vertex lines
[VarSet,lpNo,INT((fSize - fOffset)/bytesToMem)]
,
[VarSet,fOffset,0]
[VarSet,lpNo,INT(fSize/bytesToMem)]
]
[VarInc,lpNo]
[VarSet,objLine,""]
[VarSet,found,0]
[VarSet,grps,0]
[VarSet,grp1OK,1]
[Loop,lpNo,
[MemDelete,ZZ_OBJMem]//make sure this isn’t around
//load chunk of file into memory
[MemCreateFromFile,ZZ_OBJMem,“output.obj”,fOffset,bytesToMem]
[VarSet,offset,0]
[VarSet,bytes,0]
//read all the strings in the chunk
[Loop,100,
[VarSet,bytes,[MemReadString,ZZ_OBJMem,objLine,offset,1]]
[VarSet,offset,offset+bytes]
[If,offset >= [MemGetSize,ZZ_OBJMem],[LoopExit]]
[If,([StrFind,"g ",objLine] == 0),
[If,grp1OK,//if it’s the first group we’ve found
[VarSet,group1,objLine]//record it
[VarSet,grp1OK,0]//make sure we only record the first time
, //else check for different group
[If,([StrLength,group1]==[StrLength,objLine])&&([StrFind,group1,objLine] == 0),
//same group - do nothing
,//else we have a new group
[VarSet,grps,1]
[LoopExit]//we don’t need to check any more
]
]
]
]//end loop
[VarAdd,fOffset,bytesToMem]//offset for next chunk
[If,fOffset >= fSize,[LoopExit]]//exit if end of file
[If,grps,[LoopExit]]//exit if groups found
]//end loop
//display result
[If,grps,
[Note,“There are groups”]
,
[Note,“There are NO groups”]
]
//clean up
[MemDelete,ZZ_OBJMem]
]//end button