modified base scritpt. there was label display issue
This commit is contained in:
parent
1bbe001d0d
commit
22c335e06e
@ -55,22 +55,23 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
(defun labelBlockLines (block startNum)
|
(defun labelBlockLines (block startNum)
|
||||||
|
(setq counter 0) ; Add a counter to track which attribute we're processing
|
||||||
(foreach att (vlax-invoke block 'GetAttributes)
|
(foreach att (vlax-invoke block 'GetAttributes)
|
||||||
(setq tag (strcase (vla-get-tagstring att)))
|
(setq tag (strcase (vla-get-tagstring att)))
|
||||||
(if (wcmatch tag "LINE*")
|
(if (wcmatch tag "LINE*")
|
||||||
(progn
|
(progn
|
||||||
(setq idx (atoi (substr tag 5)))
|
; Use counter instead of extracting from tag
|
||||||
(setq labelNum (+ startNum (- idx 1)))
|
(setq labelNum (+ startNum counter))
|
||||||
(setq labelStr (if (< labelNum 10)
|
(setq labelStr (if (< labelNum 10)
|
||||||
(strcat "0" (itoa labelNum))
|
(strcat "0" (itoa labelNum))
|
||||||
(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 basePt (vlax-get att 'InsertionPoint))
|
||||||
(setq blockPos (vlax-get block 'InsertionPoint)) ; block base point
|
(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)))
|
(setq labelPt (list (+ (car blockPos) 0.12) (- (cadr basePt) 0.053) (caddr basePt)))
|
||||||
(entmake
|
(entmakex
|
||||||
(list
|
(list
|
||||||
(cons 0 "TEXT")
|
(cons 0 "TEXT")
|
||||||
(cons 8 "0")
|
(cons 8 "0")
|
||||||
@ -88,6 +89,7 @@
|
|||||||
(cons 100 "AcDbText")
|
(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 blockObj (vlax-ename->vla-object blockEnt))
|
||||||
(setq attrList (vlax-invoke blockObj 'GetAttributes))
|
(setq attrList (vlax-invoke blockObj 'GetAttributes))
|
||||||
@ -223,8 +225,13 @@
|
|||||||
(>= (atoi (substr attrName 5)) 1)
|
(>= (atoi (substr attrName 5)) 1)
|
||||||
(<= (atoi (substr attrName 5)) 20))
|
(<= (atoi (substr attrName 5)) 20))
|
||||||
(progn
|
(progn
|
||||||
;; Convert string to number, add index
|
;; Convert string to number; compute base as start + layoutIndex
|
||||||
(setq newValue (+ (atoi startValue) 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
|
;; Format as string with period, no leading zeros
|
||||||
(setq formattedValue (strcat (itoa newValue) "."))
|
(setq formattedValue (strcat (itoa newValue) "."))
|
||||||
@ -283,12 +290,12 @@
|
|||||||
|
|
||||||
(setq leftEnt (insertBlockAt "20_zone" basePt ptLeft))
|
(setq leftEnt (insertBlockAt "20_zone" basePt ptLeft))
|
||||||
(setq leftBlock (vlax-ename->vla-object leftEnt))
|
(setq leftBlock (vlax-ename->vla-object leftEnt))
|
||||||
(update20ZoneBlockAttributes leftEnt i startIndex)
|
(update20ZoneBlockAttributes leftEnt i startIndex 0)
|
||||||
(labelBlockLines leftBlock 1)
|
(labelBlockLines leftBlock 1)
|
||||||
|
|
||||||
(setq rightEnt (insertBlockAt "20_zone" basePt ptRight))
|
(setq rightEnt (insertBlockAt "20_zone" basePt ptRight))
|
||||||
(setq rightBlock (vlax-ename->vla-object rightEnt))
|
(setq rightBlock (vlax-ename->vla-object rightEnt))
|
||||||
(update20ZoneBlockAttributes rightEnt i startIndex)
|
(update20ZoneBlockAttributes rightEnt i startIndex 0)
|
||||||
(labelBlockLines rightBlock 21)
|
(labelBlockLines rightBlock 21)
|
||||||
|
|
||||||
;; Add layout label
|
;; Add layout label
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user