Jump to content

Make LAYER, COLOR, LINETYPE current,, that works with DIMENSION, TEXT too


Recommended Posts

Posted

hi,, ive been figuring out how "Laymcur" and "MATCHPROP" can be combined into 1,,meaning if i picked an entity say "line" the layer, color, linetype,of the picked entity will all be the current one, ready to be use for another command.

 

that goes for dimension (dim style, dim layer) and text (text syle, text layer) as well.

 

but i guest my being noob in lisp make me more confuse :oops:,,,please help.

 

many thanks :)

Posted

Hi mate

Not sure that I have undersood your issue correct

Here is Q&D code that will change all selected objects

 
(defun C:CCP(/ elist en ss)
(prompt "\n >> Select objects to apply the current settings >>")
(if (setq ss (ssget))
(progn
(while
(setq en (ssname ss 0))
(setq elist (entget en))
(setq elist (subst (cons 8 (getvar "clayer"))(assoc 8 elist) elist))
(if (assoc 62 elist)
(setq elist (subst (cons 62 (atoi (getvar "cecolor")))(assoc 62 elist) elist))
(setq elist (append elist (list (cons 62 (atoi (getvar "cecolor")))))))
(if (assoc 6 elist)
(setq elist (subst (cons 6 (getvar "celtype"))(assoc 6 elist) elist))
(setq elist (append elist (list (cons 6 (getvar "celtype"))))))
(if (assoc 48 elist)
(setq elist (subst (cons 48 (getvar "celtscale"))(assoc 48 elist) elist))
(setq elist (append elist (list (cons 6 (getvar "celtscale"))))))
(if (assoc 370 elist)
(setq elist (subst (cons 370 (getvar "celweight"))(assoc 370 elist) elist))
(setq elist (append elist (list (cons 370 (getvar "celweight"))))))
(entmod elist)
(entupd en)
(ssdel en ss)
)
)
)
(princ)
)

 

~'J'~

Posted

There is already a button on the Object Properties Toolbar that sets the current layer by picking an object.

 

Surely you would not be drawing entities that did not have Colour-ByLayer and Linetype-ByLayer. :shock:

 

From the keyboard, you could type _ai_molc, which works for me, but may have been "improved" for later releases.

Posted (edited)

If you are trying to make the current settings match an existing entity, then I'd try something like this:

 

