Author Topic: acaddoc.lsp causes automation errors in '12  (Read 1875 times)

0 Members and 1 Guest are viewing this topic.

butzers09silverado

  • Guest
acaddoc.lsp causes automation errors in '12
« on: June 27, 2012, 10:48:01 AM »
well here's another one.  I can't figure out what the automation error is, but once the error happens it prevents defpoints from being converted to color 63 as directed, and it doesn't do a bunch of other stuff.  Originally i thought it was the navbar and navvcube stuff but i commented it out and it still fails... worked fine in 2011  :pissed:

Code: [Select]

(setvar "mirrtext" 0)

(setvar "proxygraphics" 0)

;(setvar "NAVBARDISPLAY" 0)
;(setvar "NAVVCUBEDISPLAY" 0)

(vl-load-com)

(or *vla-AcadObject* (setq *vla-AcadObject* (vlax-get-acad-object)))
(or *vla-ActiveDocument* (setq *vla-ActiveDocument* (vla-get-ActiveDocument *vla-AcadObject*)))
(or *vla-LayersCollection* (setq *vla-LayersCollection* (vla-get-Layers *vla-ActiveDocument*)))

;; Adjust the layer 0
(if (not (vl-catch-all-error-p (setq l (vl-catch-all-apply 'vla-Item (list *vla-LayersCollection* "0")))))
  (progn
    (vla-put-LayerOn l :vlax-true)
    (vla-put-Freeze l :vlax-false)
    (vla-put-Lock l :vlax-false)
  )
)
(setvar 'CLayer "0")

;; Adjust / Create the Defpoints layer
(if (or (not (vl-catch-all-error-p (setq l (vl-catch-all-apply 'vla-Item (list *vla-LayersCollection* "Defpoints")))))
        (and (not (vl-catch-all-error-p (setq l (vl-catch-all-apply 'vla-Add (list *vla-LayersCollection* "Defpoints")))))
             (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Color (list l 63))))
        )
  )
  (progn
    (vla-put-LayerOn l :vlax-true)
    (vla-put-Freeze l :vlax-false)
    (vla-put-Lock l :vlax-false)
  )
)

;; Turn off wipeout frames if they are on
(if (/= 0 (cdr (assoc 70 (dictsearch (namedobjdict) "ACAD_WIPEOUT_VARS"))))
(progn
(entmod (subst (cons 70 0)(assoc 70 (dictsearch (namedobjdict) "ACAD_WIPEOUT_VARS"))
(dictsearch (namedobjdict) "ACAD_WIPEOUT_VARS"))
)
;; Regen all
(vla-Regen (vla-get-activedocument (vlax-get-acad-object)) acAllViewports)
)
)
[\code]

BlackBox

  • King Gator
  • Posts: 3770
Re: acaddoc.lsp causes automation errors in '12
« Reply #1 on: June 27, 2012, 12:49:55 PM »

Have you tried debugging the code...?

Set a breakpoint (F9) near the top of the code, and load it... use F8 to step through the code until it breaks. Diagnose from there.
"How we think determines what we do, and what we do determines what we get."

Lee Mac

  • Seagull
  • Posts: 12937
  • London, England
Re: acaddoc.lsp causes automation errors in '12
« Reply #2 on: June 27, 2012, 02:22:06 PM »
Try running the code outside of the ACADDOC.lsp, and use this procedure to attempt to determine the source of the error. If, after the erroneous expression is detected, you then cannot find a solution to resolve such error on your own, we'll be more than happy to help you with the segment that is causing you problems.

As a general programming forum tip: by narrowing the problem in this way, you are far more likely to get a more directed and beneficial response, since many of us simply don't have the time to go through the debugging process.

That said, after a quick glance over your code, the call to vla-put-freeze will error if Layer "0" is current.

butzers09silverado

  • Guest
Re: acaddoc.lsp causes automation errors in '12
« Reply #3 on: June 29, 2012, 09:58:14 AM »
after a quick glance over your code, the call to vla-put-freeze will error if Layer "0" is current.
I guess there should be a test to see if layer 0 is current, and then do the function if it isn't, right?

the vlide did highlight that piece of code identifying the error when i have layer 0 set current, thanks! 

Lee Mac

  • Seagull
  • Posts: 12937
  • London, England
Re: acaddoc.lsp causes automation errors in '12
« Reply #4 on: June 29, 2012, 10:04:20 AM »
I guess there should be a test to see if layer 0 is current, and then do the function if it isn't, right?

Sure  :-)