mahmoudqaswal Posted March 29, 2016 Posted March 29, 2016 (edited) Hi, first thanks for lee mac and rkmcswain to help me i was write a lisp that can convert the number to text number in Arabic language but, i have some problem in this lisp i use mathematics equations to separate every number like this 665.33 x=600 y=60 z=5 x1=30 x2=3 and then i use nth, fix condition by using sequence no problem about this but when reach to number after comma the variable x2 increase +1 to the value expect no 3 i don't know why do that please help me to solve this problem ; NCONVERT.lsp - convert number to text (defun c:NC (x6 ) (setq n ( getdist "\nEnter the no. :")) (setq x1 ( fix (/ n 100))) (setq x2 (fix(/ (- n (* (fix (/ n 100)) 100 )) 10))) (setq x3 (fix(- n (* x1 100) (* x2 10)))) (setq x4 (- n (* 100 x1) (* 10 x2) x3)) (setq x5 (* 100 x4)) (setq x6 (fix x5)) (setq y1 (nth x1 '("" "lhzm" "lzjhk" "eghelhzm" "hvfulhzm" "olslhzm" "sjlhzm" "sfulhzm" "elhklhzm" "jsulhzm"))) (setq y2 (nth x2 '("" ",uav" ",uav,k" ",eghe,k" ",hvfu,k" ",ols,k" ",sj,k" ",sfu,k" ",elhk,k" ",jsu,k"))) (setq y3 (nth x3 '("" ",,hp]" ",hekhk" ",eghem" ",hvfum" ",olsm" ",sjm" ",sfum" ",elhkdm" ",jsum"))) (setq x5 (* 100 x4)) (setq x6 (fix x5)) (setq y6 (nth x6 '("" ",,hp]" ",hekhk" ",eghem" ",hvfum" ",olsm" ",sjm" ",sfum" ",elhkdm" ",jsum" ",uavm" ",hp] uav" ",hekh uav" ",eghem uav" ",hvfum uav" ",olsm uav" ",sjm uav" ",sfum uav" ",elhkdm uav" ",jsum uav" ",uav,k" ",,hp] ,uav,k" ",hekhk ,uav,k" ",eghem ,uav,k" ",hvfum ,uav,k" ",olsm ,uav,k" ",sjm ,uav,k" ",sfum ,uav,k" ",elhkdm ,uav,k" ",jsum ,uav,k" ",eghe,k" ",,hp] ,eghe,k" ",hekhk ,eghe,k" ",eghem ,eghe,k" ",hvfum ,eghe,k" ",olsm ,eghe,k" ",sjm ,eghe,k" ",sfum ,eghe,k" ",elhkdm ,eghe,k" ",jsum ,eghe,k" ",hvfu,k" ",,hp] ,hvfu,k" ",hekhk ,hvfu,k" ",eghem ,hvfu,k" ",hvfum ,hvfu,k" ",olsm ,hvfu,k" ",sjm ,hvfu,k" ",sfum ,hvfu,k" ",elhkdm ,hvfu,k" ",jsum ,hvfu,k" ",ols,k" ",,hp] ,ols,k" ",hekhk ,ols,k" ",eghem ,ols,k" ",hvfum ,ols,k" ",olsm ,ols,k" ",sjm ,ols,k" ",sfum ,ols,k" ",elhkdm ,ols,k" ",jsum ,ols,k" ",sj,k" ",,hp] ,sj,k" ",hekhk ,sj,k" ",eghem ,sj,k" ",hvfum ,sj,k" ",olsm ,sj,k" ",sjm ,sj,k" ",sfum ,sj,k" ",elhkdm ,sj,k" ",jsum ,sj,k" ",sfu,k" ",,hp] ,sfu,k" ",hekhk ,sfu,k" ",eghem ,sfu,k" ",hvfum ,sfu,k" ",olsm ,sfu,k" ",sjm ,sfu,k" ",sfum ,sfu,k" ",elhkdm ,sfu,k" ",jsum ,sfu,k" ",elhk,k" ",,hp] ,elhk,k" ",hekhk ,elhk,k" ",eghem ,elhk,k" ",hvfum ,elhk,k" ",olsm ,elhk,k" ",sjm ,elhk,k" ",sfum ,elhk,k" ",elhkdm ,elhk,k" ",jsum ,elhk,k" ",jsu,k" ",,hp] ,jsu,k" ",hekhk ,jsu,k" ",eghem ,jsu,k" ",hvfum ,jsu,k" ",olsm ,jsu,k" ",sjm ,jsu,k" ",sfum ,jsu,k" ",elhkdm ,jsu,k" ",jsum ,jsu,k"))) (setq v (strcat y1 " " y3 " " y2 " " "ljvh lvfu" " " y6 " " "skjljvh lvfu" )) (SETQ pt (GETPOINT"\nWHERE TO PLACE LABLE ?")) (command "text" "m" PT 1 0 v) ) Edited March 29, 2016 by mahmoudqaswal Quote
Lee Mac Posted March 31, 2016 Posted March 31, 2016 (edited) Perhaps try something like this: (defun c:nc ( / f n p ) (setq f '(( x ) (fix (+ x 1e-))) (initget 6) (if (and (setq n (getreal "\nEnter number: ")) (setq p (getpoint "\nSpecify point for text: ")) ) (entmake (list '(0 . "TEXT") (cons 40 (getvar 'textsize)) (cons 10 p) (cons 01 (strcat (nth (f (/ n 100)) '("" "lhzm" "lzjhk" "eghelhzm" "hvfulhzm" "olslhzm" "sjlhzm" "sfulhzm" "elhklhzm" "jsulhzm")) " " (nth (f (rem n 10)) '("" ",,hp]" ",hekhk" ",eghem" ",hvfum" ",olsm" ",sjm" ",sfum" ",elhkdm" ",jsum")) " " (nth (f (/ (rem n 100) 10)) '("" ",uav" ",uav,k" ",eghe,k" ",hvfu,k" ",ols,k" ",sj,k" ",sfu,k" ",elhk,k" ",jsu,k")) " ljvh lvfu " (nth (f (* 100 (rem n 1))) '("" ",,hp]" ",hekhk" ",eghem" ",hvfum" ",olsm" ",sjm" ",sfum" ",elhkdm" ",jsum" ",uavm" ",hp] uav" ",hekh uav" ",eghem uav" ",hvfum uav" ",olsm uav" ",sjm uav" ",sfum uav" ",elhkdm uav" ",jsum uav" ",uav,k" ",,hp] ,uav,k" ",hekhk ,uav,k" ",eghem ,uav,k" ",hvfum ,uav,k" ",olsm ,uav,k" ",sjm ,uav,k" ",sfum ,uav,k" ",elhkdm ,uav,k" ",jsum ,uav,k" ",eghe,k" ",,hp] ,eghe,k" ",hekhk ,eghe,k" ",eghem ,eghe,k" ",hvfum ,eghe,k" ",olsm ,eghe,k" ",sjm ,eghe,k" ",sfum ,eghe,k" ",elhkdm ,eghe,k" ",jsum ,eghe,k" ",hvfu,k" ",,hp] ,hvfu,k" ",hekhk ,hvfu,k" ",eghem ,hvfu,k" ",hvfum ,hvfu,k" ",olsm ,hvfu,k" ",sjm ,hvfu,k" ",sfum ,hvfu,k" ",elhkdm ,hvfu,k" ",jsum ,hvfu,k" ",ols,k" ",,hp] ,ols,k" ",hekhk ,ols,k" ",eghem ,ols,k" ",hvfum ,ols,k" ",olsm ,ols,k" ",sjm ,ols,k" ",sfum ,ols,k" ",elhkdm ,ols,k" ",jsum ,ols,k" ",sj,k" ",,hp] ,sj,k" ",hekhk ,sj,k" ",eghem ,sj,k" ",hvfum ,sj,k" ",olsm ,sj,k" ",sjm ,sj,k" ",sfum ,sj,k" ",elhkdm ,sj,k" ",jsum ,sj,k" ",sfu,k" ",,hp] ,sfu,k" ",hekhk ,sfu,k" ",eghem ,sfu,k" ",hvfum ,sfu,k" ",olsm ,sfu,k" ",sjm ,sfu,k" ",sfum ,sfu,k" ",elhkdm ,sfu,k" ",jsum ,sfu,k" ",elhk,k" ",,hp] ,elhk,k" ",hekhk ,elhk,k" ",eghem ,elhk,k" ",hvfum ,elhk,k" ",olsm ,elhk,k" ",sjm ,elhk,k" ",sfum ,elhk,k" ",elhkdm ,elhk,k" ",jsum ,elhk,k" ",jsu,k" ",,hp] ,jsu,k" ",hekhk ,jsu,k" ",eghem ,jsu,k" ",hvfum ,jsu,k" ",olsm ,jsu,k" ",sjm ,jsu,k" ",sfum ,jsu,k" ",elhkdm ,jsu,k" ",jsum ,jsu,k")) " skjljvh lvfu" ) ) ) ) ) (princ) ) Edited March 31, 2016 by Lee Mac Quote
mahmoudqaswal Posted March 31, 2016 Author Posted March 31, 2016 Thank you Lee Mac but the problem still exist can you help me please? Quote
mahmoudqaswal Posted March 31, 2016 Author Posted March 31, 2016 Thank you Lee Mac but the problem still exist can you help me please? Quote
Lee Mac Posted March 31, 2016 Posted March 31, 2016 Thank you, I have now modified the above code - please try it again and let me know if the issue remains. Quote
mahmoudqaswal Posted April 1, 2016 Author Posted April 1, 2016 Thank you, the problem was solved God bless you:D:D Quote
mahmoudqaswal Posted April 2, 2016 Author Posted April 2, 2016 Thank you Lee Mac for help me, and i have another request please, can you do this lisp by selection the number instead of writing the number Quote
Lee Mac Posted April 2, 2016 Posted April 2, 2016 Thank you Lee Mac for help me, and i have another request please, can you do this lisp by selection the number instead of writing the number Should the selected text be replaced, or should a new text object be created? Quote
mahmoudqaswal Posted April 2, 2016 Author Posted April 2, 2016 should a new text object be created please or replaced but with another text not with the orginal number text Quote
Lee Mac Posted April 2, 2016 Posted April 2, 2016 Try the following: (defun c:nc ( / f n p ) (setq f '(( x ) (fix (+ x 1e-))) (initget 6) (if (and (setq n (getnumber "\nSelect number: ")) (setq p (getpoint "\nSpecify point for text: ")) ) (entmake (list '(0 . "TEXT") (cons 40 (getvar 'textsize)) (cons 10 p) (cons 01 (strcat (nth (f (/ n 100)) '("" "lhzm" "lzjhk" "eghelhzm" "hvfulhzm" "olslhzm" "sjlhzm" "sfulhzm" "elhklhzm" "jsulhzm")) " " (nth (f (rem n 10)) '("" ",,hp]" ",hekhk" ",eghem" ",hvfum" ",olsm" ",sjm" ",sfum" ",elhkdm" ",jsum")) " " (nth (f (/ (rem n 100) 10)) '("" ",uav" ",uav,k" ",eghe,k" ",hvfu,k" ",ols,k" ",sj,k" ",sfu,k" ",elhk,k" ",jsu,k")) " ljvh lvfu " (nth (f (* 100 (rem n 1))) '("" ",,hp]" ",hekhk" ",eghem" ",hvfum" ",olsm" ",sjm" ",sfum" ",elhkdm" ",jsum" ",uavm" ",hp] uav" ",hekh uav" ",eghem uav" ",hvfum uav" ",olsm uav" ",sjm uav" ",sfum uav" ",elhkdm uav" ",jsum uav" ",uav,k" ",,hp] ,uav,k" ",hekhk ,uav,k" ",eghem ,uav,k" ",hvfum ,uav,k" ",olsm ,uav,k" ",sjm ,uav,k" ",sfum ,uav,k" ",elhkdm ,uav,k" ",jsum ,uav,k" ",eghe,k" ",,hp] ,eghe,k" ",hekhk ,eghe,k" ",eghem ,eghe,k" ",hvfum ,eghe,k" ",olsm ,eghe,k" ",sjm ,eghe,k" ",sfum ,eghe,k" ",elhkdm ,eghe,k" ",jsum ,eghe,k" ",hvfu,k" ",,hp] ,hvfu,k" ",hekhk ,hvfu,k" ",eghem ,hvfu,k" ",hvfum ,hvfu,k" ",olsm ,hvfu,k" ",sjm ,hvfu,k" ",sfum ,hvfu,k" ",elhkdm ,hvfu,k" ",jsum ,hvfu,k" ",ols,k" ",,hp] ,ols,k" ",hekhk ,ols,k" ",eghem ,ols,k" ",hvfum ,ols,k" ",olsm ,ols,k" ",sjm ,ols,k" ",sfum ,ols,k" ",elhkdm ,ols,k" ",jsum ,ols,k" ",sj,k" ",,hp] ,sj,k" ",hekhk ,sj,k" ",eghem ,sj,k" ",hvfum ,sj,k" ",olsm ,sj,k" ",sjm ,sj,k" ",sfum ,sj,k" ",elhkdm ,sj,k" ",jsum ,sj,k" ",sfu,k" ",,hp] ,sfu,k" ",hekhk ,sfu,k" ",eghem ,sfu,k" ",hvfum ,sfu,k" ",olsm ,sfu,k" ",sjm ,sfu,k" ",sfum ,sfu,k" ",elhkdm ,sfu,k" ",jsum ,sfu,k" ",elhk,k" ",,hp] ,elhk,k" ",hekhk ,elhk,k" ",eghem ,elhk,k" ",hvfum ,elhk,k" ",olsm ,elhk,k" ",sjm ,elhk,k" ",sfum ,elhk,k" ",elhkdm ,elhk,k" ",jsum ,elhk,k" ",jsu,k" ",,hp] ,jsu,k" ",hekhk ,jsu,k" ",eghem ,jsu,k" ",hvfum ,jsu,k" ",olsm ,jsu,k" ",sjm ,jsu,k" ",sfum ,jsu,k" ",elhkdm ,jsu,k" ",jsum ,jsu,k")) " skjljvh lvfu" ) ) ) ) ) (princ) ) (defun getnumber ( msg / ent enx num ) (while (progn (setvar 'errno 0) (setq ent (car (entsel msg))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil) ( (not (wcmatch (cdr (assoc 0 (setq enx (entget ent))))"*TEXT")) (princ "\nPlease select a text object.") ) ( (not (setq num (distof (cdr (assoc 1 enx))))) (princ "\nText content is not numerical.") ) ) ) ) num ) (princ) 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.