Jump to content

Recommended Posts

Posted (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 by rkmcswain
added CODE tags
Posted

sir i cant under stand what is the answer & how to set

Posted (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 by pBe
Posted

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)
)

Posted

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.

Posted
Sir Lee Mac's code was helpful

 

Got yourself on the New Years Honours List Lee?? :thumbsup:

You'll have to change your Avatar now, perhaps with a lance on your bike

Posted
Got yourself on the New Years Honours List Lee?? :thumbsup:

 

lol I wish! :P

 

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...

  • 4 weeks later...
Posted

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...?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...