Not applicable
06-10-2020
02:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I would like to set and update the layout names in DWG via LISP.
At the beginning, I don't know how many layouts I will need and in the case of revisions / changes, new layouts can be added at any time.
I found a great LISP from Markus Hoffmann (many thanks to CADmaro), where after (my simple) adjustments only code sequence for the maximum number of layouts is missing (marked as "(missing code for the highest layout number)"). I can't find this definition and ask for your help.
The layout names should be: e.g. Page_1from8, Page_2from8, etc.
;Set / upgrade layout names to format: Page_XfromY
(defun c:RenameAllLayouts ()
(vl-load-com)
(vlax-for i (vlax-get-property
(vlax-get-property
(vlax-get-acad-object)
'ActiveDocument
)
'Layouts
)
(if (/= 0 (vlax-get-property i 'TabOrder))
(if
(vl-catch-all-error-p
(vl-catch-all-apply
'vlax-put-property
(list
i
'Name
(strcat
"Page_"
(itoa (vlax-get-property i 'TabOrder))
"from"
(missing code for the highest layout number)
)
)
)
)
(princ
(strcat
"\nLayout "
(vlax-get-property i 'Name)
" can't be renamed, konnte nicht umbenannt werden, because the name has already been used."
)
)
)
)
)
)
;;; Quick command ALU
(defun c:ALU ()
(c:RenameAllLayouts)
)
(princ
"\n\"ALU.lsp\" was loaded. Enter \"RenameAllLayouts\" or \"ALU\" to start."
)
(princ)
Many thanks for your help in advance.
Solved! Go to Solution.
Link copied