Jump to content

Lisp to change linetype in block bylayer


mxpxh2o

Recommended Posts

Hi,

 

i've been searching for a while not but cannot find one. I need to change both the linetypes and colours of lots of blocks to BYLAYER. I have found a lisp routine to do the colour here http://www.cadcorner.ca/lisp.php but i am still unable to find one to do linetype. I have no idea how to write lisps but am trying to learn atm. Any help would be great.

 

Thanks.

Link to comment
Share on other sites

Seems to me that the FixBlock.lsp routine from that site is changing both color and linetype to ByBlock; it also move nested entities in layer 0 (just checked the code).

 

Regards,

Link to comment
Share on other sites

I actually saw that one but it didnt even occur to me to use that one first then the colour one until you posted. Thanks.

Link to comment
Share on other sites

... use that one first then the colour one ...

 

You don't need to use other routine to change the color - the above FixBlock tool is doing all-in-one.

 

Regards,

Link to comment
Share on other sites

Yes but i need both the colour and linetype to be BYLAYER. This routine makes the colour BYBLOCK. But the other one I have changes the colour BYLAYER so if I use that afterwards the colour and linetype will be BYLAYER.

Link to comment
Share on other sites

OK, I see now; may change that code as per below example to fit your needs:

 

 
[color=red](cons 6 "BYBLOCK")[/color] replace with [color=green](cons 6 "ByLayer")[/color]
[color=red](cons 62 0)[/color] replace with [color=green](cons 62 256)[/color]

 

Regards,

Link to comment
Share on other sites

Thank you, This worked great. Well with only one problem, the lisp willnot respond to the fixblock command once loaded. I have to go in and load it every time. Is there a way to map a button to a lisp routine?

Link to comment
Share on other sites

This is because it is defined as function, not as command – just add code below at the end of the file:

(defun c:FxB()   ;define FxB command
(d_FixBlock)
(princ)
)

 

This will define the FxB command - add it to your toolbar as any built-in command. Add the file to Start-up suite to have it automatically loaded in each drawing.

 

Regards,

Link to comment
Share on other sites

Thank you very much. This lsp does everything i want it. My Life = Easier.

 

Im trying to learn how to write lisps at the minute but im finding it very difficult.

 

Thanks, Sean.

Link to comment
Share on other sites

By the way, you may also want to avoid the routine to be executed at file loading; to do so just place in comment the function call line:

 

[color=DarkGreen];[/color](fb)

 

Regards,

Link to comment
Share on other sites

Hi,

 

i've been searching for a while not but cannot find one. I need to change both the linetypes and colours of lots of blocks to BYLAYER.

Look here

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