def DoIt(h5): global reset,xP,yP, vcnt, ocnt, mcnt ### for h4 in hVP: count(h4) ### vs.AlrtDialog(ocnt) #Displays current count but for somereason is adding the previous count to the current count vcnt = ocnt = mcnt = 0 #reset to variable to 0 vs.AlrtDialog(ocnt) #displays that variable has been reset to 0count() is where you're setting them. You call count() before you reset them. That's why they have values before you reset them.
And wackiness like that is exactly why you should avoid using globals at all cost. They're hard to debug, and extremely lazy. What's wrong with just returning whatever values you want to use from a function?
import vs #reset = xP = yP = vcnt = ocnt = mcnt = 0 def count(h4, ocnt, vcnt, mcnt): # global vcnt, ocnt, mcnt ocnt += 1 if vs.GetTypeN(h4) == 5: vcnt += vs.GetVertNum(h4) if vs.GetTypeN(h4) == 21: vcnt += vs.GetVertNum(h4) if vs.GetTypeN(h4) == 40: mcnt += 1 return [ocnt, vcnt, mcnt] def DoIt(h5): #global reset,xP,yP, vcnt, ocnt, mcnt ocnt, vcnt, mcnt = (0, 0, 0) if h5 != []: if vs.GetTypeN(h5) == 16: GetHandles(h5) for h4 in hVP: ocnt, vcnt, mcnt = count(h4, ocnt, vcnt, mcnt) vs.SetRecord(h5,'Obj Count') vs.SetRField(h5,'Obj Count','Obj Count',vs.Num2Str(0,ocnt)) vs.AlrtDialog(ocnt) #Displays current count but for somereason is adding the previous count to the current count vcnt = ocnt = mcnt = 0 #reset to variable to 0 vs.AlrtDialog(ocnt) #displays that variable has been reset to 0