Automation Error Object erased

Discussion in 'AutoCAD' started by Ricky M. Medley, Nov 2, 2004.

  1. The following code runs fine in Acad2000 and changes are made to the drawing...and runs fine in Autocad2004 only if stepping through (vlide) holding F8, however the drawing remains unchanged. Otherwise, when running in acad2004, I get the command line prompt:
    ;error: Automation error: Object erased.

    I know the code is ineficient, but that's not my goal at this time.

    Comments are not accurate as to its purpose..but what it does, is take all attributes and move them to layer text, fix rotation of attribute no matter the block placement, and change size of attributes to 0.09375 only if they are close to 0.075 in height.

    Thank you for looking.

    Ricky M. Medley
    Houston

    ;;;code begins
    ; Routine to change the color of a certain attribute
    ;in a block of a certain name from the defined color
    ;to a new color. Change the values in the line above
    ;the *'s to the desired blockname, layername, old color
    ;and new color #'s.
    ;Jeff Mishler, May 2004
    ;
    ;
    (defun c:attcoadefix ()
    (att-shift "Text")
    ;************************************************* **
    ; (att-color-shift "test2" "0" 1 8)
    ; as shown will get all block inserts named "test2" and change
    ; any red(1) attributes on layer "0" to color 8
    (princ)
    )

    (defun rad->deg (x)
    (* 180 (/ x pi))
    ); end

    (defun deg->rad (x)
    (* pi (/ x 180))
    )

    (defun att-shift (newlayer / count ss rotate atts)
    (vl-load-com)
    (setq holdval 0.075)
    (if (setq ss (ssget "x" (list '(0 . "INSERT") '(66 . 1))))
    (progn
    (setq count 0)
    (while (< count (sslength ss))
    (setq atts (vla-getattributes
    (vlax-ename->vla-object
    (ssname ss count)
    )
    )
    )
    (foreach att (vlax-safearray->list
    (vlax-variant-value atts)
    )
    (progn
    (vla-put-layer att newlayer)
    (setq currentval (vla-get-height att))
    (if (equal currentval holdval 2e-3)
    (vla-put-height att 0.09375)
    )
    (setq rotate (rad->deg (vla-get-rotation att)))
    (if (and (< rotate 180.0)
    (> rotate 90.0)
    )
    (vla-put-rotation att (deg->rad (+ rotate 180.0)))
    )
    (if (and (> rotate 180.0)
    (< rotate 270.0)
    )
    (vla-put-rotation att (deg->rad (- rotate 180.0)))
    )
    (if (= rotate 180.0)
    (vla-put-rotation att 0.0)
    )
    (if (or (= rotate 90.0)
    (= rotate 270.0)
    )
    (vla-put-rotation att (deg->rad 90.0))
    )
    )
    )
    (setq count (1+ count))
    )
    )
    )
    )
    ;end
     
    Ricky M. Medley, Nov 2, 2004
    #1
  2. Ok,
    So as it turns out...changing holdval to string "0.075", and equal function to =...solved the problem...
    (if (= (rtos currentval 2 3) holdval)
    (vla-put-height att 0.09375)
    )
    But, still...why wouldn't the first way work...seems just as efficient? Actually the old way is better. Less of moving numbers around to text and visa versa. Any bodies' thoughts would be welcome.

    Ricky M. Medley
    Houston



    The following code runs fine in Acad2000 and changes are made to the drawing...and runs fine in Autocad2004 only if stepping through (vlide) holding F8, however the drawing remains unchanged. Otherwise, when running in acad2004, I get the command line prompt:
    ;error: Automation error: Object erased.

    (if (equal currentval holdval 2e-3)
    (vla-put-height att 0.09375)
    )
     
    Ricky M. Medley, Nov 3, 2004
    #2
  3. Ok....again,
    So as it turns out (dejavu), changing any of the means to accomplish the
    same thing was only correct from a certain point of view. Both pieces of
    code were bombing when ran after the ATTSYNC command. A complete restart of
    acad was the only solution. Not even a qsave would clear....whatever.
    My thoughts are picturing something not being completely written after the
    attsync command, until the drawing file is re-opened.
    So I ask ya. What could be happening here?

    Ricky M. Medley
    Houston

    -------------------------------------
    Ok,
    So as it turns out...changing holdval to string "0.075", and equal function
    to =...solved the problem...




    The following code runs fine in Acad2000 and changes are made to the
    drawing...and runs fine in Autocad2004 only if stepping through (vlide)
    holding F8, however the drawing remains unchanged. Otherwise, when running
    in acad2004, I get the command line prompt:
    ;error: Automation error: Object erased.

    (if (equal currentval holdval 2e-3)
    (vla-put-height att 0.09375)
    )
     
    Ricky M. Medley, Nov 3, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.