1
AutoLISP (Vanilla / Visual) / Re: Issue with Layout - Copy Command
« Last post by BIGAL on May 16, 2024, 09:33:25 PM »No idea use copy layout a lot, but I am not on 2025, maybe (setvar 'ctab "Template") 1st then do copy layout.
...so I end up with crossing lines instead of parallel lines...
It could be that I made mistake with (set) function... It requires symbols instead of lists... Corrected now and it should work...
OP, what do you mean - not create any lines at all? It's clearly written in my code : (command "_.line" ... )
Added checking if the plot style exists.
(setq ctbLower (strcase ctb nil))
(setq installedPsLower (mapcar '(lambda (ps) (strcase ps nil)) installedPs))
(if (/= nil (vl-position ctbLower installedPsLower))
;;----------------------------------------------------------------------;;
;; setPlotStyle FUNCTION
;; https://www.theswamp.org/index.php?topic=45000.msg502065#msg502065
;; Added checking if the plot style exists by 3dwananb on 2024.05.15
(defun setPlotStyle (ctb / CurDoc installedPs ctbLower installedPsLower)
;; Get the active document
(setq CurDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
;; Get the list of installed plot styles
(setq installedPs (vlax-safearray->list (vlax-variant-value (vla-GetPlotStyleTableNames (vla-get-ActiveLayout CurDoc)))))
;; Convert the input plot style name and the list of installed plot styles to lowercase for case-insensitive comparison
(setq ctbLower (strcase ctb nil))
(setq installedPsLower (mapcar '(lambda (ps) (strcase ps nil)) installedPs))
;; Check if the specified plot style exists in a case-insensitive manner and set it
(if (vl-position ctbLower installedPsLower)
(progn
(princ (strcat "\nPlot Style successfully set to: '" ctb "'\n"))
(vlax-map-collection
(vla-get-Layouts CurDoc)
'(lambda (x) (vla-put-StyleSheet x ctb))
)
)
(progn
(princ (strcat "\nPlot Style '" ctb "' not found!\n"))
;; Print the available plot style tables if the specified plot style is not found
(princ "\nAvailable plot style tables:\n")
(mapcar '(lambda (ps) (princ (strcat ps ""))) installedPs)
)
) ;; If plotstyle exists, set it; otherwise, print available plot styles.
)
;; Example invocation
(setPlotStyle "monochrome.ctb")
(setq CurDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq installedPs (vlax-safearray->list (vlax-variant-value (vla-GetPlotStyleTableNames (vla-get-ActiveLayout CurDoc)))))