skipo4us Posted March 18, 2008 Posted March 18, 2008 Can anybody provides me with an Autolisp program that can extract heights from a 3D polyline at specified distances and the result (elevations) to be displayed in a txt file (text editor)? (in any version of AutoCAD) Quote
VVA Posted March 19, 2008 Posted March 19, 2008 height is coordinate Z? ;------------ RUS ------------------------------------------------ ; Точка лежащая от точки P1 на расстоянии L в направлении точки P2 ;----------------------------------------------------------------- ;Параметры: ;p1 - первая точка ;p2 - точка в направлении которой откладывается расстояние ;L - расстояние ;------------ EN -------------------------------------------- ;Point laying from point P1 on distance L in a direction of point P2 ; ; Parameters: ; p1 - the first point ; p2 - the point in which direction is postponed distance ; L - distance (defun 3d_polarp (P1 P2 L) (setq L (/ L (distance P1 P2))) (mapcar '+ P1 (mapcar '(lambda (V) (* V L)) (mapcar '- P2 P1))) ) ;;Get coors from 3d polyline ;; pline - ename 3d polyline (defun _get_coors_3dpoly ( pline / tmp_ent coors ent_data) (setq tmp_ent pline) (while (/= "SEQEND" (cdr(assoc 0 (setq ent_data (entget(setq tmp_ent (entnext tmp_ent))))))) (setq coors (cons (cdr (assoc 10 ent_data)) coors)) );_while (reverse coors) ) ;;;Test command ;;Get Coordinates of a point on the specified distance from each vertex 3d polylines (defun C:TEST (/ dst pl coors point_list filPath cFile oFlag) (initget 1) (if (and (setq dst (getdist "\nSpecify distance: ")) (setq pl (car (entsel "\nPick a 3d polyline: "))) (member '(100 . "AcDb3dPolyline") (entget pl)) ) ;_ end of and (progn (setq coors (_get_coors_3dpoly pl)) (setq point_list (mapcar '(lambda (P1 P2) (3d_polarp P1 P2 dst) ) ;_ end of lambda coors (cdr coors) ) ;_ end of mapcar ) ;_ end of setq ;;;Export Data to Text File (setq filPath (getfiled "Save Coordinates to Text File" "Coordinates.txt" "txt;csv" 33 ) ;_ end of getfiled ) ;_ end of setq (setq cFile (open filPath "w")) (foreach ln point_list (write-line (strcat (rtos (car ln)) "," (rtos (cadr ln)) (if (= 3 (length ln)) (strcat "," (rtos (nth 2 ln))) ) ;_ end of if ) ;_ end of strcat cFile ) ;_ end of write-line ) ;_ end of foreach (close cFile) (initget "Yes No") (setq oFlag (getkword "\nOpen text file? [Yes/No] <No> : ")) (if (= oFlag "Yes") (startapp "notepad.exe" filPath) ) ;_ end of if ) ;_ end of progn (alert "Not a 3d polyline") ) ;_ end of if (princ) ) ;_ end of defun Type TEST in command line to execute Quote
skipo4us Posted March 22, 2008 Author Posted March 22, 2008 Thanks so much VVA, I appreciate ur response. But, the code is giving only cordinates of two points, not cordinates of all the specified points (at given distances). Please adjust the code to output the cordinates of all the specified points. Thank you for coperation Quote
VVA Posted March 24, 2008 Posted March 24, 2008 The command exports all coordinates of points on the specified distance from each vertex of polyline. Give an example polyline and points which coordinates are necessary for exporting that it is better to understand a problem Quote
skipo4us Posted March 25, 2008 Author Posted March 25, 2008 Thanks, VVA, I'll test the codes now and feed you back soonest Quote
cartographer Posted June 18, 2015 Posted June 18, 2015 My question would be : how to get this code to work ?! (I've heard of it, but never used LISP before...) Quote
Lee Mac Posted June 18, 2015 Posted June 18, 2015 My question would be : how to get this code to work ?! (I've heard of it, but never used LISP before...) http://www.lee-mac.com/runlisp.html http://www.cadtutor.net/forum/showthread.php?1390-How-to-use-the-LISP-routines-in-this-archive Quote
cartographer Posted June 25, 2015 Posted June 25, 2015 http://www.lee-mac.com/runlisp.html http://www.cadtutor.net/forum/showthread.php?1390-How-to-use-the-LISP-routines-in-this-archive Lee - I love You 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.