@juancarreras, below seems to do the same as the rvb above using the converted function:

```
# original Script written by Jarek Bieda
import Rhino
import rhinoscriptsyntax as rs
from math import atan2, pi, asin
def ResetBlockZRotation():
f = 0
block = rs.GetObject('Block Instance ?', 4096, True)
r = DecomposeXformRotation(rs.BlockInstanceXform(block))
v = round( r[2] * -180/pi, 0) + f
if v < 0: v += 360
rs.RotateObject(block, rs.BlockInstanceInsertPoint(block), v, False)
print("Block rotation reset to zero")
def DecomposeXformRotation(arrXform):
arrRotate = Rhino.Geometry.Point3d.Unset
arrRotate.X = atan2(- arrXform.M21, arrXform.M22)
arrRotate.Y = asin(arrXform.M20)
arrRotate.Z = atan2(arrXform.M10, arrXform.M00)
return arrRotate
ResetBlockZRotation()
```

## note that i added some imports and removed the ones not required.

c.