乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: Cristi_an_24

[编程交流] Lisp在GP之间绘制一条线

[复制链接]

1

主题

8

帖子

7

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:14:27 | 显示全部楼层
谢谢克里斯蒂安,我修改了更多的第三个代码-更好地找到在北半球相交的实体(Surfculpt是在区域和北半球表面之间)。。。尽管有了GPS坐标,我还是无法将PLINE转换为区域,但有了其他一些(更大的角度)它就可以完成这项工作。。。
 
  1. (setq c (* 2 (atan (sqrt a) (sqrt [color=red](- 1 a)[/color]))))

 
M、 R。
所以当你拿到2012年的时候,你可能会这样研究。。。
gpsareasph new new new。lsp
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 08:17:09 | 显示全部楼层
***问题已解决***
这正是你应该得到的:
GPS坐标之间的面积为:741875.0平方米
 
这是我最后一段也是最有效的代码——当然只适用于一个地球半球,我认为它适用于2011年及以后的版本。。。2012年测试。。。
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;                                                                                 ;;;
  3. ;;; gpspronsph function takes GPS coordinates from CSV file,                        ;;;
  4. ;;; and project between points edges as arcs on sphere with radius of planet Earth. ;;;
  5. ;;;                                                                                 ;;;
  6. ;;; 25.07.2012. Marko Ribar, d.i.a. - first and final release                       ;;;
  7. ;;;                                                                                 ;;;
  8. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  9. (defun c:gpspronsph ( / file f csvrow Latt Long gpsdata ER ptx pty ptz pt ptlst k p1 p2 pm pmv1 pmsph )
  10. (vl-cmdf "_.UCS" "w")
  11. (if (ssget "_X")
  12.    (progn
  13.      (alert "\nDWG must be empty - empty it and start over")
  14.      (exit)
  15.    )
  16. )
  17. (setq file (getfiled "Select file with GPS coordiantes" "" "csv" 2))
  18. (setq f (open file "r"))
  19. (while (setq csvrow (read-line f))
  20.    (setq Latt (substr csvrow 1 (vl-string-position (ascii ",") csvrow)))
  21.    (setq Long (substr csvrow (+ (vl-string-position (ascii ",") csvrow) 2) (- (strlen csvrow) (vl-string-position (ascii ",") csvrow) 1)))
  22.    (setq gpsdata (cons (list (read Latt) (read Long)) gpsdata))
  23. )
  24. (setq gpsdata (reverse gpsdata))
  25. (setq ER 6371000.0) ; Radius of Earth in m
  26. (foreach gps gpsdata
  27.    (setq Latt (car gps))
  28.    (setq Long (cadr gps))
  29.    (setq ptx (* ER (cos (cvunit Latt "degrees" "radians")) (cos (cvunit Long "degrees" "radians"))))
  30.    (setq pty (* ER (cos (cvunit Latt "degrees" "radians")) (sin (cvunit Long "degrees" "radians"))))
  31.    (setq ptz (* ER (sin (cvunit Latt "degrees" "radians"))))
  32.    (setq pt (list ptx pty ptz))
  33.    (setq ptlst (cons pt ptlst))
  34. )
  35. (setq ptlst (reverse ptlst))
  36. (setq k -1)
  37. (repeat (length ptlst)
  38.    (setq p1 (nth (setq k (1+ k)) ptlst))
  39.    (if (/= k (- (length ptlst) 1))
  40.      (setq p2 (nth (+ k 1) ptlst))
  41.      (setq p2 (car ptlst))
  42.    )
  43.    (setq pm (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p1 p2))
  44.    (setq pmv1 (mapcar '(lambda ( a ) (/ a (distance '(0.0 0.0 0.0) pm))) pm))
  45.    (setq pmsph (mapcar '(lambda ( a ) (* a ER)) pmv1))
  46.    (vl-cmdf "_.UCS" "3" '(0.0 0.0 0.0) p1 p2)
  47.    (vl-cmdf "_.ARC" (trans p1 0 1) "s" (trans pmsph 0 1) (trans p2 0 1))
  48.    (vl-cmdf "_.UCS" "p")
  49. )
  50. (vl-cmdf "_.ZOOM" "_E")
  51. (princ)
  52. )

 
致以崇高的敬意,
M、 R。
gpsareasph new new new。lsp
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 08:22:10 | 显示全部楼层
非常感谢,你的lisp很灵活,我也在写lisp,但我的还处于初级水平,我还在学习,但你的lisp远超我,出于我自己的好奇心,为什么你必须使用“z”坐标?这就是公式的工作原理吗?或者你真的需要一个“z”?
我已经检查了你的立体图,计算很完美,从我的手机上我只能得到周长:5888.34米。
 
最好的口哨,
克里斯蒂安
 
 
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 08:23:39 | 显示全部楼层
克里斯蒂安,谢谢你的评论,不过我必须指出,画弧的lsp是可以的。。。你总是可以用它来获得长度-距离。。。但获取区域的lsp很难预测2个GPS坐标附近的天气角度是大还是小,所以我建议2011年或+并使用我的两个代码-第四个用于大角度,第五个用于小角度,就像你的情况一样。。。我认为将它们结合到sinlge代码中并不是一个很好的解决方案,但可能存在这样的情况,即既有大角度,也有小角度-在这种情况下,你必须找到中间解,并且只需要ACAD将pline转换为区域。。。
 
M、 R。
回复

使用道具 举报

1

主题

8

帖子

7

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:27:54 | 显示全部楼层
回复

使用道具 举报

1

主题

8

帖子

7

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:28:44 | 显示全部楼层
 
 
Thanks Marko,
 
I have tried all your codes, but this one works the best for me, since I have just Autocad 2009, and as you said, your last code does not work for me yet, maybe in one day when I will have 2012 version.
 
Thanks again,
Cristian
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 08:32:57 | 显示全部楼层
Thanks Cristian, I've modified further more 3rd code - better finding solid to intersect with on north hemisphere (SURFSCULPT is between regions and north dome surface)... Still with your GPS coordinates I can't convert PLINES into REGIONS, but with some other (larger angles) it does the job...
 
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                                                                 ;;;;;; gpsareasph function takes GPS coordinates from CSV file,                        ;;;;;; and project between points edges as arcs on sphere with radius of planet Earth, ;;;;;; determines contour shape of peace of ground,                                    ;;;;;; for witch if finds approx. correct area value.                                  ;;;;;; 30.07.2012. Marko Ribar, d.i.a. - fourth and final release                      ;;;;;; *** use this code for large distances between GPS coordinates ***               ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(vl-load-com)(defun c:gpsareasph ( / osm file f csvrow Latt Long gpsdata ER ptx pty ptz pt ptlst sph1 sph2 sph k ss p1 p2 ar ) (vl-cmdf "_.UCS" "w") (if (ssget "_X")   (progn      (alert "\nDWG must be empty - empty it and start over")     (exit)   ) ) (setq osm (getvar 'osmode)) (setvar 'osmode 0) (setq file (getfiled "Select file with GPS coordiantes" "" "csv" 2)) (setq f (open file "r")) (while (setq csvrow (read-line f))   (setq Latt (substr csvrow 1 (vl-string-position (ascii ",") csvrow)))   (setq Long (substr csvrow (+ (vl-string-position (ascii ",") csvrow) 2) (- (strlen csvrow) (vl-string-position (ascii ",") csvrow) 1)))   (setq gpsdata (cons (list (read Latt) (read Long)) gpsdata)) ) (setq gpsdata (reverse gpsdata)) (setq ER 6371000.0) ; Radius of Earth in m  (foreach gps gpsdata   (setq Latt (car gps))   (setq Long (cadr gps))   (setq ptx (* (* ER 2.0) (cos (cvunit Latt "degrees" "radians")) (cos (cvunit Long "degrees" "radians"))))   (setq pty (* (* ER 2.0) (cos (cvunit Latt "degrees" "radians")) (sin (cvunit Long "degrees" "radians"))))   (setq ptz (* (* ER 2.0) (sin (cvunit Latt "degrees" "radians"))))   (setq pt (list ptx pty ptz))   (setq ptlst (cons pt ptlst)) ) (setq ptlst (reverse ptlst)) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) ER) (setq sph1 (entlast)) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (- ER 1e-4)) (setq sph2 (entlast)) (vl-cmdf "_.SUBTRACT" sph1 "" sph2 "") (setq sph (entlast)) (vl-cmdf "_.PLAN" "") (setq k -1) (setq ss (ssadd)) (repeat (length ptlst)   (setq p1 (nth (setq k (1+ k)) ptlst))   (if (= k (- (length ptlst) 1)) (setq p2 (nth 0 ptlst)) (setq p2 (nth (1+ k) ptlst)))   (vl-cmdf "_.UCS" "3" '(0.0 0.0 0.0) p1 p2)   (vl-cmdf "_.PLINE" '(0.0 0.0 0.0) (trans p1 0 1) (trans p2 0 1) "c")   (vl-cmdf "_.REGION" (entlast) "")   (ssadd (entlast) ss)   (vl-cmdf "_.UCS" "_P") ) (vl-cmdf "_.ZOOM" "_E") (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (* ER 1.25)) (vl-cmdf "_.CONVTOSURFACE" (entlast) "") (vl-cmdf "_.SLICE" (entlast) "" "XY" "" "") (entdel (entlast)) (ssadd (entlast) ss) (vl-cmdf "_.SURFSCULPT" ss "") (vl-cmdf "_.INTERSECT" sph (entlast) "") (vl-cmdf "_.ZOOM" "_E") (vl-cmdf "_.AREA" "o" (entlast) "") (setq ar (getvar 'area)) (setq ar (/ ar 2.0) (prompt "\nArea between GPS coordinates is : ") (princ ar) (prompt " square meters") (setvar 'osmode osm) (princ))
 
