CALCULATION IN LISP

CALCULATION IN LISP

Gaganpatel
Collaborator Collaborator
3,158 Views
39 Replies
Message 1 of 40

CALCULATION IN LISP

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

I want to calculation in auto lisp programming.

Please find the attached calculation.

Any body please help me.

 

0 Likes
3,159 Views
39 Replies
Replies (39)
Message 2 of 40

hak_vz
Advisor
Advisor

@Gaganpatel

All this are simple lisp expressions that are easy to program. It's time for you to start learning autolisp, If you want to became proficient  Autocad user and help yourself, you just have to do it. Try to write your code and if you stuck in problems then ask. This forum is not free programing service. There is autolisp help inside Autocad sou you can start.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 3 of 40

Gaganpatel
Collaborator
Collaborator

Dear Sir,

I don't know lisp programming.

Please help me, I request you.

0 Likes
Message 4 of 40

Sea-Haven
Mentor
Mentor

Agree just have a go you may be looking for this function (sqrt val), all the others are there (*  (+  (-  (/. Just keep remembering to go the left adding the next math function.

 

Look at first page AutoLISP Functions | AfraLISP

0 Likes
Message 5 of 40

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

I tried but didn't happen.

I request you please help me.

0 Likes
Message 6 of 40

EnM4st3r
Advocate
Advocate

did you take a look at Afra lisp? It explains pretty good for beginners.
Also you said you tried but it didnt work, so what exactly did you try?

Is there anything specific in your code that you have problems with? Post it and maybe someone can help you

0 Likes
Message 7 of 40

-didier-
Advisor
Advisor

Bonjour @hak_vz 

 

I completely agree with what you said.

I’m about to start training on Autolisp, but I’m wondering if I’ll be able to sell it, even for a small fee.

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

Message 8 of 40

Gaganpatel
Collaborator
Collaborator

Dear Sir,

I am agree for auto lisp training.

0 Likes
Message 9 of 40

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

... you may be looking for this function (sqrt val), all the others are there (*  (+  (-  (/. ....


They will probably also want to use the (expt) function.

Kent Cooper, AIA
0 Likes
Message 10 of 40

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

I need for auto lisp programming training.

Can you please give me this programming.

0 Likes
Message 11 of 40

EnM4st3r
Advocate
Advocate

No front @Gaganpatel, but i feel like we're talking to an instagram chat bot.

0 Likes
Message 12 of 40

Gaganpatel
Collaborator
Collaborator

Dear Sir,

I create the lisp programming but there is some problem with it, please help me i need your help.

Please modify this lisp programming.

 

Problem :

1) 1st Slope & 2nd Slope required under line

2)  TAN & 2TANB ( Eight digit text required)

3) Text center required

Gaganpatel_1-1698422814763.png

 

 

0 Likes
Message 13 of 40

Kent1Cooper
Consultant
Consultant

For the underlining, in plain Text %%U turns it on and off:

(command "_.text" "" " " "_.text" "" "%%U1st SLOPE%%U            %%U2nd SLOPE" ....

[no need to turn it off at the end].  

 

For the trailing zeroes, change your DIMZIN System Variable [read about it] setting to something less than 4.

 

For the centering, to really get it right I think you'll need to build it as three separate Text objects per line, or use a monospaced font.

Kent Cooper, AIA
0 Likes
Message 14 of 40

Gaganpatel
Collaborator
Collaborator

Dear Sir,

Thanks for reply

How to write three separate Text objects per line, or use a monospaced font.

Please explain one line write. 

 

 

 

0 Likes
Message 15 of 40

Sea-Haven
Mentor
Mentor

A kindle book is $8 learning lisp etc I bought 4 By Reinaldo Togeros. So pretty hard to make money but the electronic ebook etc is the way to go.

0 Likes
Message 16 of 40

Sea-Haven
Mentor
Mentor

I would look at Mtext as it has multiline built in, it uses a paragraph seperator.

 

 

 

(setq str "ASDF\nGHJK\n12345")
(setq pt (getpoint "\nPick point for mtext "))
(command "mtext" Pt Pt str "")

 

 

re 4 should be 4.0000 need to pad zeros can do this by using the Strlen function.

 

 

 

(setq x "4.")

(cond 
((= (strlen x) 2)(setq x (strcat x "0000")))
((= (strlen x) 3)(setq x (strcat x "0000")))
((= (strlen x) 4)(setq x (strcat x "000")))
((= (strlen x) 5)(setq x (strcat x "00")))
((= (strlen x) 6)(setq x (strcat x "0")))
)

 

 

 

 

 

 

0 Likes
Message 17 of 40

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Thanks for replay.

 

kindle book By Reinaldo Togeros search many book are shown. Please request which book is the best. Please share link.

0 Likes
Message 18 of 40

diagodose2009
Collaborator
Collaborator

This program convert the  C+ math source onto LISP (or GIMP),

  1. I need help from you, you transform  your'images to math script like as "pp_utm_watermocasin"
  2. This program  transform the math script on Lisp-Script (example output)

 

#region
pp_utm_watermocasin
    //Inf: UTM to LatLon test
    //Eg1: (pp_utmirneb 451602.19 4519076.99 "33N")
    //ByA: Water Moccasin
(defun pp_utm_watermocasin( utmX utmY utmZone / rr latitude longitude len isnorthhemisphere diflat diflon c_sa c_sb e2 e2cuadrada c x y s v a1 a2 j2 j4 j6 alfa beta gama bm epsi eps nab senoheps delt tao zone)
/*c2s:
       latitude = 0,
       longitude = 0;
       len=_tcslen(utmZone);
       // Changed from utmZone.Last as the Linq version is much slower than simply indexing
       // the last position in the string's array of characters
       if (len>1)
              {   isNorthHemisphere = substr(utmZone,len,1),
                  diflat = -0.00066286966871111111111111111111111111,
		  diflon = -0.0003868060578,
                  utmZone = substr(utmZone,1,len-1);
		  c_sa = 6378137.000000;
		  c_sb = 6356752.314245;
		  e2 = math_pow((math_Pow(c_sa, 2) - Math_Pow(c_sb, 2)), 0.5) / c_sb;
		  e2cuadrada = Math_Pow(e2, 2);
		  c = math_pow(c_sa, 2) / c_sb;
		  x = utmX - 500000;
                  isNorthHemisphere =(isNorthHemisphere >"N")?T:nil;
		  y = isNorthHemisphere ? utmY : utmY - 10000000;
                  zone=atoi(utmZone);
		  s = ((zone * 6.0) - 183.0);
		  lat = y / (6366197.724 * 0.9996); // Change c_sa for 6366197.724
		  v = (c / math_pow(1 + (e2cuadrada * math_pow(cos(lat), 2)), 0.5)) * 0.9996;
		  a = x / v;
		  a1 = sin(2 * lat);
		  a2 = a1 * math_pow((cos(lat)), 2);
		  j2 = lat + (a1 / 2.0);
		  j4 = ((3 * j2) + a2) / 4.0;
                  j6 = (5 * j4 + a2 * math_pow((cos(lat)), 2)) / 3.0; // saque a2 de multiplicar por el coseno de lat y elevar al cuadrado
		  alfa = (3.0 / 4.0) * e2cuadrada;
		  beta = (5.0 / 3.0) * math_pow(alfa, 2);
		  gama = (35.0 / 27.0) * math_pow(alfa, 3);
		  bm = 0.9996 * c * (lat - alfa * j2 + beta * j4 - gama * j6);
		  b = (y - bm) / v;
                  epsi = ((e2cuadrada * math_pow(a, 2)) / 2.0) * math_pow((cos(lat)), 2);
                  eps = a * (1 - (epsi / 3.0));
		  nab = (b * (1 - epsi)) + lat;
		  senoheps = (math_exp(eps) - Math_Exp(-eps)) / 2.0;
		  delt = atan(senoheps / (cos(nab)));
		  tao = atan(cos(delt) * sin(nab) / cos(nab));
                  longitude = (delt / Math_PI) * 180 + s;
		  latitude = (((lat + (1 + e2cuadrada * math_pow(cos(lat), 2) - (3.0 / 2.0) * e2cuadrada * sin(lat) * cos(lat) * (tao - lat)) * (tao - lat))) / Math_PI) * 180.0; // era incorrecto el calculo
		  str_princ(list("\nLatitud: " ,latitude,
                             "\nLongitud: " , longitude));
                  rr=list(latitude,longitude);
 		};
*/
rr)
%include=_tcslen
%include=math_exp
%include=math_pi
%include=math_pow
%include=str_princ
#endregion
​

 

  • The result is 

 

(defun;;;{$N+}
 pp_utm_watermocasin
      ( utmX utmY utmZone / rr latitude longitude len isnorthhemisphere diflat diflon c_sa c_sb e2 e2cuadrada c x y s v a1 a2 j2 j4 j6 alfa beta gama bm epsi eps nab senoheps delt tao zone)
   (setq;|a21124|;
	 latitude 0
	 longitude 0) (setq;|a21178|;
	 len (_tcslen utmZone)) (if (>  len 1) (progn (setq;|a21287|;
	 isNorthHemisphere (substr utmZone len 1)
	 diflat (- 0.00066286966871111111111111111111111111)
	 diflon (- 0.0003868060578)
	 utmZone (substr utmZone 1 (- len 1))) (setq;|a21481|;
	 c_sa 6378137.000000) (setq;|a21508|;
	 c_sb 6356752.314245) (setq;|a21535|;
	 e2 (/ (math_pow (- (math_Pow c_sa 2) (Math_Pow c_sb 2)) 0.5) c_sb)) (setq;|a21650|;
	 e2cuadrada (Math_Pow e2 2)) (setq;|a21697|;
	 c (/ (math_pow c_sa 2) c_sb)) (setq;|a21758|;
	 x (- utmX 500000)) (setq;|a21799|;
	 isNorthHemisphere (if (>  isNorthHemisphere "N") T nil)) (setq;|a21863|;
	 y (if isNorthHemisphere utmY (- utmY 10000000))) (setq;|a21926|;
	 zone (atoi utmZone)) (setq;|a21964|;
	 s (- (* zone 6.0) 183.0)) (setq;|a22019|;
	 lat (/ y (* 6366197.724 0.9996))) (setq;|a22074|;
	 v (* (/ c (math_pow (+ 1 (* e2cuadrada (math_pow (cos lat) 2))) 0.5)) 0.9996)) (setq;|a22204|;
	 a (/ x v)) (setq;|a22245|;
	 a1 (sin (* 2 lat))) (setq;|a22293|;
	 a2 (* a1 (math_pow (cos lat) 2))) (setq;|a22361|;
	 j2 (+ lat (/ a1 2.0))) (setq;|a22416|;
	 j4 (/ (+ (* 3 j2) a2) 4.0)) (setq;|a22485|;
	 j6 (/ (+ (* 5 j4) (* a2 (math_pow (cos lat) 2))) 3.0)) (setq;|a22595|;
	 alfa (* (/ 3.0 4.0) e2cuadrada)) (setq;|a22650|;
	 beta (* (/ 5.0 3.0) (math_pow alfa 2))) (setq;|a22725|;
	 gama (* (/ 35.0 27.0) (math_pow alfa 3))) (setq;|a22800|;
	 bm (* 0.9996 c (- (+ (- lat (* alfa j2)) (* beta j4)) (* gama j6)))) (setq;|a22933|;
	 b (/ (- y bm) v)) (setq;|a22988|;
	 epsi (* (/ (* e2cuadrada (math_pow a 2)) 2.0) (math_pow (cos lat) 2))) (setq;|a23104|;
	 eps (* a (- 1 (/ epsi 3.0)))) (setq;|a23173|;
	 nab (+ (* b (- 1 epsi)) lat)) (setq;|a23242|;
	 senoheps (/ (- (math_exp eps) (Math_Exp (- eps))) 2.0)) (setq;|a23326|;
	 delt (atan (/ senoheps (cos nab)))) (setq;|a23381|;
	 tao (atan (/ (* (cos delt) (sin nab)) (cos nab)))) (setq;|a23464|;
	 longitude (+ (* (/ delt Math_PI) 180) s)) (setq;|a23533|;
	 latitude (* (/ (+ lat (* (- (+ 1 (* e2cuadrada (math_pow (cos lat) 2))) (* (/ 3.0 2.0) e2cuadrada (sin lat) (cos lat) (- tao lat))) (- tao lat))) Math_PI) 180.0)) (str_princ (list "\nLatitud: " latitude "\nLongitud: " longitude)) (setq;|a23835|;
	 rr (list latitude longitude)))) 
rr)
 ;;;{$E}
;Lib:free
​

 

 

You do not have time to learn  Vla*ComTransformer.exe, 

  a) You care

 

 

0 Likes
Message 19 of 40

diagodose2009
Collaborator
Collaborator

Mr GanGanPatel😑; you don~t have time to learn AutoLISP , Clojure, Gimp-Lisp Script,  then 🤝you follow these steps:

  • You create a new file pp_gaganpatel (without extension)

#region

pp_gaganpatel

(Defun pp_gaganpatel( /  rr)

/*c2s:   here math equation...

*/

$rr)

#endregion

  •  You add the file pp_gaganpatel on pp_utmcoosmall.zip
  • You copy the file pp_utmcoosmall.zip to path "C:\Vlaxcompil\cl_aclayer\geomcalc\ " 

or "D:\Vlaxcompil\cl_aclayer\geomcalc\ pp_utmcoosmall.vlax" 

or "E:\Vlaxcompil\cl_aclayer\geomcalc\ "  depends by Windows10.

  • You add the lines

 %include=pp_gaganpatel 

before #endregion from "pp_utm_watermocasin" .

  • e)You rename  the pp_utmcoosmall.zip to pp_utmcoosmall.vlax
  • f)You open a "pp_utmcoosmall.vlax" with transpiler Vlaxco*.exe
  • The downloading link, is inside "-about library" at [bootmark]

Best Regards..God bless you.

ooopss,, I hope in the future do not spam two'messages.

😍If you need other LISP (eg. Gnu Lisp), you simulate the function (setq  inside GnuLisp, and the entire Block MathCode is good.

 

 

 

0 Likes
Message 20 of 40

diagodose2009
Collaborator
Collaborator

bigfoot_pf32bit35-isin.jpg

 

The functions sinous and cosinous are very powerfull inside "jpeg-images":

0 Likes