
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm a total noob with this. I've searched what i'm looking for but I can't find exactly what I want.
My goal is a lisp that ask you for a prefix, and what number should start renumbering the layouts.
So, you introduce for example "C-2-" and "5", and all the layouts should be like "C-2-05, C-2-06...." (with the zero when its <10).
I've tried modifying some scripts I've found in this forum and merging them. So my script is this:
(defun c:renombrapres (/ acad-object active-document layouts lout i prefijo) (setq prefijo (getstring "\by HCP - Inserta prefijo:")) (setq acad-object (vlax-get-acad-object)) (setq active-document (vla-get-activedocument acad-object)) (setq layouts (vla-get-layouts active-document)) (setq i 1) (vlax-for lout layouts (if (/= (vla-get-name lout) "Model") (if( > i 9) (vla-put-name lout (strcat prefijo (rtos i 2 0))) (vla-put-name lout (strcat prefijo "0" (rtos i 2 0)))) ) (setq i (1+ i)) (vlax-release-object lout) ) (vlax-release-object layouts) (vlax-release-object active-document) (vlax-release-object acad-object) (setq i 1) (prompt "by HCP - Listo!") (princ) )
But it doesnt work properly, becuase
- It wont ask for the starting number
- The first time runs fine, but the next, sometimes it will start numbering at 02, dont know why.
I have tried this variation but It gives me an error with the number I enter, so It don't work at all.
(defun c:renombrapres (/ acad-object active-document layouts lout i prefijo num) (setq prefijo (getstring "\byy HCP - Inserta prefijo:")) (setq num (getint "\by HCP - Inserta primer número (sin 0):")) (setq acad-object (vlax-get-acad-object)) (setq active-document (vla-get-activedocument acad-object)) (setq layouts (vla-get-layouts active-document)) (setq i num) (vlax-for lout layouts (if (/= (vla-get-name lout) "Model") (if( > i 9) (vla-put-name lout (strcat prefijo (rtos i 2 0))) (vla-put-name lout (strcat prefijo "0" (rtos i 2 0)))) ) (setq i (num + i)) (vlax-release-object lout) ) (vlax-release-object layouts) (vlax-release-object active-document) (vlax-release-object acad-object) (prompt "by HCP - Listo!") (princ) )
Please help me!!
Thank you very much!!!
PS:Sorry my bad english
Solved! Go to Solution.