Author Topic: Make a Lisp to fing all objects with center asigned to it  (Read 1429 times)

0 Members and 1 Guest are viewing this topic.

craig.petersen

  • Guest
Make a Lisp to fing all objects with center asigned to it
« on: August 08, 2018, 04:07:09 PM »
I want a lisp to find all objects with center assigned to it and set color to by layer, layer to E-CEN, linetype to BYlayer and Lineweight to by layer
(setq LT_LIST (list "CENTER" "CENTER2" "CENTERX2"))
(foreach LT_NAME LT_LIST
    (command "._chprop" (ssget "X" '((6 . "CENTER"))) "" "C" "bylayer" "LT" "bylayer" "LW" "bylayer" "la" "E-CEN" "")
    (command "._chprop" (ssget "X" '((6 . "CENTER2"))) "" "C" "bylayer" "LT" "bylayer" "LW" "bylayer" "la" "E-CEN" "")
    (command "._chprop" (ssget "X" '((6 . "CENTERX2"))) "" "C" "bylayer" "LT" "bylayer" "LW" "bylayer" "la" "E-CEN" "")
)

I also want it to work in blocks

BIGAL

  • Swamp Rat
  • Posts: 1410
  • 40 + years of using Autocad
Re: Make a Lisp to fing all objects with center asigned to it
« Reply #1 on: August 09, 2018, 11:09:17 PM »
just google "change linetype in blocks" should take about 10 seconds to find the answer or just search here 1st.
A man who never made a mistake never made anything

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Make a Lisp to fing all objects with center asigned to it
« Reply #2 on: August 10, 2018, 08:56:07 AM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ a c d f)
  2.   ;; RJP » 2018-08-10
  3.     (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  4.   )
  5.   (vla-add (vla-get-layers d) "E-CEN")
  6.     (if (= 0 (vlax-get b 'isxref))
  7.       (vlax-for o b
  8.         (cond ((and (vlax-write-enabled-p o)
  9.                     (setq c (vla-get-linetype o))
  10.                     (setq f (wcmatch (strcase c) "CENTER*"))
  11.                )
  12.                (vla-put-linetype o "ByLayer")
  13.                (vla-put-lineweight o -1)
  14.                (vla-put-layer o "E-CEN")
  15.               )
  16.         )
  17.       )
  18.     )
  19.   )
  20.   (foreach l a (vlax-put l 'lock -1))
  21.   (and f (vla-regen d acallviewports))
  22.   (princ)
  23. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC