Hari Prashanth Posted January 5, 2011 Posted January 5, 2011 (edited) Hi all... Im using autolisp to extract the coordinates out of a 2D figure to an excel file. I've to follow some conditions regarding the figures... 1. The figure must be in posotive quardrant only. 2. The coordinate extraction must always start from the origin .ie (0,0). Here s procedure i m following... 1.Ill draw the figure. 2.Divide it into many nodes with 'divide' command. 3.Load the following lisp to extract the coordinates in a spreadsheet. ;;;Select points and export their co-ords to *.csv file ;;;Written by ssg - October 23th, 2007 ;;;========================================= (defun C:EPEX(/ ss fn f e p) (prompt "\nSelect points to export:") (if not (setq ss (ssget '((0 . "POINT")))) (progn (alert "No objects selected!") (quit)) ) (if (not (setq fn (getfiled "Export to file" (getvar "dwgprefix") "csv" 1))) (progn (alert "No file selected!") (quit)) ) (setq f (open fn "w")) (while (setq e (ssname ss 0)) (setq p (cdr (assoc 10 (entget e)))) (princ (strcat (rtos (car p)) "," (rtos (cadr p)) "," (rtos (caddr p)) "\n") f) (ssdel e ss) ) (close f) (alert (strcat "Finish export points to file: " fn)) ) ;;;========================================= Ive enclosed a sample figure too... I would be grateful for any suggestions. Pls help. pent.dwg Edited January 5, 2011 by rkmcswain added CODE tags Quote
shoaib Posted January 9, 2011 Posted January 9, 2011 sir i cant under stand what is the answer & how to set Quote
pBe Posted January 9, 2011 Posted January 9, 2011 (edited) Nice Only thing i can see is what if you accidentally select "points" of negative value... it will still be written to the csv file. Make a condition to ignore those, it would be fun to code that, not hard, but fun and also while your writing your condtion, if half of your points is on the negative quadrant you'll only get half of what you need. so think about that too. and to make it more challenging for you, select every points randomly but still get the points in the right order. good luck Welcome to the forum and have fun Edited January 9, 2011 by pBe Quote
Lee Mac Posted January 9, 2011 Posted January 9, 2011 The filter for the positive quadrant could be incorporated directly into the SelectionSet filter list hence: (defun c:test ( / ss wf i p ) ;; © Lee Mac 2011 (cond ( (and (setq ss (ssget '((0 . "POINT") (-4 . ">=,>=,*") (10 0.0 0.0 0.0)))) (setq wf (getfiled "" "" "csv" 1)) (setq wf (open wf "w")) ) (repeat (setq i (sslength ss)) (setq p (cdr (assoc 10 (entget (ssname ss (setq i (1- i))))))) (write-line (strcat (rtos (car p)) "," (rtos (cadr p)) "," (rtos (caddr p))) wf) ) (close wf) (princ (strcat "\n--> " (itoa (sslength ss)) " Points Written to file.")) ) ) (princ) ) Quote
Hari Prashanth Posted January 10, 2011 Author Posted January 10, 2011 Thank u all for your suggestions. Sir Lee Mac's code was helpful but i think i didnt put the question properly... The coordinate extraction... -must start from the origin -proceed along the line -proceed along the pentagon -And finish at the same point where the line meets the figure or one node before that. Quote
Tyke Posted January 10, 2011 Posted January 10, 2011 Sir Lee Mac's code was helpful Got yourself on the New Years Honours List Lee?? You'll have to change your Avatar now, perhaps with a lance on your bike Quote
Lee Mac Posted January 10, 2011 Posted January 10, 2011 Got yourself on the New Years Honours List Lee?? lol I wish! Thank u all for your suggestions. Sir Lee Mac's code was helpful but i think i didnt put the question properly... The coordinate extraction... Glad my code could help - I didn't look at the file, only read the description... Quote
Hari Prashanth Posted February 7, 2011 Author Posted February 7, 2011 Ive been waiting for so long to get any suggestions for ma querry... Y cant any 'Senior Member' or 'Quantum Mechanic' give any...? Is s that tough to crack...? Uh... Is t...? 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.