Jump to content

Replace LINETYPE with another one in dwg and all blocks inside.


ibach

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by SLW210
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

"*$*" 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.

Link to comment
Share on other sites

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