Jump to content

simple Lisp to copy text ("TEXT" "MTEXT" "ATTRIB") and paste it to another attribute like TTC.lsp or CTX


Recommended Posts

Posted

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

Posted

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

 

 

Posted (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 by pkenewell
Posted

wow, thanks pkenewell, that was fast

will try it now...

Posted

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! 

  • Like 1
Posted
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.

Posted

yes, you are right, already deleted this again

thanks again

  • Like 1
Posted
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
    ...

 

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