Previous Thread  Next Thread

chat icon understanding problem vertex_groups method

drlolig

Posted: Tue Nov 27, 2012 1:28 pm
Joined: 27 Nov 2012
Posts: 1
hello,

i want to check the wall thickness of an object, i ve a good working script for blender 2.49,
i converted all the code to python blender 2.6, because blender 2.6 can run in the background.

Code:
def PaintVertices(me, vertIndList, paintAmt, group):
      if paintAmt >= 0.1:  # Prevents float rounding errors and so forth from potentially troubling us; we refuse to paint anything under 10%.
         for vertInd in vertIndList:
            try:
               currentState = me.getVertsFromGroup(group, 1, [vertInd])
               if currentState and currentState[0][1]:
                  curPaint = currentState[0][1]
               else: curPaint = 0.0
            except AttributeError: curPaint = 0.0
            except RuntimeError: curPaint = 0.0
         
            if not curPaint:
               me.assignVertsToGroup(group, [vertInd], paintAmt, AssignModes.ADD)
               #print "Newly painting vert {0:d} to {1:.1%}.".format(vertInd, paintAmt)
            elif paintAmt > curPaint:
               me.assignVertsToGroup(group, [vertInd], paintAmt, AssignModes.REPLACE)
               #print "Repainting vert {0:d} from {2:.1%} to {1:.1%}.".format(vertInd, paintAmt, curPaint)
            else:
               #print "Declining to paint vert {0:d} to {1:.1%}, since it's already at {2:.1%}.".format(vertInd, paintAmt, curPaint)
               pass


i don t know to do some thing with me.getVertsFromGroup(group, 1, [vertInd])

my code, but don t work:




Code:

        def PaintVertices(ob, vertIndList, paintAmt, group):
                if paintAmt >= 0.1:
                       for vertInd in vertIndList:         
                                try:
                                        currentState = ob.vertex_groups[group]
                                        if currentState.index == vertInd:
                                                if currentState and currentState[0][1]:
                                                        curPaint = currentState[0][1]
                                                else: curPaint = 0.0
                                except AttributeError: curPaint = 0.0
                                except RuntimeError: curPaint = 0.0
                               
                                if not curPaint:
                                        ob.vertex_groups[group].add([vertInd], paintAmt, type='ADD')
                                elif paintAmt > curPaint:
                                        ob.vertex_groups[group].add([vertInd], paintAmt, type='REPLACE' )
                                else:
                                        pass



mfg drlolig
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group