smallpixel Posted December 19, 2008 Share Posted December 19, 2008 Hi people,i'm a newbies in AutoLisp and my script is pretty easy and i already make 99% of the work , i have a lot of text in my DWG file and i want to ouput the XY coordonate of each text(look down for the script),and get the centent of the text and put that into the Z coordonate (look down for the script used to ouput the name of the text) in the end i wanna combine those too script to ouput all the data in some file in this format X,Y,Centent of the text (us the Z component) ///////Script for Exporting the Name of text//////// (defun C:txtex (/ et) (setq fl (open "dtext.txt" "w") et (entnext) ) (while et (setq el (entget et) tp (cdr (assoc 0 el)) ) (if (or (= tp "TEXT") (= tp "MTEXT")) (write-line (cdr (assoc 10 el)) fl) ) (setq et (entnext et)) ) (close fl) ) ///////Script for XY Exporting//////// (defun c:PO2TXT (/ file points c i) ;POints to TeXT (setq file (open (getfiled "specify output file" "c:/" "TXT" 1) "w")) (setq points (ssget) i 0) (repeat (sslength points) (if (= "TEXT" (cdr (assoc 0 (entget (ssname points i))))) (setq c (cdr (assoc 10 (entget (ssname points i)))) i (1+ i) ) ) (write-line (strcat (rtos (car c)) " , " (rtos (cadr c)) ) file) ) (close file) (Princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 19, 2008 Share Posted December 19, 2008 This will write content: (defun C:txtex (/ fl ss ssl index ent) (setq fl (open "dtext.txt" "w") ss (ssget "x" (list (cons 0 "TEXT,MTEXT"))) ssl (sslength ss) index 0 ) ;_ end setq (repeat ssl (setq ent (entget (ssname ss index))) (write-line (cdr (assoc 1 ent)) fl) (setq index (1+ index)) ) ;_ end repeat (close fl) (princ) ) ;_ end defun Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 19, 2008 Share Posted December 19, 2008 This will write points: (defun c:PO2TXT (/ file points c i) (setq file (open (getfiled "Specify Output File" "c:/" "txt" 1) "w")) (setq points (ssget "X" (list (cons 0 "TEXT,MTEXT"))) i 0 ) ;_ end setq (repeat (sslength points) (setq c (cdr (assoc 10 (entget (ssname points i)))) i (1+ i) ) ;_ end setq (write-line (strcat (rtos (car c)) " , " (rtos (cadr c)) ) ;_ end strcat file ) ;_ end write-line ) ;_ end repeat (close file) (princ) ) ;_ end defun Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 19, 2008 Share Posted December 19, 2008 Maybe this to link them? (defun c:PO2TXT (/ file points c vl i) (setq file (open (getfiled "Specify Output File" "c:/" "txt" 1) "w")) (setq points (ssget '((0 . "TEXT,MTEXT"))) i 0 ) ;_ end setq (repeat (sslength points) (setq c (cdr (assoc 10 (entget (ssname points i)))) vl (cdr (assoc 1 (entget (ssname points i)))) i (1+ i) ) ;_ end setq (write-line (strcat (rtos (car c)) " , " (rtos (cadr c)) "\t" vl ) ;_ end strcat file ) ;_ end write-line ) ;_ end repeat (close file) (princ) ) ;_ end defun (All three untested) Quote Link to comment Share on other sites More sharing options...
smallpixel Posted December 20, 2008 Author Share Posted December 20, 2008 i realy appreciate ur help man, i will get a deep look into the code and test them, Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 20, 2008 Share Posted December 20, 2008 No probs smallpixel, happy to help. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 20, 2008 Share Posted December 20, 2008 LISPs updated. ---> they didn't include MTEXT - sorry about that Also, there are two ways to do it: Have a LISP in which the user selects which text to print to file: (defun c:PO2TXT1 (/ file points c vl i) (setq file (open (getfiled "Specify Output File" "c:/" "txt" 1) "w")) (setq points (ssget '((0 . "TEXT,MTEXT"))) i 0 ) ;_ end setq (repeat (sslength points) (setq c (cdr (assoc 10 (entget (ssname points i)))) vl (cdr (assoc 1 (entget (ssname points i)))) i (1+ i) ) ;_ end setq (write-line (strcat (rtos (car c)) " , " (rtos (cadr c)) "\t" vl ) ;_ end strcat file ) ;_ end write-line ) ;_ end repeat (close file) (princ) ) ;_ end defun Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 20, 2008 Share Posted December 20, 2008 Or have a LISP which selects all the text entities automatically and prints them: (defun c:PO2TXT (/ file points c vl i) (setq file (open (getfiled "Specify Output File" "c:/" "txt" 1) "w")) (setq points (ssget "X" (list (cons 0 "TEXT,MTEXT"))) i 0 ) ;_ end setq (repeat (sslength points) (setq c (cdr (assoc 10 (entget (ssname points i)))) vl (cdr (assoc 1 (entget (ssname points i)))) i (1+ i) ) ;_ end setq (write-line (strcat (rtos (car c)) " , " (rtos (cadr c)) "\t" vl ) ;_ end strcat file ) ;_ end write-line ) ;_ end repeat (close file) (princ) ) ;_ end defun Quote Link to comment Share on other sites More sharing options...
smallpixel Posted December 20, 2008 Author Share Posted December 20, 2008 Can u give me ur email adress at smallpixel@gmail.com i wanna thank u ... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 20, 2008 Share Posted December 20, 2008 No offence, but can't you just thank me on here? Quote Link to comment Share on other sites More sharing options...
smallpixel Posted December 21, 2008 Author Share Posted December 21, 2008 thx a lot but i was thinking about noel Gift for u any way thx for u help ,our team realy appreciate ur work . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 21, 2008 Share Posted December 21, 2008 Ahh thanks, Happy to help Merry Xmas Quote Link to comment Share on other sites More sharing options...
smallpixel Posted December 21, 2008 Author Share Posted December 21, 2008 U too .... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 21, 2008 Share Posted December 21, 2008 If you have any further queries, just let me know. Quote Link to comment Share on other sites More sharing options...
smallpixel Posted December 21, 2008 Author Share Posted December 21, 2008 thx we realy appreciate the work, and the script solve what we was looking for and it work 100%. Quote Link to comment Share on other sites More sharing options...
CAB Posted December 21, 2008 Share Posted December 21, 2008 LeeMac, Here is another way to approach the routine. Note that only text in the current space are used. (defun c:PO2TXT (/ ss file fn) (if (and (setq file (getfiled "Specify Output File" "c:/" "txt" 1)) (setq ss (ssget "X" (list (cons 0 "TEXT,MTEXT")(cons 410 (getvar "ctab"))))) (setq fn (open file "W")) ) (progn (mapcar '(lambda (ent) (print (cdr (assoc 10 (entget ent))) fn) (princ (strcat "\t" (cdr (assoc 1 (entget ent)))) fn) ) (mapcar 'cadr (ssnamex ss)) ) (close fn) ) ) (princ) ) ;_ end defun Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 22, 2008 Share Posted December 22, 2008 Thanks for your help and advice CAB, I notice that you like to use the lambda function and also ssnamex - I saw them in your other routine with min, max and average I realise I did not specify the current tab, but is this necessary? But could you help me to understand the following please: '(lambda (ent) (print (cdr (assoc 10 (entget ent))) fn) ([b][color=Red]princ[/color][/b] (strcat "\t" (cdr (assoc 1 (entget ent)))) fn) ) Should the highlighted be "print"? Also, I notice that you use the "ent" argument in the lambda function, do you input this argument using the ssnamex? and if so, how is ssnamex used? I tried to use it on a selection set and found it didn't return much that is of any use... Thanks for your help. Quote Link to comment Share on other sites More sharing options...
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.