Jump to content

Lisp that will change xref layers to bylayer


xspacex

Recommended Posts

Hello everyone,

 

I am looking into writing a lisp routine that will allow me to select an xref, maybe select multiple xrefs, and then I would be able to change the color of all layers in the xref(s).

My question is, if some of the xref layers are bycolor, how would I change these layers to bylayer using the xref name that I will extract from selecting it??

 

 

Thanks

Link to comment
Share on other sites

below is the part i am having trouble with...

It is suppose to substitute byblock layers to bylayer, however, it is not working.

Any suggestions would be appreciated.

 

 

(setq newclr (cons 62 256))

(setq xrefname (entget (tblobjname "block" (cdr (assoc 2 (entget (car ent)))))))

(setq xrefdata (entget xrefname))

(setq oldclr (assoc 62 xrefdata))

(if (assoc 62 xrefdata)

(setq xrefent (subst newclr oldclr xrefdata))

(entmod xrefent)

)

Link to comment
Share on other sites

ColorX - change color all object of drawing. All layer unlock and thaw

ColorXREF change color xref only on a current session. All layer unlock and thaw

ColorXL - change color all object of drawing. Objects on the locked and frozen layers are ignored

ColorXREFL change color xref only on a current session. Objects on the locked and frozen layers are ignored

 

COLORXLAY - change xref layer's color

Link to comment
Share on other sites

Hi VVA,

 

thank you for the reply, and posting those links. However, the lisp routines in the old posts do not achieve what i am looking for; in general, they change the xref layers to a specific color...

What I am trying to achieve, is basically being able to change xref layers that are forced to a color, to bylayer.

 

Thanks again.

Link to comment
Share on other sites

so i am making some progress, but still not there yet...

if i attach an xref to a drawing, i am able to change LINE, ARC, CIRCLE and DTEXT that have a forced color to bylayer, however, if the xref has PLINE, HATCH, ELLIPSE, or MTEXT that have a forced color, i am not able to change these to bylayer. my question is, why isn't my code working for everything, and only working for LINE, DTEXT, CIRCLE and ARC??

 

Thanks

 

(setq newclr (cons 62 256))

(while (setq blkent (tblnext "block" (null blkent)))

(setq blkname (cdr (assoc -2 blkent)))

(while blkname

(entmod (list (cons -1 blkname) newclr))

(setq blkname (entnext blkname))))

Link to comment
Share on other sites

Try it

(setq newclr (cons 62 256))
(while (setq blkent (tblnext "block" (null blkent)))
 (setq blkname (cdr (assoc -2 blkent)))
 (while blkname
   (entmod
     (if (assoc 62 (entget blkname))
       (subst newclr (assoc 62 (entget blkname)) (entget blkname))
       (append (entget blkname) (list newclr))
     ) ;_ end of if
   ) ;_ end of entmod
   (setq blkname (entnext blkname))
 ) ;_ end of while
) ;_ end of while
(command "_regenall")

Link to comment
Share on other sites

Hi VVA,

 

Unfortunately, i am still getting the same result. the code will change LINE, ARC, DTEXT, CIRCLE from forced color to bylayer, but it wont change others such as PLINE, MTEXT... any other suggestions?

 

Thanks

Link to comment
Share on other sites

setbylayer will take too long. i can open the xref, open the layer manager, select all layers, and change to bylayer. each project will have multiple xrefs, so i am trying to avoid the drafter from openeing every xref and changing layers to bylayer. also, every time we recieve updates from the architect, the process of opening xrefs and changing colors to bylayer will have to repeated.

Link to comment
Share on other sites

I have an interesting update on this issue. The code that VVA posted, works like a charm in MEP 2008, however, it does not work in MEP 2010. The difference is, in MEP 2010 it only changes LINE and CIRCLE that are forced to a color, to bylayer…

 

Somewhat on the same topic, if I use nentsel to select an xref entity (eg. line, pline, mtext…) and I use entmod to substitute the (cons 62 256) the same thing happens as above. It works flawlessly in 2008, but in 2010 it will only work for LINE and CIRCLE…

 

Any thoughts overall to why this is happening??

Link to comment
Share on other sites

I do have vba installed, but both routines are lisp, and I don’t think that vba will affect the function of the lisp, but correct me if I’m wrong. Any other ides, because I have no clue what is different in 2010 that will make the lisp routines not work?

Thanks

Link to comment
Share on other sites

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...