In the following code you have to select the polyline which works fine Is there a method of modifing the code to run if the polyline is ALREADY selected if not select polyline thank you (defun VL-POLY () ;get the entity and entity name (setq THEPL (car (entsel "\nSelect a Walk Polyline: ")) ;convert to vl object THEOBJ (vlax-ename->vla-object THEPL)) ;check if it's a polyline (terpri) (if (= (vlax-get-property THEOBJ 'OBJECTNAME) "AcDb3dPolyline") (progn (setq WALKNO (substr (vla-get-layer THEOBJ) 1 5) ; layer name C_TIME (menucmd "M=$(edtime,$(getvar,date), DD-MO-YY HH:MM:SS)") WALT " " ; 6 dummy spaces for altitude IDENT "AA" WALKLT (getstring "n\Enter T=Altitude Z=Zero altitude ")