Author Topic: Whats wrong with this lisp?  (Read 1521 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1421
Whats wrong with this lisp?
« on: March 10, 2013, 01:09:57 PM »
the lisp working but not create the 3dpoly
Code: [Select]
(defun c:3dp ( / 3D CNT ELIST POINT PT ST ) (vl-load-com)

(defun _value (str / ATTS)
    (while (not
     (if (and (setq ATTS (car (nentsel str)))
      (member (vla-get-objectname (setq ATTS (vlax-ename->vla-object ATTS)))
      '("AcDbAttribute" "AcDbText"))
      (setq ATTS (vl-string-left-trim "EL. " (vla-get-textstring ATTS)))
      (numberp (setq ATTS (read ATTS))))
       ATTS (progn (princ "\nNot Valid") nil)))) ATTS)

(defun Make3DPoly ( pointlist / lastent)

(setq lastent (entlast))
(foreach definition
(append
  '(((0 . "POLYLINE") (100 . "AcDbEntity") (100 . "AcDb3dPolyline") (66 . 1) (10 0.0 0.0 0.0) (70 . 8) (40 . 0.0) (41 . 0.0)
     (210 0.0 0.0 1.0) (71 . 0) (72 . 0) (73 . 0) (74 . 0) (75 . 0)))
  (mapcar
    '(lambda (point)
       (append
'((0 . "VERTEX") (100 . "AcDbEntity") (100 . "AcDbVertex") (100 . "AcDb3dPolylineVertex"))
(list (cons 10 point))
'((40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 32) (50 . 0.0) (71 . 0) (72 . 0) (73 . 0) (74 . 0)))) PointList)
  '(( (0 . "SEQEND") (100 . "AcDbEntity")))) (entmake definition)) (not (eq (entlast) lastent)))

  (setq cnt 1)
  (while
    (setq pt (getpoint (strcat "\nPick Point No. 0" (itoa cnt) ": ")))
    (setq st (_value (strcat "\nPick Point No. 0" (itoa cnt) " Level: ")))
    (setq pt (list (float (nth 0 pt)) (float (nth 0 pt)) (float st)) )
      (setq elist (cons pt elist))
    (setq cnt (1+ cnt)))

  (setq 3d (Make3DPoly elist))
  (entmod 3d)
  )

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: Whats wrong with this lisp? Solved
« Reply #1 on: March 10, 2013, 01:33:46 PM »
I found the mistake
Code: [Select]
(setq pt (list (float (nth 0 pt)) (float (nth 1 pt)) (float st)) )instead
Code: [Select]
(setq pt (list (float (nth 0 pt)) (float (nth 0 pt)) (float st)) )
Thanks all

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: Whats wrong with this lisp?
« Reply #2 on: March 10, 2013, 01:40:05 PM »
But How to repeat?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Whats wrong with this lisp?
« Reply #3 on: March 11, 2013, 05:09:41 AM »
But How to repeat?
You are already using a while loop, just nest it in another while loop:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:3dp ( / _value Make3DPoly cnt loopSwitch pt ptList st)
  2.  
  3.  
  4.   (defun _value (str / atts)
  5.     ; ...
  6.   )
  7.  
  8.   ;; Note 1: This function does not return an entity list but T or nil.
  9.   ;; Note 2: PointList must be a valid point list. It cannot be nil.
  10.   (defun Make3DPoly (pointList / lastEnt)
  11.     ; ...
  12.   )
  13.  
  14.   (setq loopSwitch T)
  15.   (while loopSwitch
  16.     (setq cnt 1)
  17.     (setq ptList nil)
  18.     (while
  19.       (and
  20.         (setq pt (getpoint (strcat "\nPick Point No. 0" (itoa cnt) ": ")))
  21.         (setq st (_value (strcat "\nPick Point No. 0" (itoa cnt) " Level: ")))
  22.       )
  23.       (setq pt (list (nth 0 pt) (nth 1 pt) (float st)))
  24.       (setq ptList (cons pt ptList))
  25.       (setq cnt (1+ cnt))
  26.     )
  27.     (setq loopSwitch (if ptList (Make3DPoly ptList)))
  28.   )
  29.   (princ)
  30. )
  31.  

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: Whats wrong with this lisp?
« Reply #4 on: March 11, 2013, 10:39:51 AM »
But How to repeat?
You are already using a while loop, just nest it in another while loop:

Thanx Roy