[Bf-python] nmesh.getMode() nmesh.setMode : inconsistent !

Gert De Roost paleajed at yahoo.com
Thu Feb 17 17:23:38 CET 2005


What makes matters worse, the setMode() method doesn't
accept empty strings as input, so you must take into
account the number of modes you want to set.
This is the code I had to write to turn Optimal mode
off and back on:

# Turn off Optimal mode if set.
optimalwitch = 0
modes = []
modeflags = mesh.getMode()
if modeflags & 256:
	optimalswitch = 1
	if modeflags & 2:
		modes.append("NoVNormalsFlip")
	if modeflags & 4:
		modes.append("TwoSided")
	if modeflags & 32:
		modes.append("AutoSmooth")
	if modeflags & 128:
		modes.append("SubSurf")
	if len(modes) == 0:
		mesh.setMode()
	if len(modes) == 1:
		mesh.setMode(modes[0])
	if len(modes) == 2:
		mesh.setMode(modes[0], modes[1])
	if len(modes) == 3:
		mesh.setMode(modes[0], modes[1], modes[2])
	if len(modes) == 4:
		mesh.setMode(modes[0], modes[1], modes[2], modes[3])


# Turn Optimal mode back on if necessary.
if optimalswitch:
	if len(modes) == 0:
		mesh.setMode("Optimal")
	if len(modes) == 1:
		mesh.setMode(modes[0], "Optimal")
	if len(modes) == 2:
		mesh.setMode(modes[0], modes[1], "Optimal")
	if len(modes) == 3:
		mesh.setMode(modes[0], modes[1], modes[2], 
Optimal")
	if len(modes) == 4:
		mesh.setMode(modes[0], modes[1], modes[2], modes[3],
"Optimal")


Brrrrrrrrrr, ugly !


.gert.



--- Gert De Roost <paleajed at yahoo.com> wrote:

> There seems to be a blatant inconsistency in the
> format of the nmesh.getMode() and nmesh.setMode()
> methods.
> 
> The first returns an OR'ed flag while the second
> takes
> multiple strings as an argument.
> 
> When, for example, you want to turn off Optimal mode
> if it is turned on,  you need to read the OR'ed
> flag,
> check for the Optimal flag, read every other bit,
> see
> if it's turned on, assign the corresponding string
> (to
> feed into setMode()) to a string variable (which you
> need to put back to "" every time you call this
> subroutine) and then feed all those strings into
> setMode().  
> 
> This really should be: getMode() OR'ed flag, put
> Optimal bit to 0, feed new flag into setMode().
> 
> or:
> 
> getMode() modes-list-consisting-of-strings, pop the
> optimal string if it's there, feed new list into
> setMode().
> 
> So both methods should either use lists of strings
> or
> OR'ed flags for consistency.
> 
> Please do sacrifice backward-compatibility to
> correct
> this.
> 
> .gert.
> 
> Bf-python mailing list
> Bf-python at projects.blender.org
>
http://projects.blender.org/mailman/listinfo/bf-python
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250



More information about the Bf-python mailing list