ZBrushCentral

Polygon vertex position

Hello, I would like to do a zscript that copies different subtools on the surface of another subtool.like a automated insertmesh …
for that I need the vertex positions…
I already figured out a way of getting this info but it’s kind of complicated and slow… I wonder if there is a faster , more elegant way …maybe working with the obj file?

You can always export an OBJ, process it using zscript (or a custom DLL) and then re-import. What method you use really depends on what you are trying to do. ZScript commands that work with the mesh are very limited.

There is a way inside ZBrush with Zscript, to find the coordinates of the center of each face within a random mesh, if this is helpful

The general idea is:
[Mesh3DGet, 1, faceCount] - get the face count
AUVTiles - to have separate UV tile for each face
Auto Groups With UV - to have separate polygroup for each face
This gives an automatic way for selecting each face within a random mesh.
Groups Split - separates each individual face as subtool and now you can go trough each face(as subtool) and store it’s position to an array.

This is a simple procedure, but the problem is that you have limit when you try to separate too many polygroups and it is not that fast.
Wtih Plane 32x32 (961 faces) it works and above that it doesn’t.

Attachments

ZBrush Document.jpg

scatter.jpg

Looks cool, thanks for that. Is this line supposed to be there twice?
" [IPress, Tool:Deformation:Repeat To Active]

Doug Jones Looks cool, thanks for that. Is this line supposed to be there twice?
[IPress, Tool:Deformation:Repeat To Active]

No, it was just a quick test, it could be done better. :slight_smile:

Thanks Zigrapher and Marcus! That’s very helpful information.I don’t know any programming language or c++ . By now, I m stuck with what Zscript can do , which I think it’s a lot.

Zigrapher,The way I got the vertex positions inside zscript is actually in the Ztree plugin . it probably has size limitation as well. Probably more than your solution but I don’t really know. I haven’t tried it with large meshes…
My solution for that is : from a zsphere, select topo ,to convert the vertex to Zspheres , or topology-zspheres… so you can get their position with ZSPhereGet. It works with ZTree’s copyzs and pastezs.
But I think your solution could work very well for what I want

Maybe, to scatter on top of large meshes , we could work on a decimated version of the tool. it would be cool if it could make 50 or 100 instances of different subtools and randomly scale and rotate them. I don’t think we need 1000 vertex positions… I don’t really need every vertex info but an overall position.

The general idea would be to have a tool with, lets say 5-10 subtools(like the ones you prepare for IMMBrushes) and replicate them on top of another mesh.

Edited:

well I tested it again and it seems edit topo can handle 15000 topo-Zspheres so I think that’s the way to go. I don’t need to make a big variable list , maybe just lelect 100 random zspheres and use their position… I know I will probably need help but I think this will work.

Well, I tried it and I don’t think it’s a good idea… I got it to work but it’s very slow, and also when I switch subtools and append them to the base mesh it keeps changing the original subtool names… so It’s a little bit of a pain. probably there is a way to fix it but I am not sure if I want to go in this direction… I think it would be a lot better to use the IMM brush and reproduce strokes rotating the view and framing with every new Stroke…but if I had faces that are very occluded they wouldn’t receive any copy…
The good news is :The part of getting vertex positions works fine

I saved a project to use with the script,
there is a tool called base . Then the tools I want to copy: there are 2 tools with 12 subtools each. they are the same with different names… One works, at least the first time, and the other doesn’t…
you first choose the tool(with subtools) you want to clone, click on “clonethis”, and then the base and click "onThis’…

Very interesting, that gives me an idea or three :wink: