This commit is contained in:
Salijoghli 2025-11-21 15:11:29 +04:00
parent 65b3f959a8
commit e9563e61c0
2 changed files with 337 additions and 86 deletions

View File

@ -1,8 +1,6 @@
;;; automation-master-sequential.lsp ;;; automation-master-sequential.lsp
;;; Sequential CSV reading by TAGNAME, place blocks and populate attributes immediately. ;;; Sequential CSV reading by TAGNAME, place blocks and populate attributes immediately.
;;; devlay_update section starts here
(defun disable-snap-states () (defun disable-snap-states ()
"Turn OFF Osnap, Ortho, and Object Snap Tracking" "Turn OFF Osnap, Ortho, and Object Snap Tracking"
@ -39,6 +37,8 @@
(princ "\nSnap states enabled...") (princ "\nSnap states enabled...")
) )
;; devlay_update section starts here
;; Function to get attribute value by tag from a list of attributes ;; Function to get attribute value by tag from a list of attributes
(defun getAttVal (attList tag) (defun getAttVal (attList tag)
(setq tag (strcase tag)) (setq tag (strcase tag))
@ -160,7 +160,7 @@
;; Function to process each block type ;; Function to process each block type
(defun process-block-type (blkName maxDesca) (defun process-block-type (blkName maxDesca)
(setq filter (list (cons 0 "INSERT") (cons 2 blkName))) (setq filter (list (cons 0 "INSERT") (cons 2 blkName)))
(setq sioLikeBlocks '("PLCIO_ARMORBLOCK_SIO" "PLCIO_ARMBLOCK_FIOM" "PLCIO_ARMORBLOCK_FIOH")) (setq sioLikeBlocks '("PLCIO_ARMORBLOCK_SIO" "PLCIO_ARMORBLOCK_FIOM" "PLCIO_ARMORBLOCK_FIOH"))
(setq mirrorThreshold (if (member blkName sioLikeBlocks) 9 7)) (setq mirrorThreshold (if (member blkName sioLikeBlocks) 9 7))
(setq ss (ssget "X" filter)) (setq ss (ssget "X" filter))
@ -207,18 +207,36 @@
(setq newPt1 (list xCordset y1 0.0)) (setq newPt1 (list xCordset y1 0.0))
;; NEW: Check if block is FIO or FIOH ;; NEW: Check if block is FIO or FIOH
(if (or (= blkName "PLCIO_ARMBLOCK_FIOM") (= blkName "PLCIO_ARMORBLOCK_FIOH")) (if (or (= blkName "PLCIO_ARMORBLOCK_FIOM") (= blkName "PLCIO_ARMORBLOCK_FIOH"))
(progn (progn
(setq newPt1Adjusted ;; separate handling for FIOM vs FIOH
(if (>= tagNum mirrorThreshold) (cond
;; Right side ;; --- FIOM block placement ---
(list (- (car newPt1) 1.4571) (- (cadr newPt1) 0.6375) (caddr newPt1)) ((= blkName "PLCIO_ARMORBLOCK_FIOM")
;; Left side (setq newPt1Adjusted
(list (+ (car newPt1) 0.7) (- (cadr newPt1) 0.6375) (caddr newPt1)) (if (>= tagNum mirrorThreshold)
;; Right side (FIOM)
(list (- (car newPt1) 2.4571) (+ (- (cadr newPt1) 0.6375) 0.25) (caddr newPt1))
;; Left side (FIOM)
(list (+ (car newPt1) 0.9) (+ (- (cadr newPt1) 0.6375) 0.1) (caddr newPt1))
)
)
)
;; --- FIOH block placement ---
((= blkName "PLCIO_ARMORBLOCK_FIOH")
(setq newPt1Adjusted
(if (>= tagNum mirrorThreshold)
;; Right side (FIOH)
(list (- (car newPt1) 1.4571) (- (cadr newPt1) 0.6375) (caddr newPt1))
;; Left side (FIOH)
(list (+ (car newPt1) 0.7) (- (cadr newPt1) 0.6375) (caddr newPt1))
)
)
) )
) )
;; Additional shift if TAG7 or TAG8 ;; --- Additional shift for tag 7 and 8 (applies to both) ---
(if (or (= tagNum 7) (= tagNum 8)) (if (or (= tagNum 7) (= tagNum 8))
(setq newPt1Adjusted (setq newPt1Adjusted
(list (list
@ -229,25 +247,115 @@
) )
) )
(command "_-INSERT" "HC01_CORDSET_STR-STR_STRAIGHT" newPt1Adjusted 1 1 0) ;; === NEW: check if these should produce SPLITTER + TWO CABLES ===
(setq newBlock1 (vlax-ename->vla-object (entlast))) (if (and val1 val2
(setq tagnumStr (substr (car pair) 6)) (or
(setq tagnum (atoi tagnumStr)) ;; --- TPE paired devices ---
(setq taga1 (and (vl-string-search "TPE" val1)
(if (= blkName "PLCIO_ARMORBLOCK_FIOH") (vl-string-search "TPE" val2)
(progn (/= val1 val2)) ; different names (e.g., TPE2 vs TPE3)
(setq evenNum (if (= (rem tagnum 2) 0) tagnum (+ tagnum 1)))
(setq evenTagStr (if (< evenNum 10) (strcat "0" (itoa evenNum)) (itoa evenNum))) ;; --- Receiver / Sender pairs ---
;; Remove last two chars from TAGA value (and (vl-string-search "RCV" val1)
(setq val (getAttVal attList (strcat "TAGA" evenTagStr))) (vl-string-search "SND" val2))
(substr val 1 (- (strlen val) 2)) (and (vl-string-search "SND" val1)
(vl-string-search "RCV" val2))
)
) )
(getAttVal attList (strcat "TAGA" tagnumStr)) (progn
;; === INSERT TWO CORDS + SPLITTER ===
(setq y2 (+ (cadr pt2) 0.1))
(setq newPt2 (list (car newPt1Adjusted) y2 0.0))
;; 1) First straight
(command "_-INSERT" "HC01_CORDSET_STR-STR_STRAIGHT" newPt1Adjusted 1 1 0)
(setq newBlock1 (vlax-ename->vla-object (entlast)))
(setBlockAttr newBlock1 "TAG1" (getAttVal attList (strcat "TAGA" (substr (car pair) 6))))
;; 2) Second straight
(command "_-INSERT" "HC01_CORDSET_STR-STR_STRAIGHT" newPt2 1 1 0)
(setq newBlock2 (vlax-ename->vla-object (entlast)))
(setBlockAttr newBlock2 "TAG1" (getAttVal attList (strcat "TAGA" (substr (cadr pair) 6))))
;; 3) Splitter between them
(setq x3 (+ (car newPt1Adjusted) (if (< tagNum mirrorThreshold) 1.25 -1.25)))
(setq y3 (/ (+ (cadr newPt1Adjusted) y2) 2.0))
(setq newPt3 (list x3 y3 0.0))
(if (< tagNum mirrorThreshold)
(progn
(command "_-INSERT" "HC01_SPLITTER" newPt3 1 1 0)
(setq splitterEnt (vlax-ename->vla-object (entlast))) ; capture splitter
)
(progn
(command "_-INSERT" "HC01_SPLITTER(RIGHT)" newPt3 1 1 0)
(setq splitterEnt (vlax-ename->vla-object (entlast))) ; capture splitter
(setq newPos (list (- x3 2.2) (+ y3 0.0) 0.0))
(vla-move splitterEnt (vlax-3d-point newPt3) (vlax-3d-point newPos))
)
)
;; === SHIFT WHOLE GROUP UP AND LEFT (after inserting two cords + splitter) ===
(setq moveX -0.5) ; left shift
(setq moveY 0.5) ; upward shift
(vla-move newBlock1 (vlax-3d-point newPt1Adjusted)
(vlax-3d-point (+ (car newPt1Adjusted) moveX)
(+ (cadr newPt1Adjusted) moveY)
(caddr newPt1Adjusted)))
(vla-move newBlock2 (vlax-3d-point newPt2)
(vlax-3d-point (+ (car newPt2) moveX)
(- (cadr newPt2) 0.1)
(caddr newPt2)))
;; Ensure splitterEnt exists for both sides
(if (not splitterEnt)
(setq splitterEnt (vlax-ename->vla-object (entlast)))
)
;; Move splitter
(if splitterEnt
(vla-move splitterEnt
(vlax-3d-point newPt3)
(vlax-3d-point (+ (car newPt3) moveX)
(+ (- (cadr newPt3) 0.3) moveY)
(caddr newPt3)))
)
)
(progn
;; === DEFAULT: single straight (same as before) ===
(command "_-INSERT" "HC01_CORDSET_STR-STR_STRAIGHT" newPt1Adjusted 1 1 0)
(setq newBlock1 (vlax-ename->vla-object (entlast)))
(setq tagnumStr (substr (car pair) 6))
(setq tagnum (atoi tagnumStr))
(setq taga1
(cond
;; --- FIOH: even number logic + trim last 2 chars ---
((= blkName "PLCIO_ARMORBLOCK_FIOH")
(setq evenNum (if (= (rem tagnum 2) 0) tagnum (+ tagnum 1)))
(setq evenTagStr (if (< evenNum 10) (strcat "0" (itoa evenNum)) (itoa evenNum)))
(setq val (getAttVal attList (strcat "TAGA" evenTagStr)))
(substr val 1 (- (strlen val) 2))
)
;; --- FIOM: simple value + trim last 2 chars (remove _0 etc.) ---
((= blkName "PLCIO_ARMORBLOCK_FIOM")
(setq val (getAttVal attList (strcat "TAGA" tagnumStr)))
(substr val 1 (- (strlen val) 2))
)
;; --- Default for other blocks ---
(T (getAttVal attList (strcat "TAGA" tagnumStr)))
)
)
(setBlockAttr newBlock1 "TAG1" taga1)
) )
) )
(setBlockAttr newBlock1 "TAG1" taga1)
) )
(progn (progn
;; EXISTING CODE for all other blocks ;; EXISTING CODE for all other blocks
(if (and val1 val2 (if (and val1 val2
@ -288,7 +396,7 @@
;; Right side: move left 1 unit ;; Right side: move left 1 unit
(progn (progn
(setq basePt (vlax-get finalBlock 'InsertionPoint)) (setq basePt (vlax-get finalBlock 'InsertionPoint))
(setq targetPt (list (- (car basePt) 0.5) (cadr basePt) (caddr basePt))) (setq targetPt (list (- (car basePt) 0.0) (cadr basePt) (caddr basePt)))
(vla-move finalBlock (vlax-3d-point basePt) (vlax-3d-point targetPt)) (vla-move finalBlock (vlax-3d-point basePt) (vlax-3d-point targetPt))
) )
;; Left side: move right 0.5 unit ;; Left side: move right 0.5 unit
@ -463,15 +571,17 @@
(setq taga (setq taga
(if (= blkName "PLCIO_ARMORBLOCK_FIOH") (if (= blkName "PLCIO_ARMORBLOCK_FIOH")
(progn (progn
(setq evenNum (if (= (rem tagnum 2) 0) tagnum (+ tagnum 1))) ;; Make sure tag number is always odd
(setq evenTagStr (if (< evenNum 10) (strcat "0" (itoa evenNum)) (itoa evenNum))) (setq oddNum (if (/= (rem tagnum 2) 0) tagnum (+ tagnum 1)))
(getAttVal attList (strcat "TAGA" evenTagStr)) (setq oddTagStr (if (< oddNum 10) (strcat "0" (itoa oddNum)) (itoa oddNum)))
(getAttVal attList (strcat "TAGA" oddTagStr))
) )
(getAttVal attList (strcat "TAGA" tagnumStr)) (getAttVal attList (strcat "TAGA" tagnumStr))
) )
) )
(setBlockAttr newBlock "TAG1" taga) (setBlockAttr newBlock "TAG1" taga)
;; For non-special single blocks, move attribute ;; For non-special single blocks, move attribute
(if (not (and (= blkName "PLCIO_ARMORPOWERFLEX") (= tagNum 11))) (if (not (and (= blkName "PLCIO_ARMORPOWERFLEX") (= tagNum 11)))
(moveTag1UpLeft newBlock) (moveTag1UpLeft newBlock)
@ -490,14 +600,18 @@
;; === NEW: Move single straight block left/right depending on side === ;; === NEW: Move single straight block left/right depending on side ===
(if (or (and (= blkName "PLCIO_ARMORPOWERFLEX") (>= tagnum 7)) (if (or (and (= blkName "PLCIO_ARMORPOWERFLEX") (>= tagnum 7))
(and (member blkName sioLikeBlocks) (>= tagnum 8) (= tagnum 15))) (and (member blkName sioLikeBlocks)
;; Right side: move left 1 unit (only for last DESCA in SIO-like blocks) (not (= blkName "PLCIO_ARMORBLOCK_FIOM")) ; exclude FIOM
(>= tagnum 8)
(= tagnum 15)))
;; Right side: move left 1 unit (only for last DESCA in SIO-like blocks, excluding FIOM)
(progn (progn
(setq basePt (vlax-get newBlock 'InsertionPoint)) (setq basePt (vlax-get newBlock 'InsertionPoint))
(setq targetPt (list (+ (car basePt) 0.5) (cadr basePt) (caddr basePt))) (setq targetPt (list (+ (car basePt) 0.5) (cadr basePt) (caddr basePt)))
(vla-move newBlock (vlax-3d-point basePt) (vlax-3d-point targetPt)) (vla-move newBlock (vlax-3d-point basePt) (vlax-3d-point targetPt))
) )
) )
;; === NEW: Move SIO-like single blocks on left side to the left === ;; === NEW: Move SIO-like single blocks on left side to the left ===
(if (and (member blkName sioLikeBlocks) (< tagnum 8)) (if (and (member blkName sioLikeBlocks) (< tagnum 8))
@ -508,6 +622,16 @@
(vla-move newBlock (vlax-3d-point basePt) (vlax-3d-point targetPt)) (vla-move newBlock (vlax-3d-point basePt) (vlax-3d-point targetPt))
) )
) )
;; === NEW: Final vertical adjustment for FIOM single blocks ===
(if (= blkName "PLCIO_ARMORBLOCK_FIOM")
(progn
(setq basePt (vlax-get newBlock 'InsertionPoint))
(setq targetPt (list (car basePt) (+ (cadr basePt) 0.2) (caddr basePt)))
(vla-move newBlock (vlax-3d-point basePt) (vlax-3d-point targetPt))
)
)
;; === END NEW === ;; === END NEW ===
(setvar "ATTDIA" oldAttdia) (setvar "ATTDIA" oldAttdia)
@ -555,12 +679,13 @@
(delete-existing-devlay-blocks) (delete-existing-devlay-blocks)
(process-block-type "PLCIO_ARMORPOWERFLEX" 11) (process-block-type "PLCIO_ARMORPOWERFLEX" 11)
(process-block-type "PLCIO_ARMORBLOCK_SIO" 16) (process-block-type "PLCIO_ARMORBLOCK_SIO" 16)
(process-block-type "PLCIO_ARMBLOCK_FIOM" 16) (process-block-type "PLCIO_ARMORBLOCK_FIOM" 16)
(process-block-type "PLCIO_ARMORBLOCK_FIOH" 16) (process-block-type "PLCIO_ARMORBLOCK_FIOH" 16)
(princ) (princ)
) )
;;; devlay_update section ends here ;; devlay_update section ends here
;;; ----------------------- ;;; -----------------------
;;; Utilities ;;; Utilities
@ -715,6 +840,7 @@
) )
) )
;;; ----------------------- ;;; -----------------------
;;; Device placement — sequential TAGNAME grouping approach ;;; Device placement — sequential TAGNAME grouping approach
;;; layoutDevices not precomputed: we use csvRows + csvIndex and group rows by TAGNAME ;;; layoutDevices not precomputed: we use csvRows + csvIndex and group rows by TAGNAME
@ -731,31 +857,61 @@
((vl-string-search "APF" devUpper) "PLCIO_ARMORPOWERFLEX") ((vl-string-search "APF" devUpper) "PLCIO_ARMORPOWERFLEX")
((vl-string-search "SIO" devUpper) "PLCIO_ARMORBLOCK_SIO") ((vl-string-search "SIO" devUpper) "PLCIO_ARMORBLOCK_SIO")
((vl-string-search "FIOH" devUpper) "PLCIO_ARMORBLOCK_FIOH") ((vl-string-search "FIOH" devUpper) "PLCIO_ARMORBLOCK_FIOH")
((vl-string-search "FIO" devUpper) "PLCIO_ARMBLOCK_FIOM") ((vl-string-search "FIO" devUpper) "PLCIO_ARMORBLOCK_FIOM")
(T nil) (T nil)
) )
) )
;; positions arrays
;; --- Base position templates ---
(setq positions (list (setq positions (list
(list 9.63 9.5 0.0) (list 9.63 9.5 0.0)
(list 9.63 -1.5 0.0) (list 9.63 -1.5 0.0)
(list 28.88 9.5 0.0) (list 28.88 9.5 0.0)
(list 28.88 -1.5 0.0))) (list 28.88 -1.5 0.0)))
(setq positionsB (list
(list 9.6 9.5 0.0)
(list 9.6 -1.5 0.0)
(list 28.9666 9.5 0.0)
(list 28.9666 -1.5 0.0)))
;; FIOH positions (Hub old spacing)
(setq positionsFIOH (list
(list 9.6 9.5 0.0)
(list 9.6 -1.5 0.0)
(list 28.9666 9.5 0.0)
(list 28.9666 -1.5 0.0)))
;; FIO positions (new, slightly taller/wider)
(setq positionsFIO (list
(list 9.6 9.85 0.0)
(list 9.6 -1.15 0.0)
(list 28.9666 9.85 0.0)
(list 28.9666 -1.15 0.0)))
;; --- Determine which set of positions to use ---
(cond
((vl-string-search "FIOH" devUpper)
(setq pos (mapcar '+ (nth posIndex positionsFIOH) (list layoutStartX 0 0))))
((vl-string-search "FIO" devUpper)
(setq pos (mapcar '+ (nth posIndex positionsFIO) (list layoutStartX 0 0))))
(T
(setq pos (mapcar '+ (nth posIndex positions) (list layoutStartX 0 0))))
)
;; --- Insert and populate ---
(if blk (if blk
(progn (progn
;; compute insertion pos using posIndex and layoutStartX
(setq pos (if (or (vl-string-search "FIOH" devUpper) (vl-string-search "FIO" devUpper))
(mapcar '+ (nth posIndex positionsB) (list layoutStartX 0 0))
(mapcar '+ (nth posIndex positions) (list layoutStartX 0 0))))
;; insert and fill
(insertBlockAt blk '(0 0 0) pos) (insertBlockAt blk '(0 0 0) pos)
;; --- FIOM-specific 20_zone adjustment (left & right) ---
(if (and blk (vl-string-search "FIOM" (strcase deviceTag)))
(progn
(cond
((member posIndex '(0 1)) ; left side
(adjust20ZoneForFIOM *curr-left-zone* posIndex)
(setq *fiom-left-pos* posIndex))
((member posIndex '(2 3)) ; right side
(adjust20ZoneForFIOM *curr-right-zone* posIndex)
(setq *fiom-right-pos* posIndex))
)
)
)
(setq ent (entlast)) (setq ent (entlast))
(if ent (if ent
(progn (progn
@ -771,52 +927,137 @@
) )
;;; ----------------------- ;;; -----------------------
;;; 20_zone helpers (unchanged logic) ;;; 20_zone helpers
;;; ----------------------- ;;; -----------------------
(defun labelBlockLines (block startNum)
(setq counter 0) (defun fmt2 (n)
(foreach att (vlax-invoke block 'GetAttributes) (if (< n 10)
(setq tag (strcase (vla-get-tagstring att))) (strcat "0" (itoa n))
(if (wcmatch tag "LINE*") (itoa n))
(progn )
(setq labelNum (+ startNum counter))
(setq labelStr (if (< labelNum 10) (strcat "0" (itoa labelNum)) (itoa labelNum))) (defun to-int (x)
(setq basePt (vlax-get att 'InsertionPoint)) (if (numberp x) x (atoi x))
(setq blockPos (vlax-get block 'InsertionPoint)) )
(setq labelPt (list (+ (car blockPos) 0.12) (- (cadr basePt) 0.053) (caddr basePt)))
(entmakex (list (cons 0 "TEXT") (cons 8 "0") (cons 7 "WD") (cons 62 7) (defun update20ZoneBlockAttributes (blockEnt layoutIndex startValue suffixBase sideOffset
(cons 10 labelPt) (cons 11 labelPt) (cons 40 0.13) (cons 72 1) / blockObj attrList sortedList attrPair idx intBase intPart suffixPart newText)
(cons 73 1) (cons 1 labelStr) (cons 50 0.0))) "Update LINE## attributes with values like 2600.01 ... 2600.40.
(setq counter (1+ counter)) Fixes unordered attribute iteration by sorting numerically first."
) (setq blockObj (vlax-ename->vla-object blockEnt))
) (setq attrList (vlax-invoke blockObj 'GetAttributes))
;; integer part (constant for all lines in block)
(setq intBase (to-int startValue))
(setq intPart (+ intBase (to-int layoutIndex) (to-int sideOffset)))
;; sort attributes by numeric LINE## suffix
(setq sortedList
(vl-sort
(mapcar
'(lambda (a)
(list (atoi (substr (vla-get-tagstring a) 5)) a))
attrList)
'(lambda (x y) (< (car x) (car y))))
)
;; now loop in correct order
(setq idx 0)
(foreach attrPair sortedList
(setq idx (1+ idx))
(setq attr (cadr attrPair))
(setq suffixPart (fmt2 (+ suffixBase (1- idx))))
(setq newText (strcat (itoa intPart) "." suffixPart))
(vla-put-textstring attr newText)
(vlax-invoke attr 'Update)
)
(vlax-invoke blockObj 'Update)
)
;;; -----------------------
;;; FIOM-specific adjustments for 20_zone
;;; -----------------------
;; vertical Y-offsets for 8 lines in FIOM layouts
(setq *FIOM-YOFFSETS*
'(
(1 . 0.26)
(2 . 0.78)
(3 . 1.16)
(4 . 1.64)
(5 . 1.89)
(6 . 2.40)
(7 . 2.79)
(8 . 3.28)
) )
) )
(defun update20ZoneBlockAttributes (blockEnt layoutIndex startValue sideOffset / blockObj attrList attr attrName idx newValue formattedValue) (defun fiom-yoffset (relIndex / hit)
(setq blockObj (vlax-ename->vla-object blockEnt)) (setq hit (assoc relIndex *FIOM-YOFFSETS*))
(setq attrList (vlax-invoke blockObj 'GetAttributes)) (if hit (cdr hit) 0.0)
(foreach attr attrList )
(setq attrName (vlax-get-property attr 'TagString))
(if (and (>= (strlen attrName) 5) (defun adjust20ZoneForFIOM (zoneEnt posIndex / blockObj attList idx relIdx lineIndices a pt yoff newPt)
(= (substr attrName 1 4) "LINE") "Shift the correct 8 attributes of 20_zone block when FIOM exists (top/bottom, left/right),
(>= (atoi (substr attrName 5)) 1) and set justification to Middle Left for those lines only."
(<= (atoi (substr attrName 5)) 20)) (if (null zoneEnt)
(progn (princ "\n[FIOM] zone block not found.")
(setq idx (atoi (substr attrName 5))) (progn
(setq newValue (+ (atoi startValue) layoutIndex (- idx 1) sideOffset)) ;; which 8 attributes to move based on FIOM position
(setq formattedValue (strcat (itoa newValue) ".")) (setq lineIndices
(vlax-put-property attr 'TextString formattedValue) (cond
(vlax-invoke attr 'Update) ((= posIndex 0) '(1 2 3 4 5 6 7 8)) ; top-left
((= posIndex 1) '(12 13 14 15 16 17 18 19)) ; bottom-left
((= posIndex 2) '(1 2 3 4 5 6 7 8)) ; top-right
((= posIndex 3) '(12 13 14 15 16 17 18 19)) ; bottom-right
(T nil)
)
)
(if lineIndices
(progn
(setq blockObj (vlax-ename->vla-object zoneEnt))
(setq attList (vlax-invoke blockObj 'GetAttributes))
(setq idx 1)
(foreach a attList
(if (member idx lineIndices)
(progn
(setq relIdx (1+ (vl-position idx lineIndices))) ; 1..8
(setq pt (vlax-get a 'InsertionPoint))
(setq yoff (fiom-yoffset relIdx))
;; set justification to Middle Left (9) BEFORE changing position
(if (vlax-property-available-p a 'Alignment)
(vlax-put a 'Alignment 9)) ; 9 = acAlignmentMiddleLeft
;; move only vertically
(setq newPt (list (car pt) (+ (cadr pt) yoff) (caddr pt)))
;; For Middle Left, use TextAlignmentPoint
(if (vlax-property-available-p a 'TextAlignmentPoint)
(vlax-put a 'TextAlignmentPoint newPt))
;; update attribute
(vlax-invoke a 'Update)
)
)
(setq idx (1+ idx))
)
(vlax-invoke blockObj 'Update)
)
) )
) )
) )
(vlax-invoke blockObj 'Update)
) )
;;; ----------------------- ;;; -----------------------
;;; MAIN FUNCTION ;;; MAIN FUNCTION
;;; ----------------------- ;;; -----------------------
(setq *curr-left-zone* nil)
(setq *curr-right-zone* nil)
(setq *fiom-left-pos* nil) ; stores posIndex when FIOM placed on left
(setq *fiom-right-pos* nil) ; stores posIndex when FIOM placed on right
(defun c:init_layout ( / csvFile csvRows file line cols headerSkipped csvIndex totalRows layoutNum layoutStartX posIndex blocksLeft numBlocksInLayout layoutDevices firstTag currentTag blockRows) (defun c:init_layout ( / csvFile csvRows file line cols headerSkipped csvIndex totalRows layoutNum layoutStartX posIndex blocksLeft numBlocksInLayout layoutDevices firstTag currentTag blockRows)
(disable-snap-states) (disable-snap-states)
@ -861,6 +1102,10 @@
(if (= posIndex 0) (if (= posIndex 0)
(progn (progn
(setq layoutStartX (* layoutNum offsetX)) (setq layoutStartX (* layoutNum offsetX))
;; Reset FIOM tracking for new layout
(setq *fiom-left-pos* nil)
(setq *fiom-right-pos* nil)
;; draw outer box and lines (same as before) ;; draw outer box and lines (same as before)
(command "_.PLINE" (list (+ 0 layoutStartX) -11.0)) (command "_.PLINE" (list (+ 0 layoutStartX) -11.0))
(command (list (+ 38.5 layoutStartX) -11.0)) (command (list (+ 38.5 layoutStartX) -11.0))
@ -877,19 +1122,22 @@
(setq ptRight (list (+ 20.0 layoutStartX) 9.5 0)) (setq ptRight (list (+ 20.0 layoutStartX) 9.5 0))
(setq leftEnt (insertBlockAt "20_zone" basePt ptLeft)) (setq leftEnt (insertBlockAt "20_zone" basePt ptLeft))
(setq *curr-left-zone* leftEnt)
(setq *curr-right-zone* nil) ; initialize right zone tracker
(if leftEnt (if leftEnt
(progn (progn
(setq leftBlock (vlax-ename->vla-object leftEnt)) (setq leftBlock (vlax-ename->vla-object leftEnt))
(update20ZoneBlockAttributes leftEnt layoutNum startIndex 0) (update20ZoneBlockAttributes leftEnt layoutNum startIndex 1 0)
(labelBlockLines leftBlock 1) ; (labelBlockLines leftBlock 1 nil) ; ADD nil parameter
) )
) )
(setq rightEnt (insertBlockAt "20_zone" basePt ptRight)) (setq rightEnt (insertBlockAt "20_zone" basePt ptRight))
(setq *curr-right-zone* rightEnt) ; store right zone
(if rightEnt (if rightEnt
(progn (progn
(setq rightBlock (vlax-ename->vla-object rightEnt)) (setq rightBlock (vlax-ename->vla-object rightEnt))
(update20ZoneBlockAttributes rightEnt layoutNum startIndex 0) (update20ZoneBlockAttributes rightEnt layoutNum startIndex 21 0)
(labelBlockLines rightBlock 21) ; (labelBlockLines rightBlock 21 nil) ; ADD nil parameter
) )
) )
;; layout label ;; layout label

View File

@ -380,6 +380,9 @@
) )
) )
;; layout label
(setq labelPt (list (+ desiredX 14.0) 32.0 0.0))
(command "_.text" labelPt 1.5 0 (strcat "Layout " (itoa (1+ i))))
(place-enet-devices x y deviceGroup) (place-enet-devices x y deviceGroup)
(setq i (1+ i)) (setq i (1+ i))
) )