The zscript command reference is here:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/command-reference/
Here’s a way to do both types of file. But note that the OBJ example will only work with OBJs exported from ZBrush. To cope with other files you would need to either load them into ZBrush separately so you could check the vertex count that way or parse them using a dynamic library which you called from your zscript code.
IButton,CompareVertCountMDD,[COLOR=#f86b6b]“Check if the MDD file verts count is the same as selected mesh”,
VarSet,[COLOR=#c3dff9]fileVerts,0]
VarSet,[COLOR=#c3dff9]meshVerts,0]
//load the file 5th - 8th bytes into memory
MemCreateFromFile,[COLOR=#e1b8e1]MC_VertTestMem,[COLOR=#f86b6b]“boxing.mdd”,4,4]
MemCreate,[COLOR=#e1b8e1]MC_VertsLEMem,4,0]
//convert big endian to little endian:
MemCopy,[COLOR=#e1b8e1]MC_VertTestMem,3,[COLOR=#e1b8e1]MC_VertsLEMem,0]
MemCopy,[COLOR=#e1b8e1]MC_VertTestMem,2,[COLOR=#e1b8e1]MC_VertsLEMem,1]
MemCopy,[COLOR=#e1b8e1]MC_VertTestMem,1,[COLOR=#e1b8e1]MC_VertsLEMem,2]
MemCopy,[COLOR=#e1b8e1]MC_VertTestMem,0,[COLOR=#e1b8e1]MC_VertsLEMem,3]
//get the file verts number - unsigned long
MemRead,[COLOR=#e1b8e1]MC_VertsLEMem,[COLOR=#c3dff9]fileVerts,6,0]
//done with memblocks - delete
MemDelete,[COLOR=#e1b8e1]MC_VertTestMem]
MemDelete,[COLOR=#e1b8e1]MC_VertsLEMem]
//get the mesh verts number:
Mesh3DGet,0,[COLOR=#c3dff9]meshVerts]
If,([COLOR=#c3dff9]fileVerts == [COLOR=#c3dff9]meshVerts),
//OK they match
Note,[COLOR=#f86b6b]“OK, the verts number is the same”]
,//else they are different
Note,[COLOR=#f86b6b]“WARNING! the verts number is different”]
]
]
IButton,CompareVertCountOBJ,[COLOR=#f86b6b]“Check if the OBJ file verts count is the same as selected mesh”,
VarSet,[COLOR=#c3dff9]fileVerts,0]
VarSet,[COLOR=#c3dff9]meshVerts,0]
VarSet,[COLOR=#c3dff9]vertsStr,[COLOR=#f86b6b]""]
VarSet,[COLOR=#c3dff9]offset,0]
VarSet,[COLOR=#c3dff9]bytes,0]
//load first part of OBJ file into memory
MemCreateFromFile,[COLOR=#e1b8e1]MC_VertTestMem,[COLOR=#f86b6b]“boxing.obj”,0,512]
//check the comment lines for ZBrush vertex count entry
Loop,5,
VarSet,[COLOR=#c3dff9]bytes,MemReadString,[COLOR=#e1b8e1]MC_VertTestMem,[COLOR=#c3dff9]vertsStr,[COLOR=#c3dff9]offset,1]]
VarAdd,[COLOR=#c3dff9]offset,[COLOR=#c3dff9]bytes]
If,(StrFind,[COLOR=#f86b6b]"#Vertex Count ",[COLOR=#c3dff9]vertsStr]==0),//if entry is there
VarSet,[COLOR=#c3dff9]vertsStr,StrExtract,[COLOR=#c3dff9]vertsStr,14,256]]
VarSet,[COLOR=#c3dff9]fileVerts,[COLOR=#c3dff9]vertsStr]
LoopExit]
]
]
//get the mesh verts number:
Mesh3DGet,0,[COLOR=#c3dff9]meshVerts]
If,([COLOR=#c3dff9]fileVerts == [COLOR=#c3dff9]meshVerts),
//OK they match
Note,[COLOR=#f86b6b]“OK, the verts number is the same”]
,//else they are different
Note,[COLOR=#f86b6b]“WARNING! the verts number is different”]
]
]