Charpzy Posted December 1, 2022 Posted December 1, 2022 When I cancel out of my function it still runs the script, i'm trying to make it so it just cancels out the function completely without any addition text being printed at the moment when hitting cancel or esc, it prints: "Select Object Curve (Arc, Circle, Line, Polyline or Spline) Cancel Error: Function cancelled" my code: (defun c:CONELINE (/ ent len MSpace dist *error*) (defun *error* (msg) (princ (strcat " Error: " msg)) (princ) ) (defun upDateImage (sldName key) (setq width (dimx_tile key)) (setq height (dimy_tile key)) (start_image key) (fill_image 0 0 width height 0) (slide_image 0 0 width height sldName) (end_image) ) (defun updater (ent) (upDateImage (strcat "C:\\BricsCAD Scripts\\MACROS\\SLIDES\\" ent ".sld") "preview") ) (If (setq fn (findfile "MACROS\\DIALOGS\\CONELINE.dcl")) (setq dlg_id (load_dialog fn)) (alert "Dialog CONELINE.dcl not found") ) (new_dialog "CONELINE" dlg_id) (updater "CONE_LINE") (if (= lastSel Nil) (progn (set_tile "t1" "1") (mode_tile "parking_spacing" 1) (setq block "BOLLARD") (setq fileName "CONEORBOLLARD") ) (set_tile lastSel "1") ) (if (= colSel Nil) (set_tile "t1" "1") (set_tile colSel "1")) ;TYPE SELECTION (action_tile "t1" "(updater \"CONE_LINE\") (setq colSel \"t1\") (mode_tile \"cone_spacing\" 0) (mode_tile \"parking_spacing\" 1) (setq block \"BOLLARD\") (setq fileName \"CONEORBOLLARD\")") (action_tile "t2" "(updater \"PARKING_CONES\") (setq colSel \"t2\") (mode_tile \"cone_spacing\" 1) (mode_tile \"parking_spacing\" 0) (setq block \"PARKINGBOLLARD\") (setq fileName \"PARKINGCONE\")") ;SPACING SELECTION ;cone (action_tile "c10" "(setq lastSel \"c10\") (setq spacing 1)") (action_tile "c15" "(setq lastSel \"c15\") (setq spacing 1.5)") (action_tile "c20" "(setq lastSel \"c20\") (setq spacing 2)") (action_tile "c30" "(setq lastSel \"c30\") (setq spacing 3)") (action_tile "c40" "(setq lastSel \"c40\") (setq spacing 4)") (action_tile "c50" "(setq lastSel \"c50\") (setq spacing 5)") (action_tile "c90" "(setq lastSel \"c90\") (setq spacing 9)") (action_tile "c100" "(setq lastSel \"c100\") (setq spacing 10)") (action_tile "c180" "(setq lastSel \"c180\") (setq spacing 18)") (action_tile "custom" "(setq lastSel \"cCustom\") (setq spacing (atof $VALUE))") ;Parking Cones (action_tile "p10" "(setq lastSel \"p10\") (setq spacing 1)") (action_tile "p15" "(setq lastSel \"p15\") (setq spacing 1.5)") (action_tile "p20" "(setq lastSel \"p20\") (setq spacing 2)") (action_tile "p30" "(setq lastSel \"p30\") (setq spacing 3)") (action_tile "p40" "(setq lastSel \"p40\") (setq spacing 4)") (action_tile "p50" "(setq lastSel \"p50\") (setq spacing 5)") (action_tile "p90" "(setq lastSel \"p90\") (setq spacing 9)") (action_tile "p100" "(setq lastSel \"p100\") (setq spacing 10)") (action_tile "p180" "(setq lastSel \"p180\") (setq spacing 18)") (action_tile "pCustom" "(setq lastSel \"pCustom\") (setq spacing (atof $VALUE))") ;;; dialog return value (start_dialog) (unload_dialog dlg_id) (while (= (setq ent (car (entsel "\nSelect Object Curve (Arc, Circle, Line, Polyline or Spline)"))) Nil) (princ "\nNo Object Selected, Try Again") ) (setq len (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) MSpace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) dist spacing ) (vla-insertblock MSpace (vlax-curve-getpointatdist ent dist) (strcat "C:\\BricsCAD Scripts\\MACROS\\DWG\\" fileName ".dwg") 1 1 1 0 ) (setq dist (+ dist spacing)) (repeat (- (fix (/ len spacing)) 1) (vla-insertblock MSpace (vlax-curve-getpointatdist ent dist) block 1 1 1 0 ) (setq dist (+ dist spacing)) ) (princ) ) Quote
mhupp Posted December 1, 2022 Posted December 1, 2022 Fixing you error trap. So if there is an error message and it contains any of the following it wont be displayed. (defun *error* () (if (not (member *error* '("Console Break" "Function cancelled" "quit / exit abort"))) (princ (strcat "Error: " msg)) ) (princ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.