Jump to content

Recommended Posts

Posted

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?

 

 

Posted

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

 

 

  • Thanks 1

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