Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error Check ? for this routine please

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
164 Views, 4 Replies

Error Check ? for this routine please

Let's say I run this routine on a drawing that doesn't contain any ((0 .
"line,arc,circle,polyline,lwpolyline")
(8 . "cloud") (62 . 6))))

I knowwww... hard to believe but just for arguement sake.

How do I insure that the routine continues on, to search for text objects
without bombing out?

J. Logan
-----------------------------------------------------------------
(defun line5 (/ a ln n index b1 c d b2)
;;(defun line5 ()
(graphscr)
(princ "\nConverting Ojbects on CLOUD Layer to Correct Layers")
(setq ln "line5")
(setq a (ssget "x" '((0 . "line,arc,circle,polyline,lwpolyline") (8 .
"cloud") (62 . 6))))
(setq n (sslength a))
(setq index 0)
(repeat n
(setq b1 (entget (ssname a index)))
(setq index (1+ index))
(setq c (assoc 8 b1))
(setq d (cons (car c) ln))
(setq b2 (subst d c b1))
(entmod b2)
)
)
(defun Text0 (/ a tn n index b1 c d b2)
;;(defun text0()
(graphscr)
(princ "\nConverting Ojbects on CLOUD Layer to Correct Layers")
(setq tn "Text0")
(setq a (ssget "x" '((0 . "text") (8 . "cloud") (62 . 7))))
(setq n (sslength a))
(setq index 0)
(repeat n
(setq b1 (entget (ssname a index)))
(setq index (1+ index))
(setq c (assoc 8 b1))
(setq d (cons (car c) tn))
(setq b2 (subst d c b1))
(entmod b2)
)
)
(defun abylayer ()
(setq SS1 (ssget "x" '((-4 . ""))))
(command "change" SS1 "" "p" "color" "bylayer" "")
(princ)
)
(defun redrw ()
(command "redraw")
)
;; Execute command, calling constituent functions
;;
(defun C:CLC () ;;cloudlayerclean
;;(set_vars)
(line5)
(text0)
(abylayer)
(redrw)
(princ "\nCONVERSION COMPLETE")
(Princ)
)
----------------------------------------------------------------
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

it will give nil right?
put an if statement to say:
( if (setq a (ssget "x" '((0 . "line,arc,circle,polyline,lwpolyline") (8 ."cloud") (62 . 6))))
(progn....

then it will only run the stuff if it finds items to run on.

J. Logan
|>Let's say I run this routine on a drawing that doesn't contain any ((0 .
|>"line,arc,circle,polyline,lwpolyline")
|>(8 . "cloud") (62 . 6))))
|>
|>I knowwww... hard to believe but just for arguement sake.
|>
|>How do I insure that the routine continues on, to search for text objects
|>without bombing out?
|>
|>J. Logan
|>-----------------------------------------------------------------
|>(defun line5 (/ a ln n index b1 c d b2)
|> ;;(defun line5 ()
|> (graphscr)
|> (princ "\nConverting Ojbects on CLOUD Layer to Correct Layers")
|> (setq ln "line5")
|> (setq a (ssget "x" '((0 . "line,arc,circle,polyline,lwpolyline") (8 .
|>"cloud") (62 . 6))))
|> (setq n (sslength a))
|> (setq index 0)
|> (repeat n
|> (setq b1 (entget (ssname a index)))
|> (setq index (1+ index))
|> (setq c (assoc 8 b1))
|> (setq d (cons (car c) ln))
|> (setq b2 (subst d c b1))
|> (entmod b2)
|> )
|>)
|>(defun Text0 (/ a tn n index b1 c d b2)
|> ;;(defun text0()
|> (graphscr)
|> (princ "\nConverting Ojbects on CLOUD Layer to Correct Layers")
|> (setq tn "Text0")
|> (setq a (ssget "x" '((0 . "text") (8 . "cloud") (62 . 7))))
|> (setq n (sslength a))
|> (setq index 0)
|> (repeat n
|> (setq b1 (entget (ssname a index)))
|> (setq index (1+ index))
|> (setq c (assoc 8 b1))
|> (setq d (cons (car c) tn))
|> (setq b2 (subst d c b1))
|> (entmod b2)
|> )
|>)
|>(defun abylayer ()
|>(setq SS1 (ssget "x" '((-4 . ""))))
|>(command "change" SS1 "" "p" "color" "bylayer" "")
|>(princ)
|>)
|> (defun redrw ()
|> (command "redraw")
|>)
|>;; Execute command, calling constituent functions
|>;;
|>(defun C:CLC () ;;cloudlayerclean
|> ;;(set_vars)
|> (line5)
|> (text0)
|> (abylayer)
|> (redrw)
|> (princ "\nCONVERSION COMPLETE")
|> (Princ)
|>)
|>----------------------------------------------------------------
James Maeding
Civil Engineer and Programmer
jmaeding - athunsaker - com
Message 3 of 5
Anonymous
in reply to: Anonymous

Yup it nils me.

I have 6 line# routines and 6 text# routines in this one lisp. If I
understand (progn) right. I should be able to use...

(if (setq a (ssget "x" '((0 . "line,arc,circle,polyline,lwpolyline") (8
."cloud") (62 . 6))))
(progn...
(setq n (sslength a))....
(entmod b2)
)

for each occurance?

J. Logan

"James Maeding" wrote in message
news:5387004@discussion.autodesk.com...
it will give nil right?
put an if statement to say:
( if (setq a (ssget "x" '((0 . "line,arc,circle,polyline,lwpolyline") (8
."cloud") (62 . 6))))
(progn....

then it will only run the stuff if it finds items to run on.

J. Logan
|>Let's say I run this routine on a drawing that doesn't contain any ((0 .
|>"line,arc,circle,polyline,lwpolyline")
|>(8 . "cloud") (62 . 6))))
|>
|>I knowwww... hard to believe but just for arguement sake.
|>
|>How do I insure that the routine continues on, to search for text objects
|>without bombing out?
|>
|>J. Logan
|>-----------------------------------------------------------------
|>(defun line5 (/ a ln n index b1 c d b2)
|> ;;(defun line5 ()
|> (graphscr)
|> (princ "\nConverting Ojbects on CLOUD Layer to Correct Layers")
|> (setq ln "line5")
|> (setq a (ssget "x" '((0 . "line,arc,circle,polyline,lwpolyline") (8 .
|>"cloud") (62 . 6))))
|> (setq n (sslength a))
|> (setq index 0)
|> (repeat n
|> (setq b1 (entget (ssname a index)))
|> (setq index (1+ index))
|> (setq c (assoc 8 b1))
|> (setq d (cons (car c) ln))
|> (setq b2 (subst d c b1))
|> (entmod b2)
|> )
|>)
|>(defun Text0 (/ a tn n index b1 c d b2)
|> ;;(defun text0()
|> (graphscr)
|> (princ "\nConverting Ojbects on CLOUD Layer to Correct Layers")
|> (setq tn "Text0")
|> (setq a (ssget "x" '((0 . "text") (8 . "cloud") (62 . 7))))
|> (setq n (sslength a))
|> (setq index 0)
|> (repeat n
|> (setq b1 (entget (ssname a index)))
|> (setq index (1+ index))
|> (setq c (assoc 8 b1))
|> (setq d (cons (car c) tn))
|> (setq b2 (subst d c b1))
|> (entmod b2)
|> )
|>)
|>(defun abylayer ()
|>(setq SS1 (ssget "x" '((-4 . ""))))
|>(command "change" SS1 "" "p" "color" "bylayer" "")
|>(princ)
|>)
|> (defun redrw ()
|> (command "redraw")
|>)
|>;; Execute command, calling constituent functions
|>;;
|>(defun C:CLC () ;;cloudlayerclean
|> ;;(set_vars)
|> (line5)
|> (text0)
|> (abylayer)
|> (redrw)
|> (princ "\nCONVERSION COMPLETE")
|> (Princ)
|>)
|>----------------------------------------------------------------
James Maeding
Civil Engineer and Programmer
jmaeding - athunsaker - com
Message 4 of 5
Anonymous
in reply to: Anonymous

Thanks James it works like a charm...

J. Logan

"James Maeding" wrote in message
news:5387004@discussion.autodesk.com...
it will give nil right?
put an if statement to say:
( if (setq a (ssget "x" '((0 . "line,arc,circle,polyline,lwpolyline") (8
."cloud") (62 . 6))))
(progn....

then it will only run the stuff if it finds items to run on.
Message 5 of 5
Anonymous
in reply to: Anonymous

you got it 🙂

J. Logan
|>Thanks James it works like a charm...
|>
|>J. Logan
|>
|>"James Maeding" wrote in message
|>news:5387004@discussion.autodesk.com...
|>it will give nil right?
|>put an if statement to say:
|>( if (setq a (ssget "x" '((0 . "line,arc,circle,polyline,lwpolyline") (8
|>."cloud") (62 . 6))))
|> (progn....
|>
|>then it will only run the stuff if it finds items to run on.
James Maeding
Civil Engineer and Programmer
jmaeding - athunsaker - com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report