Author Topic: Color bias  (Read 7359 times)

0 Members and 1 Guest are viewing this topic.

rude dog

  • Guest
Color bias
« on: March 31, 2004, 03:01:24 PM »
In Autolisp how could one freeze or thaw by color number only....just need a hint :?:

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Color bias
« Reply #1 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)
TheSwamp.org  (serving the CAD community since 2003)

rude dog

  • Guest
Color bias
« Reply #2 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

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Color bias
« Reply #3 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....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

rude dog

  • Guest
Color bias
« Reply #4 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

rude dog

  • Guest
Color bias
« Reply #5 on: March 31, 2004, 09:10:26 PM »
sorry e before i

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Color bias
« Reply #6 on: March 31, 2004, 09:48:42 PM »
I changed it up a bit....I am probably going to change it again soon
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Color bias
« Reply #7 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)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

hendie

  • Guest
Color bias
« Reply #8 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)

rude dog

  • Guest
Color bias
« Reply #9 on: April 01, 2004, 06:14:56 AM »
hmmmmm...table search......table next i suspected but was not certain
that will help

rude dog

  • Guest
Color bias
« Reply #10 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

SMadsen

  • Guest
Color bias
« Reply #11 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

:)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Color bias
« Reply #12 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
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

rude dog

  • Guest
Color bias
« Reply #13 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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Color bias
« Reply #14 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
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

rude dog

  • Guest
Color bias
« Reply #15 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... :?

SMadsen

  • Guest
Color bias
« Reply #16 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))))