Unalbe to apply layers to selected blocks

Unalbe to apply layers to selected blocks

Anonymous
Not applicable
864 Views
4 Replies
Message 1 of 5

Unalbe to apply layers to selected blocks

Anonymous
Not applicable

Dear Helpers,

 

I have created one lisp code to create and convert the selected elements to the new layers. It's working for all excepting Blocks. Can you please check the below code and correct if I am wroing at any location of the code.

(defun C:LDT() (setq vij (ssget))
		(setq lay (tblsearch "layer" "TP-LHS-DRAIN"))
		(if (= lay nil)
			(progn (command "layer" "n" "TP-LHS-DRAIN" "c" "5" "TP-LHS-DRAIN" "")))
		(command "change" vij "" "P" "la" "TP-LHS-DRAIN" ""))
0 Likes
Accepted solutions (2)
865 Views
4 Replies
Replies (4)
Message 2 of 5

dbhunia
Advisor
Advisor

I did not get any error in your code........

 

Only thing is your Block object color is "ByLayer"???? (Because Blocks are also changing Layer but if Block object color is not "ByLayer" then it will not change Block object color as per Layer color)....... Else post sample drawing......


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 3 of 5

Anonymous
Not applicable

Please see attached dwg, Sir. Except blocks this is working for all. Please check Sir.

0 Likes
Message 4 of 5

dbhunia
Advisor
Advisor
Accepted solution

Try this....

 

(defun C:LDT();;put temp variables
(setvar 'cmdecho 0)
(setq vij (ssget))
(setq lay (tblsearch "layer" "TP-LHS-DRAIN"))
	(if (= lay nil)
		(progn (command "layer" "n" "TP-LHS-DRAIN" "c" "5" "TP-LHS-DRAIN" ""))
	)
(repeat (setq N (sslength vij))
	(setq Data (ssname vij (setq N (- N 1))))
	(setq EntityData (entget Data))
	(entmod(subst (cons 8 "TP-LHS-DRAIN") (assoc 8 EntityData) EntityData))
)
(setvar 'cmdecho 1)
(princ)
)

 

There is UCS problem for that particular block......... for that "change" is unable to change its layer......Try to "change" the layer for that particular block you will get this.....

 

Capture.PNG


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 5 of 5

cadffm
Consultant
Consultant
Accepted solution

Hi @Anonymous

as dbhunia pointed to: Read your commandline[CTRL+9] or TextScreen[F2] when you work.

You know that CHANGE don't want to edit non-parallel object (non parallel to the current ucs),

the simple solution for you: Use a command who **** of this fact: CHPROP for example.

 

 

(defun C:LDT ( / vij )
  (if (and
         (setq vij (ssget "_:L"))
         (or (tblsearch "layer" "TP-LHS-DRAIN")(not(command "_.-LAYER" "_new" "TP-LHS-DRAIN" "_color" "5" "TP-LHS-DRAIN" "")))
      )
      (command "_.CHPROP" vij "" "_layer" "TP-LHS-DRAIN" "")
  )
 (princ)
)

Sebastian