Tharwat Posted August 6, 2010 Posted August 6, 2010 No, use entmake. Text in command is the most temperamental function that can be called. That's right, Here it goes with enmake ...... (defun C:STX (/ elist en ss sum sumtxt txt ins) ;;created by Fixo ;;revised by Reid B. for sanalmakina (princ "\n\t\t>>> Select text to get summ >>>") (if ;;select texts/mtexts on screen : (setq ss (ssget '((0 . "*TEXT")))) ;; if selected then : (progn ;; set initial sum to zero : (setq sum 0.) ;; loop trough selected texts/mtexts : (while ;; get the first text in selection : (setq en (ssname ss 0)) ;; get entity list of them : (setq elist (entget en)) ;; get the textstring by key 1 from entity list : (setq txt (cdr (assoc 1 elist))) ;; create output string : (setq sumtxt ;; concatenate strings : (strcat ;; convert digits to string : (rtos ;; add to summ the digital value of text : (setq sum (+ (atof txt) sum)) ;; 2 is for metric units (3 for engineering) : 5;;revised by Reid B. ;; set precision by current : (getvar "dimdec"))" " "m3/h") ) ;; delete entity from selection set : (ssdel en ss) ) ;; Change to text : (setq ins (getpoint "\nSpecify text location: "));;start revision by Reid B. (entmake (list '(0 . "TEXT") (cons 40 (getvar 'textsize)) (cons 10 ins) (cons 1 sumtxt) ))) ) (princ) ) (princ "\nStart command with STX...") (princ) Quote
alanjt Posted August 6, 2010 Posted August 6, 2010 (cons 7 (getvar 'textstyle)) thank you Alan! I'll definitely use this one Actually, it was textsize I was thinking about. Entmake will use the current textstyle to create the text, you don't need it at all, unless you want a different style. Sorry about that. Quote
Lt Dan's legs Posted August 6, 2010 Posted August 6, 2010 Actually, it was textsize I was thinking about. this is something that is useful to me. So, is (cons 100 "AcDbEntity") and (cons 100 "AcDbText") needed? Quote
Tharwat Posted August 6, 2010 Posted August 6, 2010 YES. things like my previous reply. The problem is with the Text Style which is current , I mean put the Text height for it zero and try again. Quote
alanjt Posted August 6, 2010 Posted August 6, 2010 this is something that is useful to me. So' date=' is (cons 100 "AcDbEntity") and (cons 100 "AcDbText") needed?[/quote'] It varies with certain objects. Quote
Lt Dan's legs Posted August 6, 2010 Posted August 6, 2010 what about in this case? I wasn't sure if the version of acad played a factor Quote
sanalmakina Posted August 6, 2010 Posted August 6, 2010 That's right,Here it goes with enmake ...... (defun C:STX (/ elist en ss sum sumtxt txt ins) ;;created by Fixo ;;revised by Reid B. for sanalmakina (princ "\n\t\t>>> Select text to get summ >>>") (if ;;select texts/mtexts on screen : (setq ss (ssget '((0 . "*TEXT")))) ;; if selected then : (progn ;; set initial sum to zero : (setq sum 0.) ;; loop trough selected texts/mtexts : (while ;; get the first text in selection : (setq en (ssname ss 0)) ;; get entity list of them : (setq elist (entget en)) ;; get the textstring by key 1 from entity list : (setq txt (cdr (assoc 1 elist))) ;; create output string : (setq sumtxt ;; concatenate strings : (strcat ;; convert digits to string : (rtos ;; add to summ the digital value of text : (setq sum (+ (atof txt) sum)) ;; 2 is for metric units (3 for engineering) : 5;;revised by Reid B. ;; set precision by current : (getvar "dimdec"))" " "m3/h") ) ;; delete entity from selection set : (ssdel en ss) ) ;; Change to text : (setq ins (getpoint "\nSpecify text location: "));;start revision by Reid B. (entmake (list '(0 . "TEXT") (cons 40 (getvar 'textsize)) (cons 10 ins) (cons 1 sumtxt) ))) ) (princ) ) (princ "\nStart command with STX...") (princ) Thank you so much , it worked! -fixo -Lt Dan's legs -David Bethel -tharwat313 -alanjt Quote
alanjt Posted August 6, 2010 Posted August 6, 2010 what about in this case? I wasn't sure if the version of acad played a factorVersion shouldn't have a factor, but don't quote me on that. Quote
Lt Dan's legs Posted August 6, 2010 Posted August 6, 2010 don't quote me on that. I've come across this before but I didn't understand why it was used.. maybe I'll search for that routine and have another look at it. Thanks Quote
Tharwat Posted August 6, 2010 Posted August 6, 2010 Thank you so much , it worked! -fixo -Lt Dan's legs -David Bethel -tharwat313 -alanjt First we should thank Mr.fixo because the codes were written by him. I am glad you got it worked finally.. Enjoy it .. Tharwat Quote
Lee Mac Posted August 6, 2010 Posted August 6, 2010 So' date=' is (cons 100 "AcDbEntity") and (cons 100 "AcDbText") needed?[/quote'] For legacy reasons, entmake ignores DXF group code 100 data for the following entity types: AcDbText AcDbAttribute AcDbAttributeDefinition AcDbBlockBegin AcDbBlockEnd AcDbSequenceEnd AcDbBlockReference AcDbMInsertBlock AcDb2dVertex AcDb3dPolylineVertex AcDbPolygonMeshVertex AcDbPolyFaceMeshVertex AcDbFaceRecord AcDb2dPolyline AcDb3dPolyline AcDbArc AcDbCircle AcDbLine AcDbPoint AcDbFace AcDbPolyFaceMesh AcDbPolygonMesh AcDbTrace AcDbSolid AcDbShape AcDbViewport It is required in all other entities. Quote
Lt Dan's legs Posted August 6, 2010 Posted August 6, 2010 Would you say it's good practice to include or should I get familiar with this? Quote
Lee Mac Posted August 6, 2010 Posted August 6, 2010 Would you say it's good practice to include or should I get familiar with this? Its no harm to include them, but it will fail if those code are not included when needed. I usually only include the codes that are needed, but then I usually can't be bothered to type it out lol Quote
Lt Dan's legs Posted August 6, 2010 Posted August 6, 2010 Looking at the list all the things is use entmake for are there... but I am pretty forgetful. I think I'll include in my routines so I don't forget when it matters and wonder why it's not working. Thanks Quote
Lee Mac Posted August 6, 2010 Posted August 6, 2010 There aren't too many entities that need it, but most commonly I find MText and LWPolylines. Quote
sandman007 Posted December 9, 2010 Posted December 9, 2010 (edited) Hey I just started to use this lisp... That Fixo wrote and others edited from this thread... The problem I'm having is all out text is underlined for our key notes. and the lisp will not add them up. here's the code. is there anyone that can fix it so it recognizes the underlined text strings. (defun C:STX (/ cpent elist en ip newtxt pt ss sum sumtxt txt) (princ "\n\t\t>>> Select text to get summ >>>") (if ;;select texts/mtexts on screen : (setq ss (ssget '((0 . "*TEXT")))) ;; if selected then : (progn ;; store the first text entity for using 'em further : (setq cpent (ssname ss 0)) ;; set initial sum to zero : (setq sum 0.) ;; loop trough selected texts/mtexts : (while ;; get the first text in selection : (setq en (ssname ss 0)) ;; get entity list of them : (setq elist (entget en)) ;; get the textstring by key 1 from entity list : (setq txt (cdr (assoc 1 elist))) ;; create output string : (setq sumtxt ;; concatenate strings : (strcat ;; convert digits to string : (rtos ;; add to summ the digital value of text : (setq sum (+ (atof txt) sum)) ;; 2 is for metric units (3 for engineering) : 2 ;; set precision by current : (getvar "dimdec"))) ) ;; delete entity from selection set : (ssdel en ss) ) ;; display message in the command line: (princ (strcat "\nSumm=" sumtxt)) (setq pt (getpoint "\nSpecify the new text location: ")) ;; get the insertion point of stored entity : (setq ip (cdr (assoc 10 (entget cpent)))) ;; copy text entity to the new destination point : (command "_copy" cpent "" ip pt) ;; get the last created entity : (setq newtxt (entlast)) ;; get entity list of them : (setq elist (entget newtxt)) ;; modify entity list with new text string : (entmod (subst (cons 1 sumtxt)(assoc 1 elist) elist)) ;; update changes : (entupd newtxt) ) ) (princ) ) (princ "\nStart command with STX...") (princ) Edited December 9, 2010 by sandman007 Wearing the wrong shoes Quote
alanjt Posted December 9, 2010 Posted December 9, 2010 http://www.cadtutor.net/forum/showthread.php?46688-Combinevalues.LSP-Add-Divide-Multiply-Subtract-object-values Quote
sandman007 Posted December 9, 2010 Posted December 9, 2010 http://www.cadtutor.net/forum/showthread.php?46688-Combinevalues.LSP-Add-Divide-Multiply-Subtract-object-values Awesome! How is the text height controlled? Quote
Lt Dan's legs Posted December 9, 2010 Posted December 9, 2010 Assuming Alan used (getvar 'textsize) if you want to have 4" high text then (setvar 'textsize 4) __edit__ actually I do not see it... Quote
alanjt Posted December 9, 2010 Posted December 9, 2010 Assuming Alan used (getvar 'textsize) if you want to have 4" high text then (setvar 'textsize 4) __edit__ actually I do not see it... vla-AddMText uses the current text settings (style and textsize variable). I use it over entmake because it works with annotative text styles. 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.