TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: rude dog on March 31, 2004, 03:01:24 PM
-
In Autolisp how could one freeze or thaw by color number only....just need a hint :?:
-
Do you want to work on the whole dwg at once, or by selection?
Hint:
DXF group code 62
Color number (present if not BYLAYER); zero indicates the BYBLOCK (floating) color; 256 indicates BYLAYER; a negative value indicates that the layer is turned off (optional)
-
mark,
good to hear from ya...i was thinking of working on the whole dwg
thanks for the tip...I have been away.......in Slackware land its a beautiful place
-
Well, you can freeze and thaw layers with lisp but individual entities probably not.
In VBA you can hide entities by simply setting the visible property of them to false.
To freeze a layer by referencing it's color...
Pseudo Code
Select entity with entsel
Extract entity color, if no entity color it must be bylayer
Extract entity layer
If color is bylayer extract entity layer color
;;;;for each layer in the drawing
extract layer color
test against entity color
if there is a match
freeze or turn off that layer
proceed to next layer
Sounds simple enough...
Put together some code and let us critique it....
-
kieth
where did the computer head go?... :)
I wanted to have the routine prompt the user for a color (by number) and then step thru the program in that matter....if possible i just have to set a little time aside
-
sorry e before i
-
I changed it up a bit....I am probably going to change it again soon
-
There are some bits of code in this you could use.
(defun c:gcc (/ cmd old ent clr lyr new ss col)
(command "_.undo" "_be") ;; set undo
(setq cmd (getvar "cmdecho") ;; save cmdecho variable
old (entsel "\nPick Object of Color to change: ")
ent (entget (car old)) ;; get entity
clr (cdr (assoc 62 ent)) ;; color if not ByLayer
lyr (cdr (assoc 8 ent)) ;; Layer Name
)
(if (null clr) ;; if ByLayer, get the layer color
(setq clr (cdr (assoc 62 (tblsearch "layer" lyr))))
)
(setq new (acad_colordlg clr nil) ; get new color
ss (ssget "x" (list (cons 62 clr))) ; get all objects using color clr
lyr (tblnext "layer" t) ;; get the first layer data
)
(if ss ;; change color of objects using the color clr to the color new
(command " chprop" ss "" "_c" new "")
)
(while lyr ; change all layers using color clr to color new
(setq ent (entget (tblobjname "layer" (cdr (assoc 2 lyr))))
lyr (tblnext "layer") ; get the next layer in the drawing
)
(if (= (cdr (setq col (assoc 62 ent))) clr)
;; color is clr so change it
(progn ; change color
(setq ent (subst (cons 62 new) col ent))
(entmod ent)
)
)
)
(setvar "cmdecho" cmd)
(command "_.undo" "_e")
(princ)
)
(princ)
-
Well, you can freeze and thaw layers with lisp but individual entities probably not.....
how about
(vlax-put-property THISOBJECT 'visible 0)
-
hmmmmm...table search......table next i suspected but was not certain
that will help
-
visual lisp commands are not my strong point but i can check them out in the help feature same as anything else
-
For those not so vlaxed as Hendie, simply change/add/remove group code 60: 0=visible, 1=hidden
:)
-
For those not so vlaxed as Hendie, simply change/add/remove group code 60: 0=visible, 1=hidden
:)
Hmmm.....I guess I need to go back and review all of those new entity codes so I know what the heck they are there for....
Thanks for the info Stig
-
just dippin my feet in...and realizing how much work the program you (CAB)
constructed was...nice job :) .....its helping me tremedously...cuz the whole tblsearch, tablenext.TNAME thing is a little confusing....hell im still studying past posts from Smadsen and M.Tom...SCRATCHING MY HEAD :o
-
just dippin my feet in...and realizing how much work the program you (CAB)
constructed was...nice job :) .....its helping me tremedously...
Well I didn't write that one, I just borrowed it, so please return it when your done. :D
-
(defun C:CNN ()
(setq ENT (car (entsel "\npick layer color for function ")))
(setq E1 (entget ENT))
(setq LT (cdr (assoc 8 E1)))
(setq ITEM (assoc 62 (tblsearch "Layer" LT)))
;(setq ss (ssget "x" (list (cons 62 ITEM)))
)
(princ)
cannot get this commented out line to make a list of all objects in dwg. that are the same color....gotten good help but dammit still cant get over this fence... :?
-
(setq ITEM (assoc 62 (tblsearch "Layer" LT)))
^returns a dotted pair
You should extract the color number with CDR:
(setq ITEM (cdr (assoc 62 (tblsearch "Layer" LT))))
(setq ss (ssget "X" (list (cons 62 ITEM))))