josue777torsan Posted January 31, 2022 Posted January 31, 2022 (edited) I have a drawing where there are some linetypes and I want to replace all of them with HIDDEN2 (including objets into blocks), I found this code, but it only works in objets that are not into blocks. Thanks! ;Based on code by Tharwat, http://www.autolisp.com/forum/threads/774-linetype-change?p=2696&viewfull=1#post2696 (vl-load-com) (defun c:LtMerge (/ *error* lto ltn fnd ss i sn name blocks) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (princ (strcat "\nError: " errmsg))) (vla-endundomark acdoc) (princ)) (if (not acdoc) (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))) (vla-startundomark acdoc) (if (and (not (eq (setq lto (strcase (getstring "\nSpecify OLD lineType: "))) "")) (setq fnd (tblsearch "LTYPE" lto)) (not (eq (setq ltn (strcase (getstring "\nSpecify NEW lineType: "))) "")) (setq fnd (tblsearch "LTYPE" ltn)) (setq ss (ssget "_X")) (if (eq (getvar 'CELTYPE) ltn) (setvar 'CELTYPE ltn) T) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (if (eq (cdr (assoc 6 (entget sn))) lto) (vla-put-linetype (vlax-ename->vla-object sn) ltn)) (if (and (eq (cdr (assoc 0 (entget sn))) "INSERT") (not (member (setq name (cdr (assoc 2 (entget sn)))) blocks)) ) (progn (setq blocks (cons name blocks)) (vlax-for each (vla-item (vla-get-blocks acdoc) name) (if (eq (vla-get-linetype each) lto) (vla-put-linetype each ltn))) ) ) ) ) (command "_.-PURGE" "_lt" lto "_n") (cond ((not ltn) (princ "\n LineType is nil ")) ((not fnd) (princ "\n Couldn't find the Linetype or not loaded ")) ) (vla-regen acdoc AcallViewports) (vla-endundomark acdoc) (princ) ) @Lee Mac Edited January 31, 2022 by josue777torsan Quote
mhupp Posted February 1, 2022 Posted February 1, 2022 don't know how to do it with lisp but you can just delete it from the linetype manager. it should give you a warning saying if you delete this line type it will delete all entity's assigned it. or you can re assign a new line type to those entity's. or that's what it does in BricsCAD. 1 Quote
josue777torsan Posted February 1, 2022 Author Posted February 1, 2022 Thanks, @mhupp, it looks great, but rather I'm looking for a free solution Quote
mhupp Posted February 1, 2022 Posted February 1, 2022 That is a free solution type "linetype" to bring up the linetype manager in autocad should look like this. Select hidden 2 and delete in the top right. 1 Quote
josue777torsan Posted February 1, 2022 Author Posted February 1, 2022 Sorry, maybe I was not clear. I don't want to delete HIDDEN2, I want to replace with it all other linetypes (except Continuous), or merge them (like when merge layers) 1 Quote
Steven P Posted February 1, 2022 Posted February 1, 2022 Just quickly testing the code you posted, normally I would expect Tharwats code to be OK. So made a block with 4 lines and also the same 4 lines not in a block.. and it appears to change the line type inside and outside he block as you were wanting. Would you be able to post an example block that you are trying to update and perhaps a before and after type of thing? 1 Quote
josue777torsan Posted February 1, 2022 Author Posted February 1, 2022 8 minutes ago, Steven P said: Just quickly testing the code you posted, normally I would expect Tharwats code to be OK. So made a block with 4 lines and also the same 4 lines not in a block.. and it appears to change the line type inside and outside he block as you were wanting. Would you be able to post an example block that you are trying to update and perhaps a before and after type of thing? Oh! you are right, but I noticed that the LISP doesn't work in blocks into another block, maybe thats the main problem why I couldn't apply it Quote
Steven P Posted February 1, 2022 Posted February 1, 2022 OK we can have a think then how to add nested blocks to the routine, I think there are a couple of if statements in there, one 'if' for outside of a block to change the line type,s one 'if' for inside a block to change the line type, it might be just as simple as looping through the nested blocks from there to change the line types I'll have a think later 1 Quote
mhupp Posted February 1, 2022 Posted February 1, 2022 2 hours ago, josue777torsan said: Sorry, maybe I was not clear. I don't want to delete HIDDEN2, I want to replace with it all other linetypes (except Continuous), or merge them (like when merge layers) No your not understanding me. By deleting the Hidden2 line type Autocad should ask you what do do with the entity's that have it assigned. Either delete them The option you don't want or Reassign them to a different line type aka merge them. having trouble uploading the gif so use this link to see what im talking about. https://ibb.co/q7k6Qg4 Quote
josue777torsan Posted February 1, 2022 Author Posted February 1, 2022 I see... but I'm afraid that's not possible in AutoCAD, I think that just works on BricsCAD Quote
devitg Posted February 1, 2022 Posted February 1, 2022 @josue777torsan , why not to upload a sample dwg? So all facts can be handled / Quote
josue777torsan Posted February 1, 2022 Author Posted February 1, 2022 14 minutes ago, devitg said: @josue777torsan , why not to upload a sample dwg? So all facts can be handled / Sorry, I just test the code I posted first and magically works fine, in any case I've attached the lisp file and dwg file for you. Thanks. LTMerge test.dwg LTMerge.lsp 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.