Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear All,
Happy New Year to you!
I am working on a Lisp which can select the alternate text regardless of its coordinate.
The use has to input the axiz of the selection and then select the text in that axis.
The code should select only the alternate text regardless of the y axis.
Below is the code:
(Kindly guide me to make it a working one.)
(defun c:SelAltText (/ ss count index selected)
(prompt "\nSelect text entities to process: ")
;; Prompt user to select text entities
(setq ss (ssget '((0 . "TEXT,MTEXT")))) ; Filter for TEXT and MTEXT objects
(if ss
(progn
;; Initialize variables
(setq count (sslength ss)) ; Total number of selected entities
(setq index 0) ; Start index
(setq selected (ssadd)) ; Create an empty selection set
;; Loop through the selection and pick alternate entities
(while (< index count)
(if (= 0 (rem index 2)) ; Select even-indexed entities
(ssadd (ssname ss index) selected))
(setq index (1+ index))) ; Move to the next index
;; Highlight the selected entities
(if (> (sslength selected) 0)
(progn
(sssetfirst nil selected) ; Highlight alternate entities
(prompt (strcat "\nSelected " (itoa (sslength selected)) " alternate text entities.")))
(prompt "\nNo alternate text entities found."))
)
(prompt "\nNo text entities selected."))
(princ)) ; Exit cleanly
Solved! Go to Solution.