Author Topic: Need LISP Routine to read ASCII file and generate a 3Dpoly  (Read 13514 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Need LISP Routine to read ASCII file and generate a 3Dpoly
« Reply #30 on: February 21, 2005, 05:52:28 PM »
Quote from: Peter Jamtgaard
It includes a couple useful routines that you all might enjoy reviewing.

Or even storing in the local library. :blink:

Good stuff Peter, thanks a bunch.
TheSwamp.org  (serving the CAD community since 2003)

SMadsen

  • Guest
Need LISP Routine to read ASCII file and generate a 3Dpoly
« Reply #31 on: February 21, 2005, 05:55:31 PM »
Wow there Peter .. poor grdruck is trying his best  :wink:

Good to see you, though. Hope things are great.

grdruck

  • Guest
Need LISP Routine to read ASCII file and generate a 3Dpoly
« Reply #32 on: February 23, 2005, 03:01:58 AM »
Hello and thanks for helping me out.  I'm kinda liking this LISP stuff!!  :D

I added a few more things to it and looking at some other code from CAB to in corporate into it.

Take a look and see what you think.  Also, I like to set a static path so I don't have to keep searching for the directory that I placed the ".txt" files to read.  Secondly, is there a way to turn off the OSNAP's (I thought it would be (Setvar "OSNAP" 0) but its not working)

Code: [Select]
;;   My3Dpoly.LSP
;; Written by Garth Druckenmiller on February 20, 2005
;;       Updated on 02/23/2005 - read multiple coordinate files.
;;      
;;     with help from various sources.   Thanks to those on TheSwamp.org

(defun C:MY3DPOLY ()

  (Prompt "\nMY3DPOLY - Draws a 3Dpolyline by reading input from coordinates file(s)")
  (Prompt "\n")

  (setq OLD_CMDECHO (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)

  (setq FILENAME "")

  (while (Setq FILENAME (getfiled "Select the coordiate file to input : " FILENAME "txt" 128))
    (Setq FILEUNIT (open FILENAME "r"))

    (command ".3DPOLY")

    ;; process file
    (While (setq LINE_INPUT (read-line FILEUNIT))
      (setq PT LINE_INPUT)
      (command PT)
    )

    (command "")

    (close FILEUNIT)
  )

    (setvar "CMDECHO" OLD_CMDECHO)

    (prompt "\nProgram complete.")
    (princ)
)



All look at your code Peter at some point - its a little over my head at this point, but thanks for sharing.

Thanks again for all your help.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need LISP Routine to read ASCII file and generate a 3Dpoly
« Reply #33 on: February 23, 2005, 08:44:11 AM »
I think Se7en may be the author f this code
Code: [Select]
;;;===================================================================;
;;; SetOsnaps                                                         ;
;;;-------------------------------------------------------------------;
;;; This function accepts a integer of 1 or 0 (on or off) to set the  ;
;;; end users osnap value to enabled or disabled.                     ;
;;;                                                                   ;
;;; Argument: 1 = Enable the users osnaps                             ;
;;;           0 = Disable the users osnaps                            ;
;;;                                                                   ;
;;; Usage: (SetOsnap 1) or (SetOsnap 0)                               ;
;;;                                                                   ;
;;;===================================================================;
(defun SetOsnaps (value / osm)
  (setq osm (getvar "OSMODE"))
  (if (or (and (= value 1) (> osm 16383))
          (and (= value 0) (<= osm 16383))
      )
    (setvar "osmode" (boole 6 (getvar "osmode") 16384))
  )
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need LISP Routine to read ASCII file and generate a 3Dpoly
« Reply #34 on: February 23, 2005, 08:57:56 AM »
But the setvar should work for you. I use it when the user has no input as with your routine.
try this:

 
Code: [Select]
(defun c:my3dpoly (/ useros old_cmdecho filename line_input fileunit pt)
  (setq useros (getvar "osmode"))
  (setvar "osmode" 0)
  (setq old_cmdecho (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)

  (prompt
    "\nMY3DPOLY - Draws a 3Dpolyline by reading input from coordinates file(s)"
  )
  (prompt "\n")

  (setq filename "")

  (while (setq filename (getfiled "Select the coordiate file to input : " filename "txt" 128))
    (setq fileunit (open filename "r"))

    (command ".3DPOLY")

    ;; process file
    (while (setq line_input (read-line fileunit))
      (setq pt line_input)
      (command pt)
    )

    (command "")

    (close fileunit)
  )

  (setvar "CMDECHO" old_cmdecho)
  (setvar "osmode" useros)

  (prompt "\nProgram complete.")
  (princ)
)
(prompt "\nMy3dPoly loaded, enter My3dPoly to run.")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

nivuahc

  • Guest
Need LISP Routine to read ASCII file and generate a 3Dpoly
« Reply #35 on: February 23, 2005, 10:10:49 AM »
OSNAP != OSMODE

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need LISP Routine to read ASCII file and generate a 3Dpoly
« Reply #36 on: February 23, 2005, 10:23:48 AM »
Quote from: nivuahc
OSNAP != OSMODE

Good catch!
I need  that second cup of coffee.
Wrong word (Setvar "OSNAP" 0)
should be (Setvar "OSMODE" 0)
I've typed that myself a time or two. 8)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.