Feb-12-2021, 06:56 PM
Then why do you wait until 4 lines after the loop before you reset the counts?
This is bad way to write code, using global variables to pass values between functions. What about doing something like this?
This is bad way to write code, using global variables to pass values between functions. What about doing something like this?
def count(h4, vcnt, mcnt): 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 vcnt, mcnt def DoIt(h5): global reset,xP,yP if h5 != []: if vs.GetTypeN(h5) == 16: print('reset') GetHandles(h5) vcnt = mcnt = 0 ocnt = len(hVP) for h4 in hVP: vcnt, mcnt = count(h4, vcnt, mcnt) vs.SetRecord(h5,'Obj Count') vs.SetRField(h5,'Obj Count','Obj Count',vs.Num2Str(0,ocnt)) vs.AlrtDialog(ocnt) vs.AlrtDialog(ocnt) vs.SetRField(h5,'Obj Count','Vertex Count',vs.Num2Str(0,vcnt)) vs.SetRField(h5,'Obj Count','Mesh Count',vs.Num2Str(0,mcnt)) vs.Symbol(vs.GetSDName(h5),xP,yP,0) xP += 300 if xP > 5000: xP = 0 yP += 300