Jump to content

Recommended Posts

Posted

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

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • Dakine

    11

  • pBe

    9

  • CADWORKER

    2

  • BlackBox

    1

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

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

Posted

Guess I missed the EL part there.

Post a sample drawing or a snapshot of the string in question

Posted

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

Posted

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

Posted
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" ?

Posted

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,

Posted

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,

Posted

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

Posted
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

Posted

pBe,

Thanks for the info, that is good start and I'm very interested.

til next time

one world, one love & one peace

Posted

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

Posted

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?

Posted

pBe,

Sorry I forgot, the elevation all of them started with 35x.xxx and needs to subtract 3.700.

Thanks

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

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