draw 3D polyline using coordinates

draw 3D polyline using coordinates

Yamishon_Noah
Enthusiast Enthusiast
3,615 Views
6 Replies
Message 1 of 7

draw 3D polyline using coordinates

Yamishon_Noah
Enthusiast
Enthusiast

Hi,

 

 

I want to draw 3D polyline in coordinates, 

I have coordinates in excel.

 

Ex:

 

1st 3D polyline

X object to Y object

draw 3D polyline as per co-ordinates (have in excel)

 

2nd 3D polyline

Z object to Y object

draw 3D polyline as per co-ordinates (have in excel)

 

like I need to draw many 3D polylines in coordiantes 

 

is there any LISP for this process?

 

kindly let me know

 

thanks

 

 

0 Likes
3,616 Views
6 Replies
Replies (6)
Message 2 of 7

nichkherbsman
Advocate
Advocate

Hi,

 

This is the code that you are looking for.

Credit to cadtips.cadalyst.com - Tony Hotchkiss.

 

(defun err (s)
  (if (= s "Function cancelled")
    (princ "IMPORT-3D-POLY - cancelled: ")
    (progn (princ "IMPORT-3D-POLY - Error: ")
	   (princ s)
	   (terpri)
    ) ;_ progn
  ) ; if
  (resetting)
  (princ "SYSTEM VARIABLES have been reset\n")
  (princ)
) ; err
(defun setv (systvar newval)
  (setq x (read (strcat systvar "1")))
  (set x (getvar systvar))
  (setvar systvar newval)
) ; setv 
(defun setting ()
  (setq oerr *error*)
  (setq *error* err)
  (setv "CMDECHO" 0)
  (setv "BLIPMODE" 0)
) ; end of setting 
(defun rsetv (systvar)
  (setq x (read (strcat systvar "1")))
  (setvar systvar (eval x))
) ; restv
(defun resetting ()
  (rsetv "CMDECHO")
  (rsetv "BLIPMODE")
  (setq *error* oerr)
) ; end of resetting 

(defun poly3D ()
  (setq	ptlist1	(get-ptlist))
  (make-3dpolyline ptlist1)
) ;_ poly3D

(defun get-ptlist ()
  (setq	fn    (getfiled "3D points file" "" "txt" 8)
	f     (open fn "r")
	str   (read-line f)
	plist nil
  ) ;_ end of setq
  (while (/= str EOF)
    (setq str (read-line f))
    (if	str
      (progn
	(setq pt (get-pt str))
	(setq plist (append plist (list pt)))
      ) ;_ end of progn
    ) ;_ end of if 
  ) ;_ end of while
  (setq f (close f))
  plist
) ;_ get-ptlist

(defun get-pt (str1)
  (setq	comma (chr 44)
	str2  ""
	count 1
	i     0
  ) ;_ end of setq
  (repeat 2
    (repeat (strlen str1)
      (setq char (substr str1 (setq i (1+ i)) 1))
      (if (/= char comma)
	(setq str2 (strcat str2 char))
	(progn
	  (if (= count 1)
	    (progn
	      (setq x (atof str2))
	      (setq str1 (substr str1 (1+ i)))
	      (setq i 0)
	      (setq count 2)
	      (setq str2 "")
	    ) ;_ end of progn
	    (progn
	      (setq y (atof str2))
	      (setq str1 (substr str1 (1+ i)))
	      (setq z (atof str1))
	    ) ;_ end of progn
	  ) ;_ end of if
	) ;_ end of progn
      ) ;_ end of if
    ) ;_ end of repeat
  ) ;_ end of repeat
  (setq pt (list x y z))
) ;_ end of get-pt

(defun make-3dpolyline (ptlist)
  (entmake (list '(0 . "POLYLINE")
		 '(100 . "AcDbEntity")
		 '(100 . "AcDb3dPolyline")
		 '(70 . 8)
	   ) ;_ list
  ) ;_ entmake
  (repeat (length ptlist)
    (setq pt	 (car ptlist)
	  ptlist (cdr ptlist)
    ) ;_ setq
    (entmake (list '(0 . "VERTEX")
		   '(100 . "AcDb3dPolylineVertex")
		   (cons 10 pt)
		   '(70 . 32)
	     ) ;_ list
    ) ;_ entmake
  ) ;_ repeat
  (entmake '((0 . "SEQEND")))
) ;_ make-3dpolyline

(defun c:pl3 ()
  (setting)
  (poly3D)
  (resetting)
  (princ)
) ;_ c:pl3

(prompt "Enter PL3 to start")

For for information see the link below:

http://cadtips.cadalyst.com/3d-operations/import-3d-points-excel

 

Regards,

Jah

NiCHKCiD
BIM Modeler
Technical Officer
Technical Designer
Sr. Draftsman
0 Likes
Message 3 of 7

Yamishon_Noah
Enthusiast
Enthusiast

you're awesome...

 

pls see my query (want to do)

 

Create a layer

  many layer want to create

 

Create a 3D polyline using coordiantes  (you provided lisp for it)

  Each 3D polyline has max 10 points to create

  No. of 3D polyline to be create is more than 1000 hence we need to run every polyline individually - any other alter solution ?

  Should place drawn 3D polyline  in respective layer

 

Attach a tag to 3d polyline created - I have lisp for it (FAS file)

  Each 3D polyline has individual tag

 

how to compile all these steps together... I want to setup all these in excel file or csv or txt file as a input for this LISP and LISP should call that file and execute it..

 

 

Kindly help me,,

 

 

0 Likes
Message 4 of 7

nichkherbsman
Advocate
Advocate

Thank you.

 

That's a combination of 3 lisp.

Can you attach your lisp that you said. the FAS file.

 

And can you attach the dwg file that you want to draw.

 

Thank you.

 

NiCHKCiD
BIM Modeler
Technical Officer
Technical Designer
Sr. Draftsman
0 Likes
Message 5 of 7

Yamishon_Noah
Enthusiast
Enthusiast

Pls find attached file

 

I have attached sample dwg 

   Ex: only one 3D polyline drawn

         Similarly there are many 3D polylines to be drawn.

 

I have added TAG for that 3D polyline also.

 

0 Likes
Message 6 of 7

nichkherbsman
Advocate
Advocate

Hi,

 

I saw the file you attached. Thank you for that.

 

Anyway, I suggest that you start draw the 3D polylines and put manually the tags and layer using the lisp you have.

 

I'm still trying to figure how will happen the lisp you want, like in one cmd.

 

Regards,

Jah

NiCHKCiD
BIM Modeler
Technical Officer
Technical Designer
Sr. Draftsman
0 Likes
Message 7 of 7

Yamishon_Noah
Enthusiast
Enthusiast

Hi jah,

 

I'm figuring out like below... give me your suggestion on this too

 

(defun c:mk ()
(command "_layer" "n" "JB1" "")
(command "_layer" "c" "3" "JB1" "")
(command "_layer" "s" "JB1" "")
(command "_3dpoly" "100,100,0" "250,250,0" "250,250,750" "")

(princ)
)

 

here I can define many 3D polylines & layers can draw it.

 

only thing I could call another LISP command in this lisp.. - you have any solution for this?

 

0 Likes