bustr Posted November 1, 2017 Posted November 1, 2017 I want to put this into a script. I need to select all instances of this block and change it's layer and linetype. I can't use a lisp since don't know programming. Quote
ReMark Posted November 1, 2017 Posted November 1, 2017 Did you try searching for a lisp routine? Quote
bustr Posted November 1, 2017 Author Posted November 1, 2017 That was my question: How to put this in a script. Quote
bustr Posted November 1, 2017 Author Posted November 1, 2017 I wouldn't necessarily know how to modify a lisp routine to make it work. Quote
ReMark Posted November 1, 2017 Posted November 1, 2017 Maybe someone has already written a lisp routine that will do what you want. Try a search. Quote
bustr Posted November 1, 2017 Author Posted November 1, 2017 I did. There are. The one I found selects a block and chages it's color. But since I am not a programmer I do not know how to modify the lisp. Quote
ReMark Posted November 1, 2017 Posted November 1, 2017 Why can't you just use the BEDIT command? Open the block in question in the block editor. Change it's layer and linetype via the Properties palette. When you close the block editor you'll be asked if you want to save your changes. Do so. When you pop back into your drawing all instances of the block will have been changed. Quote
bustr Posted November 1, 2017 Author Posted November 1, 2017 I have around 80 drawings with the same mistake. Quote
bustr Posted November 1, 2017 Author Posted November 1, 2017 I found this thread but the lisp to select all blocks of a certain name doesn't work and I don't know how to code. http://www.cadtutor.net/forum/showthread.php?21217-FILTER-Command/page2 Quote
BIGAL Posted November 2, 2017 Posted November 2, 2017 Try this it has no error checking as it was done quick, read the comments to understand what its doing. I did test it, it does not change stuff on various layouts as you did not mention that. It could be used with a script to do all 80 dwg's in one go, I did not want to confuse you with how to do that also. A hint though open explorer to where you have the lisp saved just drag and drop onto dwg and it will start up straight away saving a few steps. (defun c:reset-blk ( / ss newlay newlt bname) (vl-load-com) (setq obj (vlax-ename->vla-object (car (entsel "\nPick Block")))) ;pick an object and make it a Vl object (setq newlt (getstring "\nEnter linetype name Bylayer")) ; enter linetype name (setq newlay (getstring "\nEnter layer name")) ; enter new layer name (setq bname (vla-get-name obj)) ; get the blocks name (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 2 bname)))) ; make a collection of the block (repeat (setq x (sslength ss)) ; loop through the collection and change stuff (setq blk (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) ; get a block ; (vla-put-color blk 0) ; change its color 0 is Bylayer (vla-put-linetype blk newlt) ; change linetype note BYLAYER (vla-put-layer blk newlay) ; change its layer ) ) (c:reset-blk) Quote
bustr Posted November 2, 2017 Author Posted November 2, 2017 Thanks. I'm not sure how to make this work. It prompted me to enter information. I had found a fix somewhere on this forum. I put the lisp code in a script file and to my surprise it ran. (ssget "_x" '((0 . "INSERT")(2 . "BKR,BKR"))) CHANGE P P LA WHITE-018 LT BYLAYER Quote
Recommended Posts
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.