MSTG007, I'm with CincyJeff. The (setq ang ....) is commented out. So it is likely failing in this section, not the one you pointed out:
((vl-position (setq name (vla-get-objectname x)) '("AcDbBlockReference" "AcDbText"))
(vla-put-rotation x ang) ;;<<<<<<<<<<<<<<
)