ibach Posted December 22, 2012 Share Posted December 22, 2012 I have huge DWG file and during process of creation some strange things happened to it. LINE TYPES like "$0$$0$ACAD_ISO3W100" "$0$$0$ACAD_ISO7W100" "$0$$0$HIDDEN" "$0$ACAD_ISO3W100" "$0$ACAD_ISO7W100" "$0$ACAD_ISO10W100" "$0$CENTER" "$0$DOT" "$0$HIDDEN" "$0$ZIGZAG" Appeared in blocks. i need to change them to normal named ones without $0$blabla in front of it. I really do not know how to write a lisp that would go trough blocks and change e.g. "$0$ACAD_ISO10W100" to "ACAD_ISO10W100" in any objects property. HELP PLEASE! Quote Link to comment Share on other sites More sharing options...
ibach Posted December 22, 2012 Author Share Posted December 22, 2012 By the way that is not all. The same thing happened with dimension styles and text styles so i need a lisps to change those from one style to another in drawing and nested blocks, and without losing dynamic block functionality... It also happened to layers, but I was able to merge layers to normal named ones. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 22, 2012 Share Posted December 22, 2012 Looks like the result of binding an XRef with BINDTYPE set to 0 Quote Link to comment Share on other sites More sharing options...
ibach Posted December 22, 2012 Author Share Posted December 22, 2012 Probably. Many people worked on this one doing a lot of unhappy things... now i'm the one to bring it in oreder, but it takes 3 minutes to open any layout, and there are about 100 of them. not to mention blocks... Quote Link to comment Share on other sites More sharing options...
ibach Posted December 22, 2012 Author Share Posted December 22, 2012 (edited) BTW i've found lisp like this: (defun c:clr2by (/ doc blks lays lokt new-ltype old-ltype) ;;convert all objects in a drawing to color=bylayer ;;by Jeff Mishler - updated 7/25/05 to handle dimension colors ;;updated 1/05/06 to affect Attributes and to change a specific linetype to another ;;Modified, Bob Shaw (ECCAD)..Added Lists of Linetypes to swap. (vl-load-com) ;; List of Linetypes to swap.. (setq Old_lt_lst (list "$$$bla_bla" )) (setq New_lt_lst (list "ZIGZAG" )) ;; (setq doc (vla-get-activedocument (vlax-get-acad-object)) blks (vla-get-blocks doc) lays (vla-get-layers doc) ;;;;old-ltype "OLD" ;;;;; change this to match your old ltype ;;;;new-ltype "NEW" ;;;;; change this to match your new ltype ) (vlax-for lay lays (if (eq (vla-get-lock lay) :vlax-true) (progn (setq lokt (cons lay lokt)) (vla-put-lock lay :vlax-false) ) ) ) (vlax-for blk blks (vlax-for ent blk (mapcar '(lambda (x) (if (vlax-property-available-p ent x) (vlax-put ent x 256) ) ) (list "Color" "DimensionLineColor" "ExtensionLineColor" "TextColor") ) (if (and (vlax-property-available-p ent 'hasattributes) (eq (vla-get-hasattributes ent) :vlax-true) ) (foreach att (vlax-invoke ent 'getattributes) (vla-put-color att 256) ) ) ;; (setq n 0) (repeat (length Old_lt_lst) (setq Olt (nth n Old_lt_lst)) (setq Nlt (nth n New_lt_lst)) (if (and (eq (vla-get-linetype ent) Olt) (tblsearch "LTYPE" Nlt)) (vla-put-linetype ent Nlt) ) (setq n (+ n 1)) ); repeat ;; ) ) (if lokt (mapcar '(lambda (x) (vla-put-lock x :vlax-true) ) lokt ) ) (princ) ) (c:clr2by); and run it. Edited December 26, 2012 by SLW210 Quote Link to comment Share on other sites More sharing options...
ibach Posted December 22, 2012 Author Share Posted December 22, 2012 but it also ;convert all objects in a drawing to color=bylayer which i do not want to do. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 22, 2012 Share Posted December 22, 2012 Try this quickly written code: (defun c:fixlt ( / n ) (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (and (= :vlax-false (vla-get-islayout b)) (= :vlax-false (vla-get-isxref b)) ) (vlax-for o b (if (and (wcmatch (setq n (vla-get-linetype o)) "*$*") (setq n (substr n (+ 2 (vl-string-position 36 n 0 t)))) (tblsearch "LTYPE" n) ) (vl-catch-all-apply 'vla-put-linetype (list o n)) ) ) ) ) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
ibach Posted December 22, 2012 Author Share Posted December 22, 2012 Not that i understand it, but i will. Working..... working... takes time... thank you for helping in the meantime... working still... Quote Link to comment Share on other sites More sharing options...
ibach Posted December 22, 2012 Author Share Posted December 22, 2012 Man, what ewer you wrote worked on 10 linetypes but "$0$ZIGZAG" still remained. i think it is because it was not loaded. ill try loading it. Quote Link to comment Share on other sites More sharing options...
ibach Posted December 22, 2012 Author Share Posted December 22, 2012 now what was done? can you explain in short? and yes loading zigzag worked! all linetypes are ok now. THANK YOU !!! dimension styles and text styles still remain as problem. Quote Link to comment Share on other sites More sharing options...
ibach Posted December 22, 2012 Author Share Posted December 22, 2012 Now, i did audit ... it summed up like this Command: AUDIT Fix any errors detected? [Yes/No] : y Auditing Header Auditing Tables Auditing Entities Pass 1 Pass 1 623800 objects audited Auditing Entities Pass 2 Pass 2 587400 objects auditedAcDbBlockReference(6E0025) BTR Id invalid AcDbBlockReference(6E0025) could not be repaired. It will be Erased. Pass 2 594400 objects auditedAcDbBlockReference(6F5B11) BTR Id invalid AcDbBlockReference(6F5B11) could not be repaired. It will be Erased. Pass 2 623800 objects audited Auditing Blocks 37047 Blocks audited Auditing AcDsRecords Total errors found 2 fixed 2 Erased 2 objects not sure what was erased... it'll take time to check the drawing... Quote Link to comment Share on other sites More sharing options...
ibach Posted December 23, 2012 Author Share Posted December 23, 2012 all seems to be in place. I have an other problem too, I cannot copy paste anything from an other drawing to this one nor can I do Data Extraction from this file at all ... Quote Link to comment Share on other sites More sharing options...
ibach Posted December 23, 2012 Author Share Posted December 23, 2012 little bit of purging... Data Extraction works now... this lisp magic really worked. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 23, 2012 Share Posted December 23, 2012 all linetypes are ok now. THANK YOU !!! You're welcome. now what was done? can you explain in short? My program iterates over every graphical object in the drawing, and, if the object's linetype contains the '$' character, the program will retrieve the set of characters following the last '$' character, check if such linetype is loaded, and if so, will assign the linetype to the object. Hence, '$0$ZIGZAG' becomes 'ZIGZAG', providing the linetype is loaded. Quote Link to comment Share on other sites More sharing options...
ibach Posted December 23, 2012 Author Share Posted December 23, 2012 "*$*" told me that much. nicely solved. takes me time to read code when had no sleep in 5 days... i've just printed 150m2 of paper from that dwg and corrected errors on the fly. you saved me about 3 hours of cycling trough viewports to read some data from block attributes manually, as after your lisp Data Extraction worked. thank you again. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 23, 2012 Share Posted December 23, 2012 You're very welcome ibach, a 3-hour time saving isn't bad for a program I just threw together - my cheque is in the post right? Quote Link to comment Share on other sites More sharing options...
ibach Posted December 26, 2012 Author Share Posted December 26, 2012 (edited) upgrade this code to do the same for block names and layer names, make it go trough all the blocks and unlock/unfreeze layers and return lock/freeze state at the end and you have a very very useful lisp definitely worth publishing (not that this one did not help). add rename by filter option and it's worth selling. never had time to go trough learning lisp well (stopped programming somewhere in the dos-basic era). should upgrade my knowledge. what i do know is what i really could use. Edited December 26, 2012 by ibach Quote Link to comment Share on other sites More sharing options...
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.