Jump to content

Recommended Posts

Posted

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

Posted
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

Posted

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

Posted (edited)

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
Posted

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))))

Posted

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

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...