Results 1 to 6 of 6

Thread: Skip objects that cannot be offsetted in lisp routine (error)

  1. #1
    Member
    Join Date
    2018-07
    Posts
    3
    Login to Give a bone
    0

    Default Skip objects that cannot be offsetted in lisp routine (error)

    Hello,

    I made this lisp routine which offsets polylines on layers GBG1 and GBG2 and then hatches it.
    When a polyline cannot be offsetted (because the distance is too large for a closed polyline to be offsetted to the inside), it errors and stops.
    How can I let the routine skip those objects and continue?
    ; error: Automation Error. Description was not provided.
    Code:
    (defun c:ArcerenGebouwen (/ ss n gebouw obj1 ent2 offsetlijn1 obj2 offsetlijn2 offsetlijnen1 arcering1)
    (vl-load-com)
    (setq ss (ssget "x" '((0 . "LWPOLYLINE") (-4 . "<OR") (8 . "GBG1") (8 . "GBG2") (-4 . "OR>")))
          n (1- (sslength ss))
          );; setq
    (while (>= n 0)
      (setq obj1 (vlax-ename->vla-object (ssname ss n))
    	n (1- n)
    	);; setq
    (vla-offset obj1 (- 1))
    (setq ent2 (ssget "l"))
    (setq offsetlijn1 (entlast))
    (setq obj2 (vlax-ename->vla-object (ssname ent2 0)))
    (vla-offset obj2 (+ 1))
    (setq offsetlijn2 (entlast))
    (setq offsetlijnen1 (ssadd))
    (ssadd offsetlijn1 offsetlijnen1)
    (ssadd offsetlijn2 offsetlijnen1)
    (command "._hatch" "ansi31" "0.1" "0" offsetlijnen1 "")
    (command "._erase" offsetlijnen1 "")
    );; while
    );; defun

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Skip objects that cannot be offsetted in lisp routine (error)

    Hi,

    You can skip and let the routine running and ignoring the errors safely as follows:
    Code:
    (if (not (vl-catch-all-apply 'vla-offset (list obj1 -1)))
      (progn
        ;; do your stuff here
        )
      )

  3. #3
    Member
    Join Date
    2018-07
    Posts
    3
    Login to Give a bone
    0

    Default Re: Skip objects that cannot be offsetted in lisp routine (error)

    Quote Originally Posted by Tharwat View Post
    Hi,

    You can skip and let the routine running and ignoring the errors safely as follows:
    Code:
    (if (not (vl-catch-all-apply 'vla-offset (list obj1 -1)))
      (progn
        ;; do your stuff here
        )
      )
    Thank you, that's definetly part of my solution.
    However I don't seem to be able to getting it to run properly.
    If I understand it right, this makes the routine always continue.
    However it should only continue when no error is returned, and skip the object if an error is returned.

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Skip objects that cannot be offsetted in lisp routine (error)

    So just remove the function not from the my posted codes.

  5. #5
    Member
    Join Date
    2018-07
    Posts
    3
    Login to Give a bone
    0

    Default Re: Skip objects that cannot be offsetted in lisp routine (error)

    Thanks for your help! Works perfectly.

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Skip objects that cannot be offsetted in lisp routine (error)

    Quote Originally Posted by MartijnDC View Post
    Thanks for your help! Works perfectly.
    You are welcome anytime.

Similar Threads

  1. Looking for lisp routine to select objects inside polyline
    By vlad_tzok133583 in forum AutoLISP
    Replies: 22
    Last Post: 2022-04-29, 05:44 AM
  2. lisp routine error
    By lion201050723008 in forum AutoLISP
    Replies: 2
    Last Post: 2016-03-19, 06:08 AM
  3. LISP Routine Error for AutoCAD 2012
    By mmm3535361934 in forum AutoCAD Customization
    Replies: 1
    Last Post: 2011-10-25, 01:16 PM
  4. LISP routine returning bad function error
    By playerdraft in forum AutoLISP
    Replies: 2
    Last Post: 2011-06-15, 04:38 PM
  5. Replies: 16
    Last Post: 2007-05-16, 01:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •