Author Topic: Why this is not working  (Read 2472 times)

0 Members and 1 Guest are viewing this topic.

Zykl0

  • Guest
Why this is not working
« on: April 02, 2015, 01:35:03 PM »
I'm working a script that find layer in the drawing by keyword and send everything on this layer to another one. This is not working at all and i don't know why. please help!

Code: [Select]
(defun C:ACUTEST (/ lay )

  (setq !lay (ssget "x" '((8 . "*Ala*"))))
  (command "_.CHPROP" !lay "" "LA" "Alarm" "")
 
  (setq !lay (ssget "x" '((8 . "*Ax*"))))
  (command "_.CHPROP" !lay "" "LA" "Axis" "")
 
  (setq !lay (ssget "x" '((8 . "*Back*"))))
  (command "_.CHPROP" !lay "" "LA" "Background" "")
 
  (setq !lay (ssget "x" '((8 . "*Be*"))))
  (command "_.CHPROP" !lay "" "LA" "Beam" "")
 
  (setq !lay (ssget "x" '((8 . "*Buil*"))))
  (command "_.CHPROP" !lay "" "LA" "Building" "")
  (princ)
)

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Why this is not working
« Reply #1 on: April 02, 2015, 01:46:53 PM »
Do all of the layers exist?
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
Re: Why this is not working
« Reply #2 on: April 02, 2015, 01:49:06 PM »
You need to attach the drawing for us to test.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Why this is not working
« Reply #3 on: April 02, 2015, 02:06:49 PM »
Quick & dirty for your consideration, coded blind:

Code: [Select]
(defun C:AcuTest ( / foo )

    (defun foo ( filter layer / ss )
        (if (null (setq ss (ssget "x" (list (cons 8 filter)))))
            (princ (strcat "\nNo entites found for filter <" filter ">."))
            (progn
                (if (null (tblsearch "layer" layer ))
                    (vl-cmdf ".layer" "_new" layer "")
                )
                (vl-cmdf ".chprop" ss "" "_layer" layer "")
                (princ
                    (strcat
                        "\n"
                        (itoa (sslength ss))
                        " object(s) moved to layer <" layer ">."
                    )
                )
            )
        )
        (princ)
    )

    (foreach pair
       '(   
            ("*Ala*"  "Alarm")
            ("*Ax*"   "Axis")
            ("*Back*" "Background")
            ("*Be*"   "Beam")
            ("*Buil*" "Building")
        )
        (apply 'foo pair)
    )

    (princ)

)
« Last Edit: April 02, 2015, 02:12:28 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Why this is not working
« Reply #4 on: April 02, 2015, 02:17:33 PM »
And another :)
Code - Auto/Visual Lisp: [Select]
  1. (defun c:acutest (/ ss)
  2.   (foreach lay '(("*Ala*" "Alarm")
  3.                  ("*Ax*" "Axis")
  4.                  ("*Back*" "Background")
  5.                  ("*Be*" "Beam")
  6.                  ("*Buil*" "Building")
  7.                 )
  8.     (if (null (tblobjname "layer" (cadr lay)))
  9.       (vl-cmdf ".layer" "_new" (cadr lay) "")
  10.     )
  11.     (if (setq ss (ssget "_x" (list (cons 8 (car lay)))))
  12.       (command "_.CHPROP" ss "" "Layer" (cadr lay) "")
  13.     )
  14.   )
  15.   (princ)
  16. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Zykl0

  • Guest
Re: Why this is not working
« Reply #5 on: April 04, 2015, 11:15:58 PM »
Wow this is amazing guys!

keep up to good work.