extrawurscht Posted Thursday at 04:26 PM Posted Thursday at 04:26 PM Hi there, I'm looking for a simple Lisp to copy text ("TEXT" "MTEXT" "ATTRIB") and paste it to another attribute. I know that there are some, which works perfect for me: I'm using the Lisp TTC.lsp from ASMI! Awsome with the Multiple and Pair-wise Mode The only thing I have is, that if I miss the attribute or text, the lisp ends. For pick text and paste text. I tried to modify with e.g. a while T which only works for me for the Multiple Mode, and only for paste. ;-------------------------------------------------------------------------- (while T ;-------------------------------------------------------------------------- (while(setq conFlag(TTC_Paste paseStr))T ); end while ;-------------------------------------------------------------------------- );End while T ;-------------------------------------------------------------------------- There is also a possibility with errNo 7 like used in Mac Lee's CTX (= 7 (getvar 'errno)) (princ "\nMissed, try again.") Is there anyone who can help out with this and can modify this? Many Thanks and BR TTC.lsp Quote
extrawurscht Posted Thursday at 04:34 PM Author Posted Thursday at 04:34 PM for pick text I found something like this, but have absolutley no glue to implement: (defun _entsel (msg / p r) (setvar "ErrNo" 0) (while (not (cond ((and (null (setq p (entsel (strcat "\n" msg)))) (/= 52 (getvar 'errno))) (prompt "\nPick missed, try again...") ) ((null p) t) ((setq r p)) ) ) ) r ) ;; (_entsel "Pick something: ") (if (setq vbobj (car (_entsel "\nPick Something: "))) (setq vbobj (vlax-ename->vla-object vbobj)) ) Quote
pkenewell Posted Thursday at 05:00 PM Posted Thursday at 05:00 PM (edited) The trick is to replace the NENTSEL function with this: ;|============================================================================== Function Name: (pjk-Nentsel) Arguments: pr = string; a select prompt for the command line. Usage: (pjk-Nentsel <Prompt>) Returns: Returns a list containing the Entity name and the point selected in the same manner as (nentsel). Returns nil if no object is selected and Enter / Escape is initiated. Description: This routine is a wrapper for the (nentsel) function to capture a missed pick with the cursor and continue prompting for a point until a return is initiated. Improves the inherent problem using (initget) with (nentsel), forcing a pick or an escape. ================================================================================|; (defun pjk-Nentsel (pr / ent) (setvar "errno" 0) (while (and (not (setq ent (nentsel pr)))(= (getvar "errno") 7)) (princ "\nNo Object Selected. Try Again...\n") ) ent ) ;; End Function (pjk-Nentsel) See the updated attached file. Haven't had time to test it, but should do what you want. TTC.lsp Edited Thursday at 05:02 PM by pkenewell Quote
extrawurscht Posted Thursday at 05:44 PM Author Posted Thursday at 05:44 PM wow, thanks pkenewell, that was fast will try it now... Quote
extrawurscht Posted Thursday at 06:20 PM Author Posted Thursday at 06:20 PM It's working quite well! I only had to exchange of course as well for the copy text part in the code. I also added the "while T" for the Multiple like mentioned in the first post. Thanks a lot for your help! 1 Quote
pkenewell Posted Thursday at 07:08 PM Posted Thursday at 07:08 PM 31 minutes ago, extrawurscht said: It's working quite well! I only had to exchange of course as well for the copy text part in the code. I also added the "while T" for the Multiple like mentioned in the first post. Thanks a lot for your help! @extrawurscht I don't think you need that "While T" loop! That makes you have to force the function to error out, try just adding: (while (setq conFlag (TTC_Paste paseStr))) It should stop the loop when there is no value for "conflag"; (TTC_paste) will return nil if you just press ENTER. Quote
extrawurscht Posted Thursday at 07:27 PM Author Posted Thursday at 07:27 PM yes, you are right, already deleted this again thanks again 1 Quote
pkenewell Posted Thursday at 08:32 PM Posted Thursday at 08:32 PM 1 hour ago, extrawurscht said: yes, you are right, already deleted this again thanks again @extrawurscht FYI - There is also another "nentsel" in the (TTC_copy) sub-function. I recommend you change to "pjk-nentsel" in that location as well. (defun TTC_Copy (/ sObj sText tType actDoc) (if (and (setq sObj (car (pjk-Nentsel "\nCopy text... "))) ;<-- Here ... Quote
Recommended Posts
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.