Jump to content

AutoLisp program for storing points in a text format


prny90

Recommended Posts

hello,

I am trying to write a lisp program to get the coordinates of the points on a parabolic profile at every one mm distance. this points must be stored in to a text file so that it can be given as input for my machine.

 

please help me in this regard.

Link to comment
Share on other sites

Take a look at Lee Mac's signature (if you are lucky, he'll come along and say hi) for the Point Manager - that might help you.

Link to comment
Share on other sites

thanks guys the measure works :-)

Using measure you will loose both end points

Try this out:

(vl-load-com)
;;==============================================;;
(defun C:EXPOINTS (/ *error* cnt datafile dimz en end filename obj param pt ptlist sset start step)
 (defun *error* (msg)
   (if datafile (close datafile))
   (if dimz (setvar "dimzin" dimz))
   (if msg (princ (strcat "\nError! " msg)))
   (princ)
   )

 (setq dimz (getvar "dimzin"))
 (setvar "dimzin" 2);<-- change to suit

;;==============================================;;

(setq filename (strcat (getvar "dwgprefix")
       (vl-filename-base (getvar "dwgname"))".txt")
)
(prompt "\n  >> Select polyline  >>")
 (if
   (setq sset (ssget "+.:S:E" (list (cons 0 "LWPOLYLINE,SPLINE"))))
    (progn
      (setq datafile (open filename "W"))
      (initget 6)
      (setq step (getreal "\n Enter step <10>: "))
      (if (not step)(setq step 10))
      (setq en (ssname sset 0)      
     obj (vlax-ename->vla-object en)
     leng (vla-get-length obj)
     )
      (setq cnt -1
     start 0
     )

      (while (<= (setq dist (* (setq cnt (1+ cnt)) step)) leng)
      (setq param
      (vl-catch-all-apply (function (lambda()
  (vlax-curve-getparamatdist obj dist))
        )
        )
    )
 (setq pt (vlax-curve-getclosestpointto obj
     (vlax-curve-getpointatparam obj param)
     )
       )
 (setq ptlist (cons pt ptlist)
       )
 )

      (if (not (equal (car ptlist)(setq end (vlax-curve-getendpoint obj)) 0.00001))
 (setq ptlist (cons end ptlist))
 )
 (setq ptlist (reverse ptlist )
     )

      (foreach p ptlist

 (write-line (strcat (rtos (car p)2 3);<--precision 3 decimals
       (chr 9)
       (rtos (cadr p) 2 3)
       (chr 9)
       (rtos (cadr p)2 3))
  datafile)
 )
      (close datafile)
      )
    )
 (princ)
 )

;;==============================================;;
(prompt "\nStart command with EXPOINTS")
(prin1)

 

~'J'~

Link to comment
Share on other sites

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