diff --git a/layout-base-v2.lsp b/layout-base-v2.lsp index f1eefda..bd97c5c 100644 --- a/layout-base-v2.lsp +++ b/layout-base-v2.lsp @@ -55,22 +55,23 @@ ) (defun labelBlockLines (block startNum) + (setq counter 0) ; Add a counter to track which attribute we're processing (foreach att (vlax-invoke block 'GetAttributes) (setq tag (strcase (vla-get-tagstring att))) (if (wcmatch tag "LINE*") (progn - (setq idx (atoi (substr tag 5))) - (setq labelNum (+ startNum (- idx 1))) + ; Use counter instead of extracting from tag + (setq labelNum (+ startNum counter)) (setq labelStr (if (< labelNum 10) (strcat "0" (itoa labelNum)) (itoa labelNum))) - ;; Use the block's X position + 0.5, and Y from the attribute + ;; Use the block's X position + 0.12, and Y from the attribute - 0.053 (setq basePt (vlax-get att 'InsertionPoint)) (setq blockPos (vlax-get block 'InsertionPoint)) ; block base point - ;; X from block + 0.5, Y from attribute - 0.05 + ;; X from block + 0.12, Y from attribute - 0.053 (setq labelPt (list (+ (car blockPos) 0.12) (- (cadr basePt) 0.053) (caddr basePt))) - (entmake + (entmakex (list (cons 0 "TEXT") (cons 8 "0") @@ -88,6 +89,7 @@ (cons 100 "AcDbText") ) ) + (setq counter (1+ counter)) ; Increment counter after processing each LINE attribute ) ) ) @@ -210,7 +212,7 @@ ) -(defun update20ZoneBlockAttributes (blockEnt layoutIndex startValue / blockObj attrList attr attrName newValue formattedValue) +(defun update20ZoneBlockAttributes (blockEnt layoutIndex startValue sideOffset / blockObj attrList attr attrName idx newValue formattedValue) (setq blockObj (vlax-ename->vla-object blockEnt)) (setq attrList (vlax-invoke blockObj 'GetAttributes)) @@ -223,8 +225,13 @@ (>= (atoi (substr attrName 5)) 1) (<= (atoi (substr attrName 5)) 20)) (progn - ;; Convert string to number, add index - (setq newValue (+ (atoi startValue) layoutIndex)) + ;; Convert string to number; compute base as start + layoutIndex + ;; then add per-line index (0-19) and side offset (0 for left, 20 for right) + (setq idx (atoi (substr attrName 5))) + (setq newValue (+ (atoi startValue) + layoutIndex + (- idx 1) + sideOffset)) ;; Format as string with period, no leading zeros (setq formattedValue (strcat (itoa newValue) ".")) @@ -283,12 +290,12 @@ (setq leftEnt (insertBlockAt "20_zone" basePt ptLeft)) (setq leftBlock (vlax-ename->vla-object leftEnt)) - (update20ZoneBlockAttributes leftEnt i startIndex) + (update20ZoneBlockAttributes leftEnt i startIndex 0) (labelBlockLines leftBlock 1) (setq rightEnt (insertBlockAt "20_zone" basePt ptRight)) (setq rightBlock (vlax-ename->vla-object rightEnt)) - (update20ZoneBlockAttributes rightEnt i startIndex) + (update20ZoneBlockAttributes rightEnt i startIndex 0) (labelBlockLines rightBlock 21) ;; Add layout label