Angle between lines by group of polycurve

Good morning colleagues … I am new to dynamo and I was doing a practice and I ran into an angle problem and developed a Script …
The script works when I take a group of lines … but stops working when there are several groups … ??? why does that happen … can you help me understand and solve it …



ANGULOS ENTRE LINEAS_PRUEBA.dyn (32.5 KB)
Angulos entre lineas.rvt (1.5 MB)