View Full Version : routine to place all objects on a particular layer with a particular colour
stephen.coff
2006-12-08, 12:14 AM
Guys,
Can anyone assist ?
I want to run a routine that will select all the objects on the screen (absolutely everything). Will then create a layer with a particular name and colour and place all the selected items on that layer at that colour.
I know how to craete the layer and select the colour. I get stuck with selecting all the items and putting them all on the current layer.
I use the ssget "x" to select all and prior to all this I have removed all hatch, dimensions and exploded everything. I get stuck with placing the selected items onto the created layer and at the layers colour.
Can anyone assist ?
Regards
Stephen
kennet.sjoberg
2006-12-08, 06:53 AM
The easy way ?
(command "._change" "All" "" "Properties" "LAyer" "MyLayer" "" )
: ) Happy Computing !
kennet
stephen.coff
2006-12-10, 11:12 PM
Thanks you Kennet.
Can I ask, what does the full stop before the under score do ?
Regards
stephen
madcadder
2006-12-11, 01:44 AM
Thanks you Kennet.
Can I ask, what does the full stop before the under score do ?
Regards
stephen
If i don't get these backwards...
The period is to use the "stock" CHANGE command if change has been redefined.
The underscore is for non-english versions of autocad to be able translate the command.
Adesu
2006-12-11, 08:51 AM
Hi stephen,
I have a code to change an object as that color object,here that code,ans test it
; clbco is stand for Create Layer Base on Color Object
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 28 November 2006
; Program no.: 0473/11/2006
; Edit by :
(defun c:clbco (/ cnt col p1 p2 ss sse ssl ssn ssx)
(if
(setq ss (car (entsel "\nSelect an object to take a color")))
(progn
(setq sse (entget ss))
(setq col (cdr (assoc 62 sse)))
(command "_layer" "m" (itoa col) "c" col "" "")
(setq p1 (getpoint "\nClick any location near object: "))
(setq p2 (getcorner p1 "\nClick opposite corner: "))
(setq ssx (ssget "_W" p1 p2))
(setq ssl (sslength ssx))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ssx cnt))
(command "_chprop" ssn "" "la" col "")
(setq cnt (1+ cnt))
) ; repeat
) ; progn
(alert "\nInvalid selected object,please try again")
) ; if
(princ)
)
Guys,
Can anyone assist ?
I want to run a routine that will select all the objects on the screen (absolutely everything). Will then create a layer with a particular name and colour and place all the selected items on that layer at that colour.
I know how to craete the layer and select the colour. I get stuck with selecting all the items and putting them all on the current layer.
I use the ssget "x" to select all and prior to all this I have removed all hatch, dimensions and exploded everything. I get stuck with placing the selected items onto the created layer and at the layers colour.
Can anyone assist ?
Regards
Stephen
kpblc2000
2006-12-11, 09:45 AM
Maybe something like this (if activex using is possible):
(defun c:chall (/ adoc selset layer color)
(vl-load-com)
(vla-startundomark
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
) ;_ end of vla-StartUndoMark
(if
(and (setq selset (ssget "_:L"))
(setq layer ((getstring t "\nEnter new layer name <No change> : ")))
(setq color (acad_colordlg 256))
) ;_ end of and
(progn
(if (not (tblobjname "layer" layer))
(vl-catch-all-apply (vla-add (vla-get-layers adoc) layer))
) ;_ end of if
(foreach ent
(mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex selset)))
) ;_ end of mapcar
(vl-catch-all-apply
'(lambda ()
(if color
(vla-put-color ent color)
) ;_ end of if
) ;_ end of lambda
) ;_ end of vl-catch-all-apply
(vl-catch-all-apply
'(lambda ()
(if layer
(vla-put-layer ent layer)
) ;_ end of if
) ;_ end of lambda
) ;_ end of vl-catch-all-apply
) ;_ end of foreach
) ;_ end of progn
) ;_ end of if
(vla-endundomark adoc)
(princ)
) ;_ end of defun
(princ "\nType chall in command line to start lisp")
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.