mostafa badran 发表于 2022-7-5 23:17:25

Remove $ from layer name

hi all,I need help, I need lisp which can remove $ from layer name ,block name ,style text ,etc. with explain the steps of syntax of lisp.
thanks for help.
mostafa

tzframpton 发表于 2022-7-5 23:41:38

You can already accomplish this with the RENAME tool, utilizing wildcard matches to edit all names in these categories.

mostafa badran 发表于 2022-7-5 23:48:20

Thanks tzframpton fro respond,can you to clarify more,there's too much layers, blocks,the RENAME tool renamed as single category.

asos2000 发表于 2022-7-6 00:13:36

Start withthis one

(defun c:BF;/////////////////////////////////////////////////////////////////////////;;BindFix15.lsp (AutoCAD 2000+);;Copyright 2003 | Michael Puckett | All Rights Reserved;;/////////////////////////////////////////////////////////////////////////(/   ;local defuns   __GetTableEntries   __RenameTableEntry   __RenameTableEntryViaObjname   __RenameTableEntryViaActiveX   __StripBindingArtifacts   __GetUniqueTableEntryName   ;local vars   doc   newname);/////////////////////////////////////////////////////////////////////////;;local defun;;/////////////////////////////////////////////////////////////////////////(defun __GetTableEntries ( table / data result )   (while (setq data (tblnext table (null data)))      (setq result         (cons (cdr (assoc 2 data)) result)      )   )   result);/////////////////////////////////////////////////////////////////////////;;local defun;;/////////////////////////////////////////////////////////////////////////(defun __RenameTableEntry ( doc table oldname newname / data )   ;wrapper for __RenameTableEntryViaObjname   ;and __RenameTableEntryViaActiveX functions   (setq table      (cond         ((eq (setq table (strcase table t)) "ltype") "linetype")         (t table)      )   )   (if (member table '("style" "dimstyle"))      ;autodesk made textstyles and dimstyles read-only to      ;the automation model w/regards to the symbol name, why?      (__RenameTableEntryViaObjname table oldname newname)      (__RenameTableEntryViaActiveX doc table oldname newname)   ));/////////////////////////////////////////////////////////////////////////;;local defun;;/////////////////////////////////////////////////////////////////////////(defun __RenameTableEntryViaObjname ( table oldname newname / data )   ;calling function responsible for   ;ensuring appropriate data passed   (entmod      (subst         (cons 2 newname)         (assoc 2 (setq data (entget (tblobjname table oldname))))         data      )   ));/////////////////////////////////////////////////////////////////////////;;local defun;;/////////////////////////////////////////////////////////////////////////(defun __RenameTableEntryViaActiveX ( doc table oldname newname / data )   ;calling function responsible for   ;ensuring appropriate data passed   (vla-put-name      (vla-item         (eval            (list               (read (strcat "vla-get-" table "s"))               doc            )         )         oldname      )      newname   )   ;if you wanted this to be more robust   ;you could use the following ...   ;   ;(vl-catch-all-apply   ;   (function   ;      (lambda ()   ;         (vla-put-name ...)   ;      )   ;   )   ;)   ;   ;I chose to pass valid data instead);/////////////////////////////////////////////////////////////////////////;;local defun;;/////////////////////////////////////////////////////////////////////////(defun __StripBindingArtifacts ( entry / i done )   (cond      ((wcmatch entry "*`$#`$*")         (setq i 0 ceiling (strlen entry))         (while (and (not done) (< i ceiling))            (if (wcmatch (substr entry (setq i (1+ i)) 3) "`$#`$*")               (setq                  entry (substr entry (+ i 3))                  donet               )            )         )      )   )   entry);/////////////////////////////////////////////////////////////////////////;;local defun;;/////////////////////////////////////////////////////////////////////////(defun __GetUniqueTableEntryName ( table entry )   (cond      ((tblsearch table entry)         (setq i 1)         (while            (tblsearch table               (strcat entry "_" (itoa (setq i (1+ i))))            )         )         (strcat entry "_" (itoa i))      )      (t entry)   ));/////////////////////////////////////////////////////////////////////////;;"main";;/////////////////////////////////////////////////////////////////////////(cond   ((< 14 (atoi (getvar "acadver")))      (vl-load-com)      (setq doc (vla-get-activedocument (vlax-get-acad-object)))      (foreach table '("block" "dimstyle" "layer" "ltype" "style")         (foreach entry (reverse (__GetTableEntries table))            (cond               ((wcmatch entry "*`$#`$*")                  (__RenameTableEntry                     doc                     table                     entry                     (setq newname                        (__GetUniqueTableEntryName table                           (__StripBindingArtifacts entry)                        )                     )                  )                  (princ                     (strcat "\n"                        (if (tblsearch table newname)                           (strcat                              "Renamed "                              table " "                              entry " => "                              newname "."                           )                           (strcat                              "Could not rename "                              table " "                              entry "."                           )                        )                     )                  )               )            )         )      )   )   (t (princ "\nSorry, penned for AutoCAD 2000+.")))(princ))

mostafa badran 发表于 2022-7-6 00:30:16

Thanks Mr asos2000 I will try this,thanks for your response.
页: [1]
查看完整版本: Remove $ from layer name