Error handling help

Error handling help

Anonymous
Not applicable
1,017 Views
7 Replies
Message 1 of 8

Error handling help

Anonymous
Not applicable

I really need help in understanding what this attempt at error handling is doing or if it is really required for this function to isolate layers in AutoCAD 2010.

  The person who wrote it is long gone and the support is just trying to piece together the right version of source .lsp files compiled into VLX to have it working the way they believe it should.

     Some users has version that does not pop up this message and continues with performing the function to isolate layers.  Other users have a different version which will pop up this message "This is the OLD ISO with multi selections - need to add layerstate storage" but can click "OK" and continue.

     Can this be REM out of the function?

 

(defun c:iso (/ ss cnt lay laylst val)

(defun trap (errmsg)
   (setq *error* err)
   (prompt errmsg)
   (princ)
);endfunction trap

(setq err *error* *error* trap)

(alert "\nThis is the OLD ISO with multi selections - need to add layerstate storage")

 

Thank you

0 Likes
1,018 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

Do you have another routine that defines a new  ISO?  It looks like this must have been written under a version before Layer States existed, and they've added either a warning to the User  if they're in a newer version, or a reminder to the writer  whenever they used it that it needed to be updated.  If so, and if you're using a newer version of AutoCAD and have a newer ISO defined, you should be able to eliminate this routine altogether.

 

If I've misunderstood, maybe posting the code that follows it would help.

Kent Cooper, AIA
0 Likes
Message 3 of 8

paullimapa
Mentor
Mentor

Sure, rem it out since users even when they get this alert message can click OK to continue the routine.

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 8

Anonymous
Not applicable

Kent

     They are currently running in AutoCAD 2010 but all these functions and customizations may have begun from when they were on AutoCAD 2002.  I believe there is a macro embed into a button on a custom toolbar that does the same function but without the pop up message.  Some users are wanting to use the ISO as a command. 

     Posting the remainder of the code but it does seem like the error trap and alert may not be needed.

 

(if (not (setq ss (ssget "_i")))
  (progn
    (prompt "\nselect object(s) on the layer(s) to be isolated: ")
    (setq ss (ssget))
  );endpro
);endif

(if ss
  (progn

    (setq cnt 0)

    (while (setq lay (ssname ss cnt))
      (setq lay (cdr (assoc 8 (entget lay))))
      (if (not (member lay laylst))
        (setq laylst (cons lay laylst))
      )
      (setq cnt (1+ cnt))
    );endwhile

    (if (member (getvar "clayer") laylst)
      (setq lay (getvar "clayer"))
      (setvar "clayer" (setq lay (last laylst)))
    );endif

    (command "_.-layer" "_off" "*" "_y")
    (foreach val laylst (command "_on" val))
    (command "")
   
    (if (= (length laylst) 1)
      (prompt (strcat "\nlayer " (car laylst) " has been isolated."))
      (prompt (strcat "\n" (itoa (length laylst)) " layers have been isolated. "
                      "layer " lay " is current."
              )
      )
    );endif
  );endpro
);endif ss

;(setq *error* err)
;  (princ)
);endfun

0 Likes
Message 5 of 8

paullimapa
Mentor
Mentor

Curious as to why you wouldn't just use the built-in Layiso command instead of the lisp routine?

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 8

Anonymous
Not applicable

Paul,

    They do not want all the layers locked in the case of LAYISO.  The custom rountine command turns them off.

   

0 Likes
Message 7 of 8

paullimapa
Mentor
Mentor
0 Likes
Message 8 of 8

Kent1Cooper
Consultant
Consultant

If the goal is isolating Layers, you may be interested in two routines of mine:  LayerIsolateOnOff.lsp [available here] which has certain improvements over AutoCAD's LAYISO/LAYUNISO commands  [see the long first comment there, as well as the top of the file], and LayerIsolateFreezeThaw.lsp [here] which does the same but by Freezing/Thawing rather than turning Off/On.  Neither involves Locking -- maybe some day I'll make some that do, or add that as an option in those.

Kent Cooper, AIA
0 Likes