Dakine Posted January 20, 2012 Posted January 20, 2012 Hi, Is anyone can help me come up with an automated method by Macro or Lisp to edit text string with a constant number. Since I have a drawing with a lot of coordinates needed to be changed and with the lisp helps me to do globally or individual is still helpful. For instance, if the orginal text is N 35800.578 and I have to manually subtract 210.5 and edit the text to be N35590.078. Likewise on the Easting coordinates have to subtract 400.0 and Elevations have to subtract 3.700. With these constants value which if I can change the text automatedly without edit manually then it will be cutting time comsuming down tremendously. Thanks so much in advance. ps. pls. let me know any other info you need in order to achieve this routine. Thnks Quote
pBe Posted January 21, 2012 Posted January 21, 2012 (edited) I'm guessing your not certain a space " " after N or E is always present, hence the need for while .... Written in haste (defun c:SuBVal (/ ss i en prf v clr) (if (setq ss (ssget ":L" '((0 . "TEXT")(1 . [color=blue]"E. #*,EL. #*,N. #*"[color=black]))))[/color][b][color=black] [/color] [/b][/color] (repeat (setq i (sslength ss)) (setq en (ssname ss (setq i (1- i)))) (if (and (setq prf (substr (setq str (cdr (assoc 1 (entget en)))) 1 3)) (setq v (cond ((eq prf "E. ") [color=blue]210.50) [/color] ((eq prf "N. ") [color=blue]400.00[/color] ) ((eq prf "EL.") [color=blue](setq str (substr str 2) prf (strcat prf " ")) 3.70[/color] ))) ) (progn (vla-put-textstring (setq en (vlax-ename->vla-object en)) (strcat prf (rtos (- (distof (substr str 3) 2) [color=blue]v[/color]) 2 3))) [color=blue](vla-put-color en 1)[/color]) ) ) ) (princ) ) EDIT: "E. #*,EL. #*,N. #*" Edited January 26, 2012 by pBe Quote
Dakine Posted January 23, 2012 Author Posted January 23, 2012 Hi, Somehow, maybe I did not do it properly since after load it and type in @ command line Test but it prompted "; error: bad argument type: numberp: nil". BTW, you are absolutely correct that was a space after N. and E. and so EL. So the constant for EL. is 3.7, N. is 210.5 and E. is 400.0. Thanks so much for your effort, Dakine Quote
pBe Posted January 24, 2012 Posted January 24, 2012 Guess I missed the EL part there. Post a sample drawing or a snapshot of the string in question Quote
Dakine Posted January 24, 2012 Author Posted January 24, 2012 Mahalo pBe and Renderman, I worked perpectly, thanks for the useful thought and your expertise. It has inspired me to learn more about Lisp. pBe, a favor to ask if you can revise it to change the color to red after edited in order to know which is which. Thanks again for your effort and time, Happy New Year for the year of the Dragon. peace Quote
Dakine Posted January 24, 2012 Author Posted January 24, 2012 pBe, In addition, the period after N and E and EL should remain after the text is edited. Trying to post the image with the dwg file but somehow and attach it. will try again. thanks Quote
pBe Posted January 25, 2012 Posted January 25, 2012 pBe,In addition, the period after N and E and EL should remain after the text is edited. Trying to post the image with the dwg file but somehow and attach it. will try again. thanks You're telling me that the target strings contains a "." after N/E/EL? and not just a " " (space)? so.. "N. 5800.578" and not "N 35800.578" ? Quote
Dakine Posted January 25, 2012 Author Posted January 25, 2012 PBe, That is correct, my fault since did not demonstrated clearly. It originally looks like N. XXXXX.XXX, E. XXXXX.XXX, EL. XXX.XXX. So the previous still worked, all I have to to is find N and replace with N., likewise for the E and El. If it do one shot for all and change the color to red the would be nice. Thanks in advance, Quote
Dakine Posted January 26, 2012 Author Posted January 26, 2012 pBe, Thanks for the revision, your help is appreciated, most of all is more than the work of art itself but the effort to wake up so early for helping others, that is admirable. Kindest regards, Quote
Dakine Posted January 26, 2012 Author Posted January 26, 2012 pBe, It did the job perfectly, first it did backward in terms of N. subtract 400.00 instead of 210.50, and E. same thing with 210.0 but I did edited it accordingly and it works. Just wondering that was written with LSP or Diesel or other language ? Would you let me know where is the helpful start or some sort of resource can be found to get in to it for learning the basic. Back to the old days, I remember the macro is very tidious with parenthesis and ((command:)) repeatedly, but yours is very brief but it functional. Anyway, that would be inspirational for me and anybody interest. Thanks again, peace Quote
pBe Posted January 27, 2012 Posted January 27, 2012 pBe,It did the job perfectly, first it did backward in terms of N. subtract 400.00 instead of 210.50, and E. same thing with 210.0 but I did edited it accordingly and it works. Ooops.. my mistake pBe,Just wondering that was written with LSP or Diesel or other language ? Would you let me know where is the helpful start or some sort of resource can be found to get in to it for learning the basic.Thanks again, Our fellow members website LeeMac Where I started AFRALisp Another JefferyPSanders Quote
Dakine Posted January 27, 2012 Author Posted January 27, 2012 pBe, Thanks for the info, that is good start and I'm very interested. til next time one world, one love & one peace Quote
Dakine Posted January 27, 2012 Author Posted January 27, 2012 pBe, Would you revise the Lisp for just doing the text which will do same function to text which were manually picked, these text does not have letter N. in front of the value (xxxxx.xxx) and does not have letter E. also. Just text such as 12345.678 for coordinate in chart. So the Lisp should have choice of subtract 400.00, and 210.50 and 3.700 then we go to pick the text (xxxxx.xxx). Just FYI that the Northing always starts with 2xxxx.xxx, and Easting starts with 3xxxx.xxx. Don't know this help or not. Thanks in adance again. PS. I attached the PDF of the dwg which in the chart is the coordinate to be edited. Sorry I could not , exceed the limits Quote
pBe Posted January 28, 2012 Posted January 28, 2012 Make another one or incorporate an option for "Annotation or Chart"? Just FYI that the Northing always starts with 2xxxx.xxx, and Easting starts with 3xxxx.xxx. What of EL. values? Quote
Dakine Posted January 28, 2012 Author Posted January 28, 2012 pBe, Sorry I forgot, the elevation all of them started with 35x.xxx and needs to subtract 3.700. Thanks Quote
pBe Posted January 29, 2012 Posted January 29, 2012 (edited) It would help if i can see how your chart looks like. Anyhoo try this: (defun c:SuBVal (/ ss i en prf v clr) [color=blue](if (not opt) (setq opt "A"))[/color] [color=blue](initget "A C")[/color] [color=blue](setq opt[/color] [color=blue] (cond ( (getkword[/color] [color=blue] (strcat "\nChoose [Annotations/Chart] <" opt ">: ")[/color] [color=blue] )[/color] [color=blue] )[/color] [color=blue] ( opt )[/color] [color=blue] )[/color] [color=blue])[/color] (if (setq ss (ssget ":L" [color=blue](list '(0 . "TEXT")[/color] [color=blue] (cons 1 (if (eq opt "A") "E. #*,EL. #*,N. #*" "#*")))))[/color] (repeat (setq i (sslength ss)) (setq en (ssname ss (setq i (1- i)))) (if (and (setq prf (substr (setq str (cdr (assoc 1 (entget en)))) 1 3)) (setq v (cond ((eq prf "E. ") 400.00 ) ((eq prf "N. ") 210.50) ((eq prf "EL.") (setq str (substr str 2) prf (strcat prf " ")) 3.70 ) [color=blue]((wcmatch prf "35*") 3.70 )[/color] [color=blue] ((wcmatch prf "3*") 400.00 )[/color] [color=blue] ((wcmatch prf "2*") 210.50 )[/color] ) ) ) (progn (vla-put-textstring (setq en (vlax-ename->vla-object en)) [color=blue](if (eq opt "A")[/color] (strcat prf (rtos (- (distof (substr str 3) 2) v) 2 3)) [color=blue](rtos (- (distof str 2) v) 2 3)[/color] ) ) (vla-put-color en 1)) ) ) ) (princ) ) Edited January 29, 2012 by pBe Quote
Dakine Posted January 30, 2012 Author Posted January 30, 2012 pBe, Hope the chart was attached with this. Could not load it previously. thanks 074-2300-110-270-010 03.dwg 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.