TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: rude dog on March 31, 2004, 03:01:24 PM

Title: Color bias
Post 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 :?:
Title: Color bias
Post by: Mark on March 31, 2004, 03:34:01 PM
Do you want to work on the whole dwg at once, or by selection?

Hint:
DXF group code 62
Quote

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)
Title: Color bias
Post by: rude dog on March 31, 2004, 04:26:28 PM
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
Title: Color bias
Post by: Keith™ on March 31, 2004, 08:57:01 PM
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
Code: [Select]

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....
Title: Color bias
Post by: rude dog on March 31, 2004, 09:08:45 PM
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
Title: Color bias
Post by: rude dog on March 31, 2004, 09:10:26 PM
sorry e before i
Title: Color bias
Post by: Keith™ on March 31, 2004, 09:48:42 PM
I changed it up a bit....I am probably going to change it again soon
Title: Color bias
Post by: CAB on March 31, 2004, 11:46:28 PM
There are some bits of code in this you could use.

Code: [Select]
(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)
Title: Color bias
Post by: hendie on April 01, 2004, 03:15:19 AM
Quote from: Keith
Well, you can freeze and thaw layers with lisp but individual entities probably not.....

how about
Code: [Select]
(vlax-put-property THISOBJECT 'visible 0)
Title: Color bias
Post by: rude dog on April 01, 2004, 06:14:56 AM
hmmmmm...table search......table next i suspected but was not certain
that will help
Title: Color bias
Post by: rude dog on April 01, 2004, 06:16:52 AM
visual lisp commands are not my strong point but i can check them out in the help feature same as anything else
Title: Color bias
Post by: SMadsen on April 01, 2004, 06:47:03 AM
For those not so vlaxed as Hendie, simply change/add/remove group code 60: 0=visible, 1=hidden

:)
Title: Color bias
Post by: Keith™ on April 01, 2004, 08:14:36 AM
Quote from: SMadsen
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
Title: Color bias
Post by: rude dog on April 01, 2004, 04:21:35 PM
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
Title: Color bias
Post by: CAB on April 01, 2004, 04:33:03 PM
Quote from: rude dog
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
Title: Color bias
Post by: rude dog on April 19, 2004, 03:20:32 PM
Code: [Select]

(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... :?
Title: Color bias
Post by: SMadsen on April 19, 2004, 05:08:57 PM
(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))))