Results 1 to 2 of 2

Thread: 3DPOLY Lisp routine problems....

  1. #1
    Member
    Join Date
    2011-12
    Posts
    3
    0 Did you find this post helpful? Yes

    Default 3DPOLY Lisp routine problems....

    My friend and I are total newbies at writing script/lisp routines, but we are attempting because there has to be a faster way to do what we're doing. I have a spillway structure defined by hundreds of points in excel (the points are cross sections, so 3 to 5 points defining the tops of the walls, chute, bottom of walls, etc). I brought the points into CAD by importing as a .csv file. Now we'd like to connect the different cross section points into 3dpolygons to eventually make a solid for concrete volumes (more confusion we'll tackle later). Anyway, our hope is to just do this over and over and over until we say to stop:

    3DPOLY
    'PN
    (enter cross section point range, for example 100-199)
    Esc
    C (to close the polygon)

    We can get the points entered, but cannot get the escape and close the polygon to work. Any suggestions? Thanks in advance!!!
    Last edited by cstark804917; 2013-05-01 at 11:30 PM.

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    0 Did you find this post helpful? Yes

    Default Re: 3DPOLY Lisp routine problems....

    My first suggestion is to use "CL" instead of "C"
    Other way to use entmake to create 3d poly,
    here is Q&D routine to do it:

    Code:
     (defun C:3PE (/  *error* dimz file file-to-list p points split-string)
       (defun *error*  (msg)
        (if 
          (vl-position
    	msg
    	'("console break"
    	  "Function cancelled"
    	  "quit / exit abort"
    	  )
    	)
           (princ "Error!")
           (princ msg)
           )
        (if dimz (setvar "dimzin" dimz))
        (princ)
        )
       ;; local defuns
        (defun file-to-list (filename / file result line)
      (if (findfile filename)
        (progn (setq file (open filename "r"))
    	   (while (setq line (read-line file))
    	     (setq result (cons line result))
    	   )
    	   (close file)
    	   (reverse result)
        )
        (alert (strcat "File " filename " not found!"))
      )
    )
     (defun split-string (str delim / pos)
      ;; Splits a string into a list of strings at every
      ;; occurrence of the delimiter (single-letter string).
      (setq pos (vl-string-position (ascii delim) str))
      (if (null pos)
        (list str)
        (cons (substr str 1 pos)
    	  (split-string (substr str (+ pos 2)) delim)
        )
      )
    )
        
        ;; main part
       (setq dimz (getvar "dimzin"))
    (setvar "dimzin" 0)
       ;; choose delimited csv file
       (setq file (getfiled "Select points file:" "" "CSV;TXT" 4))
        ;; text file is semicolon delimited, values are in order of: X , Y , Z 
        
       ;;(setq file (findfile "C:\\Test\\3Points.csv"));for test only
      (setq points (file-to-list file))
       (if points (progn
      (setq points (mapcar '(lambda (p)(mapcar 'atof (split-string p ";"))) points)); <-- char ";" is a separator, change on your separator here
    
    ;; entmake polyline
    ;; create polyline first
    (entmake
      (list (cons 0 "POLYLINE")
    	(cons 100  "AcDbEntity")
    	(cons 8 "0");< -- layer
    	(cons 100 "AcDb3dPolyline")
    	(cons 66 1)
    	(cons 70 9)); <-- 9 is flag for closed (non fit/smooth) 3d poly
      )
    ;; pline vertices
    (foreach pt points
      ; creates new vertex
      (entmake
        (list
          (cons 0 "VERTEX")
          (cons 100 "AcDbEntity")
          (cons 8 "0");< -- layer
            (cons 100  "AcDbVertex")
      (cons 100  "AcDb3dPolylineVertex")
          (cons 10 pt)
          (cons 42 0.0)
          (cons 70 32)
          ))
      ) ;end foreach
    (entmake (list
    	   (cons 0 "SEQEND")
    	   (cons 100  "AcDbEntity")
    	   (cons 8 "0");< -- layer)
    	 )
    )
       (gc)
      (command "_zoom" "_ob" (entlast) "")
    )
         )
      (*error* nil)
      (princ)
    )
    (prompt "\n\t\t---\tStart command with: 3PE \t---")
    (prin1)
    "The whole problem with the world is that fools and fanatics are always
    so certain of themselves, and wiser people so full of doubts."
    Bertrand Russell

Similar Threads

  1. Help with a lisp routine to add a 12" line to this routine
    By Orbytal.edge341183 in forum AutoLISP
    Replies: 3
    Last Post: 2012-11-14, 09:33 PM
  2. Replies: 9
    Last Post: 2012-01-21, 06:58 AM
  3. 3DPOLY within a lisp
    By Mlabell in forum AutoLISP
    Replies: 6
    Last Post: 2007-03-02, 05:58 PM
  4. Replies: 2
    Last Post: 2006-08-17, 07:39 PM
  5. Replies: 2
    Last Post: 2006-03-10, 11:58 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •