Jump to content
Reu

Problem with code to select a single piece of text using ssget.

Recommended Posts

Reu

What is wrong with my coding?

 

(defun 1ststring ()
 (if
   (while (= str nil)
     (setq ss	(ssget ":S" '((0 . "TEXT")))
    str
	(cdr (assoc 1 entget ss))
     ) ;_end setq
     (setq str nil)
   ) ;_end while
 ) ;_end if
) ;_end defun

Share this post


Link to post
Share on other sites
Reu
What is wrong with my coding?

 

(defun 1ststring ()
 (if
   (while (= str nil)
     (setq ss	(ssget ":S" '((0 . "TEXT")))
    str
	(cdr (assoc 1 entget ss))
     ) ;_end setq
     (setq str nil)
   ) ;_end while
 ) ;_end if
) ;_end defun

 

 

Nevermind

 

(defun 1ststring ()
 (setq	ss  (ssget ":S" '((0 . "TEXT")))
str (cdr (assoc 1 entget ss))
 ) ;_end setq
) ;_end defun

 

Sincerely,

Mr. Overcomplicated

Share this post


Link to post
Share on other sites
Reu

On another note I am interested to learn a little about writing a 'while' expression in an 'if' statement.

Share this post


Link to post
Share on other sites
Reu

Nevermind

 

;;; Function (1ststring)
;;; Description: Get the string from the first text object to be edited. ;
(defun 1ststring (/ ss str)
 (setq	ss  (ssget "_:S" '((0 . "TEXT"))) ; Select the text to be edited.
str (cdr (assoc 1 (entget (ssname ss 0)))) ; Get the text string from the selected text.
 ) ;_end setq
) ;_end defun

 

Sincerely,

Mr. Overcomplicated

Edited by Reu

Share this post


Link to post
Share on other sites
BIGAL

If your only picking 1 text maybe use entsel only disadvantage is it will not check if its text. Basicly code is same

 

 (setq ent (car (entsel "\nSelect Text: "))) 
(setq str (cdr (assoc 1 (entget ent))))

Share this post


Link to post
Share on other sites
Reu

Thanks BIGAL, that disadvantage is precisely why I didn't use it :)

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...