M.R.
So maybe when you get A2012, you'll look into this way...
gpsareasph-new-new-new.lsp
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 08:37:29 | 显示全部楼层
*** PROBLEM SOLVED ***
This is exactly what you should get :
Area between GPS coordinates is : 741875.0 square meters
 
Here is my last and the most efficient code - of course only for one Earth hemisphere and works I think for A2011 and +... Tested on A2012...
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                                                                 ;;;;;; gpsareasph function takes GPS coordinates from CSV file,                        ;;;;;; and project between points edges as arcs on sphere with radius of planet Earth, ;;;;;; determines contour shape of peace of ground,                                    ;;;;;; for witch if finds approx. correct area value.                                  ;;;;;; 31.07.2012. Marko Ribar, d.i.a. - fifth and final release                       ;;;;;; *** improved possibility of making REGION objects ***                           ;;;;;; *** use this code for small distances between GPS coordinates ***               ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(vl-load-com)(defun c:gpsareasph ( / osm file f csvrow Latt Long gpsdata ER pt1x pt1y pt1z pt1 pt1lst pt2x pt2y pt2z pt2 pt2lst sph1 sph2 sph k ss p1 p2 p3 p4 ar ) (vl-cmdf "_.UCS" "w") (if (ssget "_X")   (progn      (alert "\nDWG must be empty - empty it and start over")     (exit)   ) ) (setq osm (getvar 'osmode)) (setvar 'osmode 0) (setq file (getfiled "Select file with GPS coordiantes" "" "csv" 2)) (setq f (open file "r")) (while (setq csvrow (read-line f))   (setq Latt (substr csvrow 1 (vl-string-position (ascii ",") csvrow)))   (setq Long (substr csvrow (+ (vl-string-position (ascii ",") csvrow) 2) (- (strlen csvrow) (vl-string-position (ascii ",") csvrow) 1)))   (setq gpsdata (cons (list (read Latt) (read Long)) gpsdata)) ) (setq gpsdata (reverse gpsdata)) (setq ER 6371000.0) ; Radius of Earth in m  (foreach gps gpsdata   (setq Latt (car gps))   (setq Long (cadr gps))   (setq pt1x (* (* ER 1.02) (cos (cvunit Latt "degrees" "radians")) (cos (cvunit Long "degrees" "radians"))))   (setq pt1y (* (* ER 1.02) (cos (cvunit Latt "degrees" "radians")) (sin (cvunit Long "degrees" "radians"))))   (setq pt1z (* (* ER 1.02) (sin (cvunit Latt "degrees" "radians"))))   (setq pt1 (list pt1x pt1y pt1z))   (setq pt1lst (cons pt1 pt1lst))   (setq pt2x (* (* ER 0.98) (cos (cvunit Latt "degrees" "radians")) (cos (cvunit Long "degrees" "radians"))))   (setq pt2y (* (* ER 0.98) (cos (cvunit Latt "degrees" "radians")) (sin (cvunit Long "degrees" "radians"))))   (setq pt2z (* (* ER 0.98) (sin (cvunit Latt "degrees" "radians"))))   (setq pt2 (list pt2x pt2y pt2z))   (setq pt2lst (cons pt2 pt2lst)) ) (setq pt1lst (reverse pt1lst)) (setq pt2lst (reverse pt2lst)) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) ER) (setq sph1 (entlast)) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (- ER 1e-4)) (setq sph2 (entlast)) (vl-cmdf "_.SUBTRACT" sph1 "" sph2 "") (setq sph (entlast)) (vl-cmdf "_.PLAN" "") (setq k -1) (setq ss (ssadd)) (repeat (length pt1lst)   (setq p1 (nth (setq k (1+ k)) pt1lst))   (if (= k (- (length pt1lst) 1)) (setq p2 (nth 0 pt1lst)) (setq p2 (nth (1+ k) pt1lst)))   (setq p3 (nth k pt2lst))   (if (= k (- (length pt2lst) 1)) (setq p4 (nth 0 pt2lst)) (setq p4 (nth (1+ k) pt2lst)))   (vl-cmdf "_.UCS" "3" p1 p2 p3)   (vl-cmdf "_.PLINE" (trans p1 0 1) (trans p2 0 1) (trans p4 0 1) (trans p3 0 1) "c")   (vl-cmdf "_.REGION" (entlast) "")   (ssadd (entlast) ss)   (vl-cmdf "_.UCS" "_P") ) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (* ER 1.01)) (vl-cmdf "_.CONVTOSURFACE" (entlast) "") (vl-cmdf "_.SLICE" (entlast) "" "XY" "" "") (entdel (entlast)) (ssadd (entlast) ss) (vl-cmdf "_.SPHERE" '(0.0 0.0 0.0) (* ER 0.99)) (vl-cmdf "_.CONVTOSURFACE" (entlast) "") (vl-cmdf "_.SLICE" (entlast) "" "XY" "" "") (entdel (entlast)) (ssadd (entlast) ss) (vl-cmdf "_.SURFSCULPT" ss "") (vl-cmdf "_.INTERSECT" sph (entlast) "") (vl-cmdf "_.ZOOM" "_E") (vl-cmdf "_.AREA" "o" (entlast) "") (setq ar (getvar 'area)) (setq ar (/ ar 2.0)) (prompt "\nArea between GPS coordinates is : ") (princ ar) (prompt " square meters") (setvar 'osmode osm) (princ))
 
Many regards,
M.R.
gpsareasph-new-new-new-new.lsp
回复

使用道具 举报

1

主题

8

帖子

7

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:39:12 | 显示全部楼层
Thank you very much, your lisp's are briliant, i am writing lisp's as well, but mine are just at beginer level, I am still learning, but your lisp's are way above me, for my own curiosity, why did you had to use a "z" coordinate? is this how the formula works? or you really need a "z"?
I have checked your solid, and the calculation is perfect, from my phone I can get only the perimeter which is: 5888.34m.
 
Best whishes,
Cristian
 
 
084111fomjpayacmmjj18z.jpg
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 08:42:36 | 显示全部楼层
Cristian, thank you for your comments, however I have to point that lsp for drawing arcs is OK... You can always use it to get lengths - distances... But lsp for getting area is difficult to predict weather angles between 2 near GPS coordinates are going to be large or small, so I suggest A2011 or + and using both of mine codes - fourth for large angles, and  fifth for small as in your case... I think that combine them into sinlge code isn't soo good solution, but there maybe cases where you have both large angles and also small - in this case you have to find middle solution and only prey that ACAD will convert plines to regions...
 
M.R.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-9 21:42 , Processed in 0.999126 second(s), 83 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表