Author Topic: Layer 0 attack  (Read 17370 times)

0 Members and 2 Guests are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer 0 attack
« Reply #45 on: November 19, 2008, 11:02:36 AM »
Change this
(defun ChangeAllItemsToLayer0 (vla-get-ActiveDocument (vlax-get-Acad-Object)))
to this
(defun ChangeAllItemsToLayer0 (doc)

but id didn't work for me

I may be late to the party and this may have already been resolved but if your using Odbx can you issue a call to an "Active Document"?  It has been a while since I used Odbx so I may be missing the mark.
No.  Since it is already open you couldn't use Odbx.  But if you are the one with it opened, then you could just use the document object, from the document collection, and use it like you would an Odbx document.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Notsober

  • Guest
Re: Layer 0 attack
« Reply #46 on: November 19, 2008, 02:58:14 PM »
this guy right here is the winner! Worked perfectly, and exactly how I wanted.

now, if I can only get a code to get management OFF my layer!  :-D


Give this a whirl...be warned that it deletes audited items (which in this case seemed to be empty blocks).

Code: [Select]
(defun c:allzero (/ doc makesmecry rjp-progress n ss)
  (vl-load-com)
  (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vla-auditinfo doc :vlax-true)
  (vla-purgeall doc)
  (vlax-for i (vla-get-Layers doc)
    (vla-put-lock i :vlax-false)
  )
  (vl-catch-all-apply 'setvar (list 'clayer "0"))

  (defun makesmecry (obj / p)
    (foreach p '(Color Linetype Lineweight)
      (if (vl-position (vlax-get-property obj p) '(256 -1 "ByLayer"))
(vl-catch-all-apply
  'vlax-put-property
  (list obj
p
(vlax-get-property
  (vlax-ename->vla-object
    (tblobjname "layer" (vla-get-layer obj))
  )
  p
)
  )
)
      )
    )
    (vl-catch-all-apply
      'vlax-put-property
      (list obj 'Layer "0")
    )
    (princ)
  )

  (vlax-for blk (vla-get-blocks doc)
    (vlax-for i blk
      (makesmecry i)
      (if (= (vla-get-ObjectName i) "AcDbBlockReference")
(foreach j (append (vlax-invoke i 'GetAttributes)
   (vlax-invoke i 'GetConstantAttributes)
   )
  (makesmecry j)
)
      )
    )
  )
  ;;deletes audited crap so be forewarned
  (if (setq ss (ssget "x" '((2 . "AUDIT*"))))
    (foreach x (mapcar 'cadr (ssnamex ss))
      (entdel x)
    )
  )
  (repeat 3 (vla-purgeall doc))
)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Layer 0 attack
« Reply #47 on: November 19, 2008, 04:04:00 PM »
Glad it worked for you :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC