That's pretty impressive for just starting Tho I assume you had some help from ChatGPT with how some of those variables are named.
The problem looks like the lisp is only checking the variable SS and with a dialog box i guess you would have to close and open it again to allow the user to make a selection. this code would loop until a selection set ss is set. down side is you would either have to make a selection or hit esc to exit loop.
;;Execute button
(defun execute ()
(if (= flag 4)
(progn
(prompt "\nSelektujte linijske objekte za proracun ukupne duzine") ;adding "/n" in string is telling autocad to start newline
(if ss
(load_dialog dcl_id) ;do nothing
(progn
(unload_dialog dcl_id)
(prompt "\nNišta nije odabrano pokušaj ponovno")
(setq ss (ssget '((0 . "INSERT,*POLYLINE,LINE,ARC,SPLINE"))))
(execute) to test SS again
)
)
....
I would suggest having another button next to Execute like "Make Selection" or something. That way you can modify the selection without having to exiting the lisp and starting over.
Also these are the same.
(setq ss (ssget '((-4 . "<or") (0 . "INSERT,POLYLINE,LWPOLYLINE,LINE,ARC,SPLINE") (-4 . "or>"))))
(setq ss (ssget '((0 . "INSERT,*POLYLINE,LINE,ARC,SPLINE"))))