Jump to content

Lisp -text millimeters to feet


Hsanon

Recommended Posts

  • 2 years later...
  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • Hsanon

    8

  • Tharwat

    4

  • Lee Mac

    3

  • Ajmal

    3

On 22/11/2014 at 14:00, Tharwat said:

Try my program and let me know .

 

 


(defun c:mm2in (/ in ss)
 ;; ==================================================    ;;
 ;;    Author : Tharwat Al Shoufi .Date: 22.Nov.2014    ;;
 ;;    Converts Text Strings from Millimeter to Inch    ;;
 ;; ==================================================    ;;
 (if (setq in (/ 1. 25.4)
           ss (ssget "_:L"
                     '((0 . "TEXT,MTEXT")
                       (1 . "1*,2*,3*,4*,5*,6*,7*,8*,9*,x*,X*")
                      )
              )
     )
   ((lambda (x / sn e s a)
      (while (setq sn (ssname ss (setq x (1+ x))))
        (entmod
          (subst
            (cons
              1
              (if (wcmatch
                    (setq
                      a (strcase
                          (substr
                            (setq
                              s (cdr (assoc 1 (setq e (entget sn))))
                            )
                            1
                            1
                          )
                        )
                    )
                    "X*"
                  )
                (if (/= (atof (substr s 2)) 0.)
                  (strcat a (rtos (* (atof (substr s 2)) in) 4 0))
                  s
                )
                (rtos (* (atof s) in) 4 0)
              )
            )
            (assoc 1 e)
            e
          )
        )
      )
    )
     -1
   )
 )
 (princ)
)

 

 

how to make mm to m

Link to comment
Share on other sites

On 30/11/2014 at 22:38, Lee Mac said:

Hi Hsanon,

 

Try the following program:

 


([color=BLUE]defun[/color] c:mm2in [color=BLUE]nil[/color] (converttext ([color=BLUE]/[/color] 1.0 25.4) 4 0))
([color=BLUE]defun[/color] c:in2mm [color=BLUE]nil[/color] (converttext 25.4 2 2))

([color=BLUE]defun[/color] converttext ( f u p [color=BLUE]/[/color] e i n s x y )
   ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] '((0 . [color=MAROON]"TEXT,MTEXT"[/color]) (1 . [color=MAROON]"[1-9xX]*"[/color]))))
       ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s))
           ([color=BLUE]setq[/color] e ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i))))
                 x ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 1 e))
           )
           ([color=BLUE]if[/color] ([color=BLUE]wcmatch[/color] x [color=MAROON]"[xX]*"[/color])
               ([color=BLUE]setq[/color] y ([color=BLUE]chr[/color] ([color=BLUE]ascii[/color] x)) x ([color=BLUE]substr[/color] x 2))
               ([color=BLUE]setq[/color] y [color=MAROON]""[/color])
           )
           ([color=BLUE]if[/color] ([color=BLUE]setq[/color] n ([color=BLUE]distof[/color] x 4))
               ([color=BLUE]entmod[/color] ([color=BLUE]subst[/color] ([color=BLUE]cons[/color] 1 ([color=BLUE]strcat[/color] y ([color=BLUE]rtos[/color] ([color=BLUE]*[/color] n f) u p))) ([color=BLUE]assoc[/color] 1 e) e))
           )
       )
   )
   ([color=BLUE]princ[/color])
)
 

 

The commands are mm2in & in2mm.

 

Lee

How to run the code...

Link to comment
Share on other sites

20 hours ago, Lee Mac said:

 

I have updated my earlier post to remove the visible BBCode formatting.

 

Firstly, thanks for your help. This very helps full for me

I just change this code to the millimeter to meter

am using this lisp for changing level. But this is not reding any positive or negative (+OR-)

if I will select +18.050 it will not come. I have to replace +. Can you help me to read this any positive or negative value also

Link to comment
Share on other sites

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