rsaei Posted January 7, 2009 Posted January 7, 2009 I was wondering if anyone knows of a lisp routine for copying text and then editing the text. Quote
ReMark Posted January 7, 2009 Posted January 7, 2009 Could you cite an example of how this might be useful? I'm not trying to be funny or anything but can't this be accomplished in a couple of different ways already? Quote
Lee Mac Posted January 7, 2009 Posted January 7, 2009 Not sure why you would need it necessarily, but here goes: (defun c:cpyed (/ *error* ent elist) (defun *error* (msg) (setvar "cmdecho" 1) (if (= msg "") (princ "\nFunction Complete.") (princ (strcat "\n" (strcase msg))) ) ;_ end if (princ) ) ;_ end defun (setvar "cmdecho" 0) (while (not ent) (setq ent (car (entsel "\nSelect Text: "))) ) ;_ end while (setq elist (entget ent)) (if (or (= "TEXT" (cdr (assoc 0 elist))) (= "MTEXT" (cdr (assoc 0 elist))) ) ;_ end or (progn (command "_copy" ent "" (cdr (assoc 10 elist)) pause) (command "_ddedit" (entlast)) (while (> (getvar "cmdactive") 0) (command pause)) ) ;_ end progn (alert "\nSelected Item is not Text!") ) ;_ end if (*error* "") (princ) ) ;_ end defun Quote
rsaei Posted January 7, 2009 Author Posted January 7, 2009 Thank you, I'm just experimenting. I have a lot of elevations that I'm copying and editing to As-Built conditions. Quote
Lee Mac Posted January 7, 2009 Posted January 7, 2009 Only slight glitch with the LISP is that after the text is edited, one has to exit the "ddedit" command manually, I could probably work around this, but I need more time. Quote
jammie Posted January 7, 2009 Posted January 7, 2009 Hi rsaei, Welcome to the forum! Heres one that works similar to Lee's, just coded differently ;Description : Copy text and edit it ;Written by : Jammie ;Posted : Cadtutor.net ;Thread : http://www.cadtutor.net/forum/showthread.php?t=31082 ;Date : 20:05 07/01/2009 ;Version : 0.0 (defun c:ct (/ loop input ename elist ) ;;A loop test expression (setq loop t) ;;Repeat the function while the test is True (while loop ;;Allow the user to hit enter to end the command (initget " ") ;;Select an object (setq input (entsel "\nSelect text or mtext :")) (cond ;;1st test the expression ;;The user selected an object. If the user picked an object then Entsel will return a list ((= (type input) 'list) (progn (setq ename (car input);Retrieve the enity name elist (entget ename) ;Retrieve the enity list etype (cdr (assoc 0 elist));Retrieve the enity type ) ;;Test that the selected object is a text or mtext (if (wcmatch etype "*TEXT") ;If the selected object is a text or mtext (progn ;;Start Copy (command "._copy" ename "" pause pause) ;;Edit the newly created object (command "._ddedit" (entlast) "") ;_ end of command ) ;If the selected object is not a text or mtext, promt the user with the selected object type (princ (strcat "\nSelected object is a(n) <" etype "> :")) ) ) ) ;;2nd test the expression ;;The user hits retun and wishes to end the command. Entsel returns "" ((= input "") ;;Set the loop to nil to end the command (setq loop nil)) ) ;_ end of cond ) (Princ "\nFunction ended...") (princ) ) (Princ "\nEdit copied text loaded. \nType CT to start command, hit return to exit:..") (princ) Regards Jammie Quote
Lee Mac Posted January 7, 2009 Posted January 7, 2009 Another: (defun c:ct2 (/ ss) (while (or (not ss) (> (sslength ss) 1) ) ;_ end or (setq ss (ssget '((0 . "MTEXT,TEXT")))) ) ;_ end while (command "_copy" (ssname ss 0) "" pause pause) (command "_ddedit" (entlast) "") (princ) ) ;_ end defun Quote
ReMark Posted January 7, 2009 Posted January 7, 2009 Ask and ye shall receive. Somebody just got a late Christmas present. Quote
Lee Mac Posted January 7, 2009 Posted January 7, 2009 Ask and ye shall receive. Somebody just got a late Christmas present. I had fun with this one - just trying to simplfy it more and more Quote
ReMark Posted January 8, 2009 Posted January 8, 2009 Nice job Lee. What do you do for fun and relaxation...brain surgery? Quote
wizman Posted January 8, 2009 Posted January 8, 2009 here's what im using. copybase a text /block then run the routine. it will prompt for two points for rotation of text/block. if the copied object is text, editor will pop out, defaulting to previous input ;|*********************************************************************************** PROGRAM CREATED FOR PASTECLIP FOR BLOCKS AND TEXT WITH ROTATION DATE: OCTOBER 28, 2008 OFFICE: MOUCHEL INTERNATIONAL ABU-DHABI OFFICE CREATED BY: RONALD MANEJA (WIZMAN)...email_add: ron_09812001@yahoo.com **AUTO 'PREVIOUS' INPUT AND DDEDIT FOR TEXT OBJECTS * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |; (defun c:1q (/ angron ptrot1 ptrot2) (while (and (setq ptrot1 (getpoint "\n>>>...Specify first point...>>>: ")) (setq ptrot2 (getpoint ptrot1 "\n>>>...Specify second point...>>>: ")) (setq angron (angle ptrot1 ptrot2)) ) ;_ end_and (grvecs (list 1 ptrot1 ptrot2)) (command "_pasteclip" "r" (* (/ angron pi) 180) ptrot1) (if (or (= (cdr (assoc 0 (entget (entlast)))) "TEXT") (= (cdr (assoc 0 (entget (entlast)))) "MTEXT") ) ;_ end_or (progn (if 1q_value (entmod (subst (cons 1 1q_value) (assoc 1 (entget (entlast))) (entget (entlast)) ) ;_ end_subst ) ;_ end_subst ) ;_ end_entmod (command "_ddedit" (entlast) "") (setq 1q_value (cdr (assoc 1 (entget (entlast))))) ) ;_ end_progn ) ;_ end_if (princ) ) ;_ end_while ) ;_ end_defun (prompt "\n>>>...1q-Mega.lsp is now loaded, Type '1q' to run command...<<<" ) ;_ end_prompt (princ) Quote
Lee Mac Posted January 8, 2009 Posted January 8, 2009 Nice job Lee. What do you do for fun and relaxation...brain surgery? Haha, depends what day it is... LISP on weekdays, brain surgery at weekends. 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.