Author Topic: Automate All to Zero and With Existing Entity Properties: How-to Needed  (Read 297 times)

0 Members and 1 Guest are viewing this topic.

chilldaddy

  • Guest
Goal:
Find methods to help assemble a new LISP program or find an existing LISP program to perform the  following:
Convert all entities to layer zero while maintaining properties as originally assigned based on the entities' original layer.
In a single DWG file, 700+/- details are organized and include drawing borders that supply individual details to our main non-Autodesk specialized and multi-functional design application.

Please provide:
Links to and/or actual LISP programs that perform this or similar conversions.
LISP tips and/or instruction on links to methods to create a conversion LISP program.
Non-programmed methods to accomplish this conversion. 

Skill level:
Almost a LISP Beginner

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
If you have Autocad 2007+, then this should work, since "copytolayer" command was introduced at that release...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:moveto0layer ( / ss )
  2.   (prompt "\nSelect objects to move to 0 Layer...")
  3.   (if (setq ss (ssget "_:L"))
  4.     (progn
  5.       (if command-s
  6.         (command-s "_.-copytolayer" ss "" "0" "")
  7.         (vl-cmdf "_.-copytolayer" ss "" "0" "")
  8.       )
  9.       (if command-s
  10.         (command-s "_.erase" ss "")
  11.         (vl-cmdf "_.erase" ss "")
  12.       )
  13.       ;;; if you want to keep source layer(s) don't remove ;| and |; , but if you want them purged - erased, remove ;| and |; ...
  14.       ;|
  15.       (if command-s
  16.         (command-s "_.-purge" "_la" "*" "_n")
  17.         (vl-cmdf "_.-purge" "_la" "*" "_n")
  18.       )
  19.       |;
  20.     )
  21.   )
  22.   (princ)
  23. )
  24.  

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Another one in pure AutoLISP...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:moveto0layer ( / ss i e ex )
  2.   (prompt "\nSelect objects to move to 0 Layer...")
  3.   (if (setq ss (ssget "_:L"))
  4.     (repeat (setq i (sslength ss))
  5.       (setq e (ssname ss (setq i (1- i))))
  6.       (setq ex (entget e))
  7.       (entupd (cdr (assoc -1 (entmod (subst (cons 8 "0") (assoc 8 ex) ex)))))
  8.     )
  9.   )
  10.   (princ)
  11. )
  12.  
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chilldaddy

  • Guest
Ah yes, "ribarm"!

We run the latest version. Both of your generous contributions and the descriptions provided are very helpful and educated me, saving my company tons of processing time and expense.

Thanks a million!