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