Author Topic: On Error Resume Next (for LSP)  (Read 2953 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
On Error Resume Next (for LSP)
« on: August 29, 2007, 03:39:11 PM »
Is there a function in vlisp similar to VBA's 'On Error Resume Next'?

Reason I'm asking is because I've written a batch xref bind routine and sometimes it fails because xrefs need to be cleaned up or audited.  It'd like to have the program continue to run when it encounters a situation like that -  maybe spit the drawing's name out to the command line and then keep on chugging along.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: On Error Resume Next (for LSP)
« Reply #1 on: August 29, 2007, 03:42:32 PM »
Something like this?

Code: [Select]
  (vl-catch-all-error-p
    (vl-catch-all-apply 'vla-put-color (list obj 256))
  )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Guest

  • Guest
Re: On Error Resume Next (for LSP)
« Reply #2 on: August 29, 2007, 03:45:04 PM »
How would I use that in conjunction with....
Code: [Select]
(command "-xref" "bind" "*")

Guest

  • Guest
Re: On Error Resume Next (for LSP)
« Reply #3 on: August 29, 2007, 03:49:08 PM »
Here's the code I'm using...

Quote
Code from: http://discussion.autodesk.com/thread.jspa?messageID=4612015

(defun C:IsLoaded ( / lst oXR)
   (vlax-map-Collection (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
      '(lambda (b)
      (if (and
         (= (vla-get-IsXRef b) :vlax-true)
            (vl-catch-all-error-p (vl-catch-all-apply 'vla-get-XRefDatabase (list b)))
         );and
         (setq lst (append lst (list (vla-get-Name b))))
      );if
      )
   )
   (foreach oXR lst
      (command "-layer" "f" (strcat oXR "|*") "")
      (command "-xref" "r" oXR)
   )
   (command "-xref" "bind" "*")  This is where it would bomb out
   (princ)
)

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: On Error Resume Next (for LSP)
« Reply #4 on: August 29, 2007, 04:19:05 PM »
Not tested but.......I think that this will work in place of the red line in your code:
Code: [Select]
     (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
       (if (= :vlax-true (vla-get-isxref blk))
(if (vl-catch-all-error-p (vl-catch-all-apply
     '(lambda (b)
(vla-bind b :vlax-false)
)
     (list blk)))
   (setq notbound (cons (vla-get-name blk) notbound))
   )
)
       )
   )
then the variable "notbound" will hold a list of any Xref names not able to be bound. Sorry, I don't have any drawings handy to test it with.....

ronjonp

  • Needs a day job
  • Posts: 7531
Re: On Error Resume Next (for LSP)
« Reply #5 on: August 29, 2007, 04:25:54 PM »
Just tested this and it works fine:
Code: [Select]
  (vlax-map-Collection
    (vla-get-Blocks
      (vla-get-ActiveDocument (vlax-get-acad-object))
    )
    '(lambda (b)
       (if (= (vla-get-IsXRef b) :vlax-true)
(vl-catch-all-error-p
   (vl-catch-all-apply
     'vla-bind
     (list b :vlax-false)
   )
)
       )
     )
  )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Guest

  • Guest
Re: On Error Resume Next (for LSP)
« Reply #6 on: August 29, 2007, 04:40:15 PM »
Not tested but.......I think that this will work in place of the red line in your code:


then the variable "notbound" will hold a list of any Xref names not able to be bound. Sorry, I don't have any drawings handy to test it with.....


Thanks Jeff and Ron....  Not as easy as I had thought it was going to be.

(once I removed the extra paren, it worked)
« Last Edit: August 29, 2007, 04:43:48 PM by Matt W »

KewlToyZ

  • Guest
Re: On Error Resume Next (for LSP)
« Reply #7 on: August 29, 2007, 05:12:28 PM »
Just curious,
Are you using Vanilla 2008 or one of the ADT, MEP, Land or Civil Desktop environments?
If one of the latter why not -exporttoautocad?
This routine overwrites the original file.
You can set the defaults in the -exporttoautocad feature to add a prefix or suffix to the filename it creates like -bound.

JohnK

  • Administrator
  • Seagull
  • Posts: 10656
Re: On Error Resume Next (for LSP)
« Reply #8 on: August 29, 2007, 06:22:37 PM »
An alternate method(s) i suppose.

Wasn't it bit code 36...?

Quote
70  Block-type flags (bit-coded values, may be combined):
0 = Indicates none of the following flags apply
1 = This is an anonymous block generated by hatching, associative
    dimensioning, other internal operations, or an application
2 = This block has non-constant attribute definitions (this bit is not
    set if the block has any attribute definitions that are constant,
    or has no attribute definitions at all)
4 = This block is an external reference (xref)
8 = This block is an xref overlay
16 = This block is externally dependent
32 = This is a resolved external reference, or dependent of an
     external reference (ignored on input)
64 = This definition is a referenced external reference (ignored on
     input)


Code: [Select]
( (lambda ( / entry)
    (while
      (setq entry (tblnext "block" (not entry)))
      (if (cdr (assoc 1 entry))
        (progn
          (princ "\n")
          (princ (cdr (assoc 2 entry)))
          (princ "    --->    ")
          (prin1 (cdr (assoc 70 entry)))
          (princ "    ...    ")
          (princ
            (cond
              ((> (cdr (assoc 70 entry)) 36) "You can bind this one")
              (t "I aint not so sure about this one here"))))))
    (princ)) )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Guest

  • Guest
Re: On Error Resume Next (for LSP)
« Reply #9 on: August 30, 2007, 08:28:36 AM »
Just curious,
Are you using Vanilla 2008 or one of the ADT, MEP, Land or Civil Desktop environments?
If one of the latter why not -exporttoautocad?
This routine overwrites the original file.
You can set the defaults in the -exporttoautocad feature to add a prefix or suffix to the filename it creates like -bound.

MEP, Architecture, Land & C3D.

We've run into an "issue" that when the xrefs are bound, regardless of the BINDTYPE variable, layers are being turned on that shouldn't be when we use EXPORTTOAUTOCAD2000/2004, AECEXPORTTOAUTOCAD2000/2004 or eTransmit.  But if we bind the xrefs using "-XREF" "BIND" "*" then we don't run into that problem.  Plus, we have some drawings that have xrefs that are attached in another xref but unloaded (just to through THAT into the mix).

KewlToyZ

  • Guest
Re: On Error Resume Next (for LSP)
« Reply #10 on: August 30, 2007, 11:23:19 AM »
Thanks for confirming my fears! I am going through trying to setup some tools to help me manage all of the bugs we are getting with 2008, MEP, AEC objects, driver combinations, etc....

Getting to the point I have a hard time toning things down enough to see the obvious at times and wasting more time chasing mysteries lol.