help Crete lisp

help Crete lisp

chan230984
Advocate Advocate
941 Views
8 Replies
Message 1 of 9

help Crete lisp

chan230984
Advocate
Advocate

Hi, all .

help Create lisp please, i want to click POLYLINE and get NE and sent to Excel or Notepad

thanks

 

Untitled.png

0 Likes
Accepted solutions (1)
942 Views
8 Replies
Replies (8)
Message 2 of 9

dlanorh
Advisor
Advisor
Accepted solution

Try this.

 

(defun rh:sammlung_n (o_lst grouping / tmp n_lst)
	(setq n_lst nil)
	(if (= (rem (length o_lst) grouping) 0)
		(while o_lst
			(while (< (length tmp) grouping)
				(setq tmp (cons (car o_lst) tmp)
							o_lst (cdr o_lst)
				);end_setq
			);end_while
			(setq n_lst (cons (reverse tmp) n_lst) 
						tmp nil
			);end_setq
		);end_while
		(princ "\nModulus Error : The passed list length is not exactly divisible by the group size!!")
	);end_if
  (reverse n_lst)
);end_defun


(defun c:gpc ( / obj o_type c_lst t_file fp )
	(setq obj (vlax-ename->vla-object (car (entsel "\nSelect Polyline : "))))
  (cond ( (wcmatch (setq o_type (vlax-get-property obj 'objectname)) "*Polyline")
          (setq n (if (wcmatch o_type "*3d*") 3 2)
                c_lst (rh:sammlung_n (vlax-get obj 'coordinates) n)
                t_file (vl-filename-mktemp "Polyline" (getvar 'dwgprefix) ".csv")
                fp (open t_file "w")
          );end_setq
          (foreach v c_lst
            (setq p_str (strcat "N=" (rtos (cadr v) 2 3) ", E=" (rtos (car v) 2 3)))
            (write-line p_str fp)
          );end_foreach
          (close fp)          
        )
        ( (alert "Not a Polyline"))
  );end_cond      
);end_defun

Type gpc to run

I am not one of the robots you're looking for

0 Likes
Message 3 of 9

chan230984
Advocate
Advocate

When select Polyline:

 

Command: (LOAD "C:/Users/CHAN/Desktop/sammlung_n.LSP") C:GPC
Command: GPC
Select Polyline : nil
Command:

 

Untitled.png

0 Likes
Message 4 of 9

dlanorh
Advisor
Advisor

sammlung_n is the name of a subroutine to sort the coordinates into a list

 

Copy code, past into notepad and save to file somewhere in your autocad path. You choose the filename.

 

Command: APPLOAD <enter>

 

Navigate to where you saved the file, select and press load button. Press the close button.

 

Command : gpc <enter>

 

Should ask you to select a polyline. Creates a csv file in the same directory as the drawing. Double click this file and it will open in Excel

 

Link to detailed explanation - http://www.lee-mac.com/runlisp.html

I am not one of the robots you're looking for

0 Likes
Message 5 of 9

chan230984
Advocate
Advocate

Yes it's

when i Command : gpc <enter> and select Polyline

Command :

Select Polyline : nil

0 Likes
Message 6 of 9

dlanorh
Advisor
Advisor

That is correct.

Go to drawing folder and look for "polyl###.csv" file. Double click and it will open in excel.

I am not one of the robots you're looking for

Message 7 of 9

chan230984
Advocate
Advocate

Hi @dlanorh 

Help me a little more

I want the E value in front of N

THANK YOU '

 

Untitled.png

0 Likes
Message 8 of 9

dlanorh
Advisor
Advisor
(defun rh:sammlung_n (o_lst grouping / tmp n_lst)
	(setq n_lst nil)
	(if (= (rem (length o_lst) grouping) 0)
		(while o_lst
			(while (< (length tmp) grouping)
				(setq tmp (cons (car o_lst) tmp)
							o_lst (cdr o_lst)
				);end_setq
			);end_while
			(setq n_lst (cons (reverse tmp) n_lst) 
						tmp nil
			);end_setq
		);end_while
		(princ "\nModulus Error : The passed list length is not exactly divisible by the group size!!")
	);end_if
  (reverse n_lst)
);end_defun


(defun c:gpc ( / obj o_type c_lst t_file fp )
	(setq obj (vlax-ename->vla-object (car (entsel "\nSelect Polyline : "))))
  (cond ( (wcmatch (setq o_type (vlax-get-property obj 'objectname)) "*Polyline")
          (setq n (if (wcmatch o_type "*3d*") 3 2)
                c_lst (rh:sammlung_n (vlax-get obj 'coordinates) n)
                t_file (vl-filename-mktemp "Polyline" (getvar 'dwgprefix) ".csv")
                fp (open t_file "w")
          );end_setq
          (foreach v c_lst
            (setq p_str (strcat "E=" (rtos (car v) 2 3) ", N=" (rtos (cadr v) 2 3)))
            (write-line p_str fp)
          );end_foreach
          (close fp)          
        )
        ( (alert "Not a Polyline"))
  );end_cond      
);end_defun

As requested. Enjoy. Robot Happy

I am not one of the robots you're looking for

Message 9 of 9

chan230984
Advocate
Advocate

@dlanorh  Thanks again

0 Likes