delete the character DPF

delete the character DPF

long.nguyen6GY5K
Observer Observer
289 Views
4 Replies
Message 1 of 5

delete the character DPF

long.nguyen6GY5K
Observer
Observer

simple one to solve I think

I need a lisp to delete all "-DPF" word inside all dwg drawing inside one folder.

... So basically It would open each drawing and make sure to delete DPF from title, inside block or simple text... then close it and save it. 

 

Can anyone help me? here is a drawing for exemple.

 

Also for bonus can you guys tell me how do we rename in CMD command so that all my files remove the DPF ?

I have done it before so, I need a reminder how to do it. 

 

Thanks guys 

0 Likes
290 Views
4 Replies
Replies (4)
Message 2 of 5

pendean
Community Legend
Community Legend

@long.nguyen6GY5K wrote:

simple one to solve I think

I need a lisp to delete all "-DPF" word inside all dwg drawing inside one folder.


Why not just use a freeware renaming tool in your OS if I may ask? 

0 Likes
Message 3 of 5

long.nguyen6GY5K
Observer
Observer

Can you explain what renaming tool you are referring to? 

 

Also can it erase or replace text in autocad?

0 Likes
Message 4 of 5

long.nguyen6GY5K
Observer
Observer

I found this but what I need would be something like...

 

remove -DPF from

XXX-XXX-XXX-DPF-XXX-XX OR XXX-DPF as seen inside of the dwg

 

 

;;
;;  By Don Ireland
;;
;;  Takes two arguments:  A String to search for and a string to search in.
;;  Usage:  (charfind "ST" "TEST") ; This will return 3.
;;
;;  Example:  (if (> (setq pos (charfind "S" "TEST")) 0)(princ "Found the letter S at position:  " . pos)(Princ "One or both search parameters was blank"))
;;
;;  Return Values:
;;  -1 = character not found within given string.
;;  -2 = Search string is empty.  (srch)
;;  -4 = Test String is empty.  (str)
;;  -6 = Search String and Test String are both empty.

(defun strfind(srch str / pt pt2 cnt)
  (setq cnt 0 pt 0 pt2 nil)
  (if (EQ (strlen srch) 0) (setq pt -2))
  (if (EQ (strlen str) 0) (setq pt (+ pt (- 0 4))))
  (if (EQ pt 0)(setq pt -1))
  (while (and (< pt 0) (> (strlen str) 0)(< cnt (strlen str)))
    (if (eq srch (substr str (setq cnt (1+ cnt)) (strlen srch)))(setq pt cnt))
  )
  (setq pt2 pt)
)
(defun remTxt(ba)
  (setq ent(ssget '(
                   (-4 . "<OR")
                   (0 . "TEXT")(0 . "MTEXT")
                   (-4 . "OR>")
                   ))
  )

  (setq cnt -1)
  (repeat (sslength ent)
    (setq cent (entget (ssname ent (setq cnt (1+ cnt)))))
    (setq cur (cdr(assoc 1 cent)))
    (setq pos (strfind "-" cur))
    (if (EQ ba 1)
      (setq new (substr cur 1 (1- pos)))
      (setq new (substr cur (1+ pos) (strlen cur)))
    )
    (setq cent(subst (cons 1 New) (cons 1 cur) cent))
    (entmod cent)
  )
)
(defun c:remA()
  (remTxt 1)
)
(defun c:remB()
  (remTxt 0)
)
0 Likes
Message 5 of 5

Sea-Haven
Mentor
Mentor

Your looking for accoreconsole which is ran from CMD it loads a dwg and runs a script. The script can call a lisp. It does not open Autocad but rather runs in a OS window. 

 

https://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-consol...

0 Likes