[b][color=BLACK]([/color][/b]defun c:match-en [b][color=FUCHSIA]([/color][/b]/ ss en ed vdl val[b][color=FUCHSIA])[/color][/b]

[b][color=FUCHSIA]([/color][/b]defun RtoA [b][color=NAVY]([/color][/b]r[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]/ [b][color=MAROON]([/color][/b]* r 180.0[b][color=MAROON])[/color][/b] pi[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not ss[b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]/= [b][color=GREEN]([/color][/b]sslength ss[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect 1 Entity To Match:"[/color][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]setq en [b][color=NAVY]([/color][/b]ssname ss 0[b][color=NAVY])[/color][/b]
       ed [b][color=NAVY]([/color][/b]entget en[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[color=#8b4513];;;STANDARD GROUPS[/color]
 [b][color=FUCHSIA]([/color][/b]setq vdl '[b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]  6  [color=#2f4f4f]"CELTYPE"[/color]     [color=#2f4f4f]"BYLAYER"[/color][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]  8  [color=#2f4f4f]"CLAYER"[/color]      [color=#2f4f4f]"0"[/color][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b] 39  [color=#2f4f4f]"THICKNESS"[/color]    0.0[b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b] 48  [color=#2f4f4f]"CELTSCALE"[/color]    1.0[b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]370  [color=#2f4f4f]"CELWEIGHT"[/color]    -1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]foreach v vdl
     [b][color=NAVY]([/color][/b]cond [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]setq val [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc [b][color=PURPLE]([/color][/b]nth 0 v[b][color=PURPLE])[/color][/b] ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
            [b][color=GREEN]([/color][/b]setvar [b][color=BLUE]([/color][/b]nth 1 v[b][color=BLUE])[/color][/b] val[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
           [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]getvar [b][color=BLUE]([/color][/b]nth 1 v[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
            [b][color=GREEN]([/color][/b]setvar [b][color=BLUE]([/color][/b]nth 1 v[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]nth 2 v[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[color=#8b4513];;;SPECIALTY GROUPS[/color]

[color=#8b4513];;;DIMSTYLE[/color]
 [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq val [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 3 ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]/= val [color=#2f4f4f]"*UNNAMED"[/color][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]command [color=#2f4f4f]"_.DIM1"[/color] [color=#2f4f4f]"_Restore"[/color] val[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[color=#8b4513];;;TEXTSTYLE[/color]
 [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq val [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 7 ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]progn
        [b][color=MAROON]([/color][/b]command [color=#2f4f4f]"_.STYLE"[/color]
                [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 7 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [color=#2f4f4f]""[/color]
                [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 40 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 41 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                [b][color=GREEN]([/color][/b]rtoa [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 51 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
        [b][color=MAROON]([/color][/b]while [b][color=GREEN]([/color][/b]> [b][color=BLUE]([/color][/b]getvar [color=#2f4f4f]"CMDACTIVE"[/color][b][color=BLUE])[/color][/b] 0[b][color=GREEN])[/color][/b]
               [b][color=GREEN]([/color][/b]command [color=#2f4f4f]"_N"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[color=#8b4513];;;ELEVATION[/color]
 [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq val [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 38 ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]setvar [color=#2f4f4f]"ELEVATION"[/color] val[b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]setvar [color=#2f4f4f]"ELEVATION"[/color] [b][color=MAROON]([/color][/b]caddr [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 10 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[color=#8b4513];;;CECOLOR[/color]
 [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq val [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 62 ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]setvar [color=#2f4f4f]"CECOLOR"[/color] [b][color=MAROON]([/color][/b]itoa val[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]setvar [color=#2f4f4f]"CECOLOR"[/color] [b][color=MAROON]([/color][/b]itoa 256[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[color=#8b4513];;;UCS[/color]
 [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]assoc 210 ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]equal [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 210 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] '[b][color=GREEN]([/color][/b]0 0 1[b][color=GREEN])[/color][/b] 1e-8[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]command [color=#2f4f4f]"_.UCS"[/color] [color=#2f4f4f]"_World"[/color][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]command [color=#2f4f4f]"_.UCS"[/color] [color=#2f4f4f]"_E"[/color] en[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

You could make a reset values similarly. -David

Edited by David Bethel
CELWEIGHT default to -1
Posted

fixo,, thank you for the code i have tried it (cad 2009) and it spit an error

Command: ccp
>> Select objects to apply the current settings >>
Select objects: 1 found
Select objects:
; error: bad DXF group: (6 . 1.0)

 

david - thank you too, i did check and tried your code quickly as well but could only see that the current layer change to what i had picked,,,,

 

maybe my explanation need a bit more explaining :oops: sorry guys for my poor english. :ouch:

 

ok here's another try;

 

im sure everyone is very familiar with "match prop" command "c:ma" - what it does (pls. correct me if im wrong) is match exactly the properties of the selected object to the destination object;

 

as for the "laymcur" layer make current command it makes the picked object or entity to be the current layer, and its COLOR bylayer only

 

now most of the time in my work i get to see drawings from other company that uses a layer that represent many entities all they do is change the layer colors and line type, these goes for dimension and text too

 

as i do amendments to these drawings we have to draw our design the way they (client/contractors) uses their layers and color,,, now this is where my request comes in,,,i wonder if it could be done in lisp that if i select a line the current layer will match it and its color, even if its not by-layer,,

 

example: note the sample below all reside in 1 layer (layer 1)

 

entity A had -->> layer1 (color red by-layer) (line type "continuous")

 

entity B had -->> layer1 (color blue) (line type "dotted" )

 

entity C had -->> layer1 (color green) (dim style "dim100")

 

entity D had -->> layer1 (color orange) (dim style "leader")

 

entity E had -->> layer1 (color 7) (text style "romans")

 

 

here's the scenario:

1. i wanted to draw something so i quickly picked an entity say entity B (a line) and right away my current layer become "layer 1" current color become "blue" current line type become "dotted",,,, ready for my next command.

 

2. say i wanted to add in annotations i picked entity E (say an annotation text) and right after selecting that text my current layer matches that picked entity, its color (regardless if its bylayer or not) its text style.

 

3. say i wanted to start my dimensioning,, i will first picked an existing dimension and right after my picked dimension, it matches the current layer, its color (regardless if its bylayer or not), its dim-syle.

 

4. say i wanted to,,,,,, i think you got the idea,,,, :roll:

 

i hope i've explained it well,,, thanks everyone for the effort...but keep it commin !!! :)

Posted
fixo,, thank you for the code i have tried it (cad 2009) and it spit an error

 

Do you think that the words you used in your reply are correct, or it's a way of giving favor back.:x

Posted

Sorry, my bad, it's a typo

Command: ccp

>> Select objects to apply the current settings >>

Select objects: 1 found

Select objects:

; error: bad DXF group: (6 . 1.0)

 

Try instead

 

 

(defun C:CCP(/ elist en ss)
(prompt "\n  >>  Select objects to apply the current settings  >>")
(if (setq ss (ssget))
 (progn
   (while
     (setq en (ssname ss 0))
     (setq elist (entget en))
     (setq elist (subst (cons 8 (getvar "clayer"))(assoc 8 elist) elist))
     (if (assoc 62 elist)
     (setq elist (subst (cons 62 (atoi (getvar "cecolor")))(assoc 62 elist) elist))
     (setq elist (append elist (list (cons 62 (atoi (getvar "cecolor")))))))
     (if (assoc 6 elist)
     (setq elist (subst (cons 6 (getvar "celtype"))(assoc 6 elist) elist))
     (setq elist (append elist (list (cons 6 (getvar "celtype"))))))

     (if (assoc 48 elist)
     (setq elist (subst (cons 48 (getvar "celtscale"))(assoc 48 elist) elist))
     (setq elist (append elist (list (cons 48 (getvar "celtscale"))))))
      (if (assoc 370 elist)
     (setq elist (subst (cons 370 (getvar "celweight"))(assoc 370 elist) elist))
     (setq elist (append elist (list (cons 370 (getvar "celweight"))))))
     (entmod elist)
     (entupd en)
     (ssdel en ss)
     )
   )
 )
 (princ)
 )

 

~'J'~

Posted
Do you think that the words you used in your reply are correct, or it's a way of giving favor back.:x

i did not mean to upset you or anyone the way it did,,, sorry :unsure:

 

Fixo-->> thank you for your understanding i had tried your code again, and i think what it did was to make the current layer change its layer state to "byblock" im not sure if its the case,,

 

im not sure if you notice my example to post #5 above? :oops:

 

thank you

Posted

pryzmm,

 

I changed the celweight to default to -1. It should work now. The release I tried it on didn't know about it. -David

Posted

[quote name= fixo Get the code from there

[/url]http://www.afralisp.net/visual-lisp/...ors-part-2.php-fixo

 

thanks, man ill have a look later on ... :)

 

 

pryzmm,

 

I changed the celweight to default to -1. It should work now. The release I tried it on didn't know about it. -David

 

david,,i've run a quick test and boyy you nailed it man,:shock:,A BIG THANK YOU,will run more test,,,many thanks to all once again :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...