- 积分
- 6789
- 明经币
- 个
- 注册时间
- 2011-3-18
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2020-2-24 07:41:45
|
显示全部楼层
本帖最后由 baoxiaozhong 于 2020-2-24 07:45 编辑
只有简单的去除前缀。
(defun c:RBP(/ ActDoc Name NewName)
; RemoveBindPrefixes
; Renames layers, blocks, dimension styles, text styles, user coordinate systems, and views
; by taking out the bind as bind prefix
; Example Drawing1$0$Layer1 -> Layer1
(vl-load-com)
(defun RemoveBindPrefix (String / Pos LastPos)
(if (setq Pos (vl-string-search "$" String))
(progn
(setq LastPos Pos)
(while (setq Pos (vl-string-search "$" String (1+ Pos)))
(setq LastPos Pos)
)
(substr String (+ 2 LastPos))
)
String
)
)
;---------------------------------------------------------
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vlax-for Obj (vla-get-Layers ActDoc)
(setq Name (vla-get-Name Obj))
(if (/= (setq NewName (RemoveBindPrefix Name)) Name)
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName)))
(prompt (strcat "\n Layer: " Name " was not renamed."))
)
)
)
(vlax-for Obj (vla-get-Blocks ActDoc)
(setq Name (vla-get-Name Obj))
(if (/= (setq NewName (RemoveBindPrefix Name)) Name)
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName)))
(prompt (strcat "\n Block: " Name " was not renamed."))
)
)
)
(vlax-for Obj (vla-get-TextStyles ActDoc)
(setq Name (vla-get-Name Obj))
(if (/= (setq NewName (RemoveBindPrefix Name)) Name)
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName)))
(prompt (strcat "\n Text style: " Name " was not renamed."))
)
)
)
(vlax-for Obj (vla-get-Views ActDoc)
(setq Name (vla-get-Name Obj))
(if (/= (setq NewName (RemoveBindPrefix Name)) Name)
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName)))
(prompt (strcat "\n View: " Name " was not renamed."))
)
)
)
(vlax-for Obj (vla-get-UserCoordinateSystems ActDoc)
(setq Name (vla-get-Name Obj))
(if (/= (setq NewName (RemoveBindPrefix Name)) Name)
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName)))
(prompt (strcat "\n UCS: " Name " was not renamed."))
)
)
)
(vlax-for Obj (vla-get-DimStyles ActDoc)
(setq Name (vla-get-Name Obj))
(if (/= (setq NewName (RemoveBindPrefix Name)) Name)
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName)))
(prompt (strcat "\n Dimension style: " Name " was not renamed."))
)
)
)
(princ)
) |
|