CharlieDFW Posted 2 hours ago Posted 2 hours ago Is it possible to import surface styles from my template using lisp? I asked Claude and the lisp provided inserts all object styles. ;;-------------------------=={ Import Alignment Styles }==---------------;; ;; ;; ;; Imports Alignment Styles from Power Generation template ;; ;; Uses INSERT method to import block with embedded styles ;; ;; ;; ;;----------------------------------------------------------------------;; (defun C:PG-INS-ALIGN ( / template_dwg curecho curlayer block_name *error*) ;; Error handler (defun *error* (msg) (if curecho (setvar "CMDECHO" curecho)) (if curlayer (setvar "CLAYER" curlayer)) (if (not (member msg '("Function cancelled" "quit / exit abort"))) (princ (strcat "\nError: " msg)) ) (princ) ) ;; Save current settings (setq curecho (getvar "CMDECHO")) (setq curlayer (getvar "CLAYER")) (setvar "CMDECHO" 0) ;; Set template path and block name (setq template_dwg "C:/WSB-DT/Autodesk/Power Generation/Templates/Utility Scale Solar/RENEWABLES-CT-DESIGN.dwt") (setq block_name "TPLT-Alignment-Styles") ;; Check if template file exists (if (findfile template_dwg) (progn (princ "\n----------\nImporting Alignment Styles...") ;; Set layer to 0 (setvar "CLAYER" "0") ;; Insert block from template ;; Format: blockname=filepath (command "_.INSERT" (strcat block_name "=" template_dwg) "0,0,0" ; Insertion point "" ; X scale (default) "" ; Y scale (default) "") ; Rotation (default) ;; Check if insert was successful (if (entlast) (progn ;; Explode the inserted block (command "_.EXPLODE" (entlast)) ;; Purge the block definition (command "._-PURGE" "_B" block_name "_N") ;; Run audit to verify drawing integrity (command "._AUDIT" "_Y") (princ "\n----------\nPower Generation Alignment Styles Have Been Imported!") ) (progn (princ "\n----------\nERROR: Block insertion failed!") (princ (strcat "\nBlock '" block_name "' not found in template")) (princ "\n----------") ) ) ;; Restore settings (setvar "CLAYER" curlayer) (setvar "CMDECHO" curecho) ) (progn ;; Template file not found (setvar "CMDECHO" curecho) (princ "\n----------\nERROR: Template file not found!") (princ (strcat "\nLooking for: " template_dwg)) (princ "\nPlease verify the path is correct") (princ "\n----------") ) ) (princ) ) ;;----------------------------------------------------------------------;; ;; Load Confirmation ;; ;;----------------------------------------------------------------------;; (princ "\n----------") (princ "\nAlignment Style Import Command Loaded:") (princ "\n PG-INS-ALIGN - Import Alignment Styles") (princ "\n") (princ "\nNote: Template must contain a block named 'TPLT-Alignment-Styles'") (princ "\n with embedded alignment style definitions") (princ "\n----------") (princ) 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.