leonucadomi Posted April 15 Posted April 15 hello all: I need to rename styles and dimension styles in many dwg I use this code (defun C:REN (/) ;Renombra stylo (command "_-rename" "S" "STYLO-1" "STYLO-PRIMARIO") (command "_-rename" "S" "STYLO-2" "STYLO-SECUNDARIO") (command "_-rename" "S" "STYLO-3" "STYLO-TERCIARIO") (command "_-rename" "D" "Shop-1" "SHOP-PRIMARIO") (command "_-rename" "D" "Shop-2" "SHOP-SECUNDARIO") (princ) ); defun The problem is that some dwg do not have all the styles and when trying to delete them the routine it doesn't find them and it shows me an error and apparently it doesn't continue the routine. Does anyone have any LSP routines to rename better? Quote
BIGAL Posted April 16 Posted April 16 You need to wrap your changes into a loop say make a list of old new names then loop through that list. (("STYLO-1" "STYLO-PRIMARIO")("STYLO-SECUNDARIO")...) Check 1st does style exist. (setq chk (tblobjname "style" tstyle)) this will return say nil if it does not exist. (foreach sty lst (setq chk (tblobjname "style" (car sty))) (if (= chk nil) (princ "miss style") (command "_-rename" "S" (car sty) (cadr sty)) ) (princ) ) 1 Quote
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.