bbqcake / ZhCG_PolyTools_2023

ZhCG_PolyTools ported to python 3
13 stars 1 forks source link

Edit Facet: errors involving mixed floats and integers #1

Open impivot opened 1 year ago

impivot commented 1 year ago

Hello! Thanks for porting this script over to 2023 (and python3), its invaluable.

I used to use the Edit Components > Edit Facets part of the tool a lot to make connected quad-grids out of n-gons and fix topology direction, but that part of the script is broken in some places. Selecting face(s) and clicking on Edit Facets gives this error: # Error: line 1: TypeError: file [...]/maya/scripts\zhcg_polyTools.py line 4291: 'float' object cannot be interpreted as an integer

Line 4291 is

 for i in range(tem_vtxNum / 2 - 2):

I'm absolutely no good at python, but I was told that replacing the / division operator with the // floor division operator (to get an integer-only result) would fix this, and it did. Using the spin dialog would also throw an error on line 4071, which has a similar division setup and is fixed the same way. Doing a search through the code, it seems there are other / division operations on lines 4361 and 4145 which might also run into the same issue (I just changed those two as well).

That fixed most of the Edit Facet issues, however if you go into the spin dialog and do a 90-degree turn (easiest to find on a ribbon-type selection) you'll encounter this error: # Error: line 1: TypeError: file [...]/maya/scripts\zhcg_polyTools.py line 4072: list indices must be integers or slices, not float

Turns out thats because Line 4070 also has a regular division operator to replace with floor division:

step = vtxNum / 4 if speed == 3 else speed

There's probably more integer-float division mixes around, but fixing those let me use Edit Facets again so that was enough for me. The spin dialog box displays the numbers for x-ribbon and x-star as decimals (10.0-star, 6.0 ribbon, etc) which is probably also a float/integer thing, but I don't know where/how to fix that and it's (seemingly) just visual.

bbqcake commented 1 year ago

Thank you so much for taking the time to find these bugs and fixing them. I really do appreciate it. I have implemented your fixes, updated the script on github and credited you in the readme.

I updated the dialog box to not show decimals. I wouldn't even have noticed if it wasn't for you. So thanks again! The fix for that was a few lines inside of def editFacet(): Just floored those values.

I found another bug while testing everything out. Currently spin is broken if you select verts instead of edges. I'll take a look at that within the next couple of days and see if I can see what's causing it.

giovanniakp commented 1 month ago

I think the old code from ZhCG behaves the same way in regards to spin? if the selected verts are shared between a centre edge in tris, or near a tris face, or near a star/pole, then it won't spin at all. The selected verts must be surrounded by all quads faces (and no pole) I think for it to work with vertices selection . There is no problem when edge is selected, it can spin just fine near any tris/star/poles even N-Gon. Tested in maya 2018-2020. So I think it's just how the original code/calculation works? We also now have built-in tool from Maya to spin edge in Edit Mesh menu anyway (only work with edges).

bbqcake commented 1 month ago

I think the old code from ZhCG behaves the same way in regards to spin?

I used to compare the original script 2022 and the modified one in 2023. I no longer have access to 2022, but I believe you're right.

Sorry I haven't responded faster and thanks a lot for fixing the version number,