Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/08/2019 in all areas

  1. I probably should add (vl-load-com) to every file. Also remove the "alert" line once paths are changed, it just so many times people do not understand that the code must be changed to save the file. Ps (command "_START" "EXCEL C:/yourdiredctory/yourfilename.csv") will open the file
    1 point
  2. Put (vl-load-com) At the top of Al's file and reload, unless you are running on a MAC. If you are going to use lisp, it might be an idea to put this into one of the lisps that load automatically when AutoCAD starts, that way it is always there.
    1 point
  3. (startapp "EXPLORER" fname ) ;; open full path fname using its default app FWIW If what you mean similar without COM API, normally just use command START or SHELL (command "_START" "EXCEL")
    1 point
  4. Can't you open the file in excel using (startapp "excel.exe" fname) or something similar? The braincell is telling me there is a method but I can't put my finger on it at the moment.
    1 point
  5. Thanks guys not sure how I missed that.
    1 point
  6. oops.. thanks If OP knows EXCEL well, just get it sorted in opened csv file select range (example=$A$1:$C$6) -> insert Table -> sort A-Z at column 'length' -> renumber 'column 'Rank'
    1 point
  7. Missing the "sort by length" ascending
    1 point
  8. ;(setq fo (open (setq fname "C:\\yourdiredctory\\yourfilename.csv") "w")) ;(write-line "Rank,Length,Type" fo) ;(repeat (setq x (length lst)) ;(setq ans (nth (setq x (- x 1)) lst)) ;(write-line (strcat (rtos y 2 0) "," (car ans) "," (rtos (cadr ans) 2 2)) fo) ;(setq y (+ y 1)) ;) ;(close fo) @BIGAL just notice you have commented ";" in your code , that's why it doesn't write file here's another quick & dirty using vlax-curve- function (defun c:CA (/ *error* l ls f fn i ss fn) (defun *error* (msg) (if (= (type f) 'FILE) (close f) ) (terpri) ) (if (and (setq i 0 ss (ssget "_X" (list '(0 . "ARC,CIRCLE") (cons 410 (getvar 'CTAB)))) ) (setq ls (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))));(acet-ss-to-list ss)) (setq fn (vl-filename-mktemp "CA.csv")) (setq f (open fn "W")) (write-line "Rank,Length,Type" f) ) (progn (setq i 0 l (mapcar ''((x) (list (vlax-curve-getDistAtParam x (vlax-curve-getEndParam x)) (cdr (assoc 0 (entget x)))) ) ls ) ls (vl-sort l ''((a b) (< (car a) (car b)))) ) (foreach x ls (write-line (apply 'strcat (mapcar ''((x) (strcat x ",")) (list (itoa (setq i (1+ i))) (rtos (car x) 2) (cadr x))) ) f ) ) (if (= (type f) 'FILE) (close f) ) (vl-cmdf "_START" fn) ) (princ "\nOops.. Nothing?") ) (princ) )
    1 point
  9. Try this you need to set up the correct file path for output, makes a csv file open in excel. Remove the remark ; to run once path is set. (defun c:test ( / x y lay lst fo ) (setq lay (vla-get-layer (vlax-ename->vla-object (car (entsel "Pick Arc.circ for layer"))))) (setq ss (ssget (list (cons 0 "Arc,circle")(cons 8 lay)))) (setq lst '()) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (if (= (vla-get-objectname obj) "AcDbCircle") (progn (setq len (vla-get-circumference obj)) (setq id "Circle") ) (progn (setq len (vla-get-arclength obj)) (setq id "ARC") ) ) (setq lst (cons (list id len) lst)) ) (setq lst (vl-sort lst '(lambda (x y) (< (cadr x)(cadr y))) )) (alert "ok now write a csv file you must change path below") (setq lst (reverse lst)) (setq y 1) (setq fo (open (setq fname "C:\\yourdiredctory\\yourfilename.csv") "w")) (write-line "Rank,Length,Type" fo) (repeat (setq x (length lst)) (setq ans (nth (setq x (- x 1)) lst)) (write-line (strcat (rtos y 2 0) "," (car ans) "," (rtos (cadr ans) 2 2)) fo) (setq y (+ y 1)) ) (close fo) ) (vl-load-com) (c:test)
    1 point
×
×
  • Create New...