Kablamtron Posted August 15, 2008 Posted August 15, 2008 Hey, I'm trying to export two selection sets of autocad point co-ordinates to two different txt files. Most of this code was supplied by ASMI (defun c:pls(/ plSet ptLst plSet) (princ"\n<<< Select polyline >>> ") (and (setq plSet (ssget "_:S" '((0 . "LWPOLYLINE")))) (setq ptLst (mapcar '(lambda(x)(trans x 0 1)) (mapcar 'cdr (vl-remove-if-not '(lambda(x)(= 10(car x))) (entget (ssname plSet 0)))))) (sssetfirst nil (setq plSet(ssget "_CP" ptLst))) (sssetfirst nil (setq ss1 (ssget "P" '((-4 . "<OR")(8 . "PNT0808b")(8 . "PNT0808z")(-4 . "OR>"))) )) (sssetfirst nil (setq ss2 (ssget "P" '((8 . "PNT0808b"))) )) (if ss1 (princ (strcat "\n"(itoa(sslength ss1)) " found ") ); end princ (princ "\nNothing found ") );end if ); end and (princ) ); end of c:plset The selection sets I want to export are ss1 and ss2 The problems I have are: 1. How to get the function getfiled to export both selection sets, mabey using it twice? ss1 will be called 1.xyz and ss2 will be called 1.xyb 2. How do I get the selection sets formatted in a usable way. The program I use needs to have the co-ordinates formated like so 4898.260 5011.630 95.500 4898.610 5008.570 95.460 4899.850 5006.170 95.480 4900.530 5003.580 95.530 4900.900 5003.170 95.520 4901.950 4999.660 95.580 I looked at this thread but modifying this code is giving me problems to say the least. http://www.cadtutor.net/forum/showthread.php?t=9628&highlight=export+point+co-ordinates+txt Anything you guys can do would help even calling me stupid if the solution is simple Thanks kablam Quote
Kablamtron Posted August 15, 2008 Author Posted August 15, 2008 Update got some of it working! (defun c:pls(/ plSet ptLst plSet file points c i) (princ"\n<<< Select polyline >>> ") (and (setq plSet (ssget "_:S" '((0 . "LWPOLYLINE")))) (setq ptLst (mapcar '(lambda(x)(trans x 0 1)) (mapcar 'cdr (vl-remove-if-not '(lambda(x)(= 10(car x))) (entget (ssname plSet 0)))))) (sssetfirst nil (setq plSet(ssget "_CP" ptLst))) ;SEPERATOR (sssetfirst nil (setq ss1 (ssget "P" '((-4 . "<OR")(8 . "*b")(8 . "*z")(-4 . "OR>"))))) ;SEPERATOR _____________________________________|; ;POints to TeXT (setq file (open (getfiled "specify output file" "c:/Data08/" "xyz" 1) "w")) (setq points (ssget) ss1 0) (repeat (sslength points) (if (= "POINT" (cdr (assoc 0 (entget (ssname points ss1))))) (setq c (cdr (assoc 10 (entget (ssname points ss1)))) ss1 (1+ ss1) ) ) (write-line (strcat (rtos (car c)) " " (rtos (cadr c)) " " (rtos (caddr c)) ) file) ) (close file) ;SEPERATOR (sssetfirst nil (setq ss2 (ssget "P" '((8 . "*b"))))) ;SEPERATOR (setq file1 (open (getfiled "specify output file" "c:/Data08/" "xyb" 1) "w")) (setq points1 (ssget) ss2 0) (repeat (sslength points1) (if (= "POINT" (cdr (assoc 0 (entget (ssname points1 ss2))))) (setq c1 (cdr (assoc 10 (entget (ssname points1 ss2)))) ss2 (1+ ss2) ) ) (write-line (strcat (rtos (car c1)) " " (rtos (cadr c1)) " " (rtos (caddr c1)) ) file1) ) (close file1) (if ss2 (princ (strcat "\n"(itoa(sslength ss2)) " found ") ); end princ (princ "\nNothing found ") );end if ); end and (Princ) ); end of c:plset 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.