What is wrong??? (error: numbe
Hi all.I'm trying to get minimum and maximum values of x coordinate and y coordinate of a polyline in this code. but it returns this error:
error: bad argument type: numberp: nil
Can anyone tell me what is wrong??
thanks....
(DEFUN C:TEST (/ NOVERTEX ENTCNT)(SETQ SH (SSGET '((0 . "LWPOLYLINE"))))(SETQ NOVERTEX (CDR (ASSOC 90 (ENTGET (SSNAME SH 0)))))(SETQ VERTEXLISTX (LIST))(SETQ VERTEXLISTY (LIST))(FOREACH A (ENTGET (SSNAME SH 0)) (IF (= 10 (CAR A))(PROGN (SETQ VERTEXLISTX (APPEND VERTEXLISTX (LIST (CADR A))) );_SETQ (SETQ VERTEXLISTY (APPEND VERTEXLISTY (LIST (CADDR A))) );_SETQ);_PROGN );_IF);_FOREACH(SETQ ENTCNT 0)(WHILE (
This happens when using (nth) when theis outside the scope of a list
Sample
(setq tempList (list "abc" "def" "ghi"))(nth 4 tempList)
On the final loop
(WHILE ( For an alternative method of sorting the points
Swap
(SETQ ENTCNT 0)(WHILE ( Dear jammie,
So thanks for your complete guildance.
Your alternative code is great.
But there is one question:
By increasing "entcnt" to 4, shouldn't the loop stop when (novertex=4)???
Yes,
The While loop stops when
(
BUT, on the last run through, when you are dealing with the last vertex ; you use this
(nth (+ ENTCNT 1) VERTEXLISTX)
effectively asking for the index AFTER the last one ... Just for comparison, perhaps have a look at something like this
(defun c:doit (/ sh ll ur) (vl-load-com) (setq SH (ssget '((0 . "LWPOLYLINE")))) (vla-getboundingbox (vlax-ename->vla-object (ssname SH 0)) 'll 'ur ) (setq ll (vlax-safearray->list ll) ur (vlax-safearray->list ur) ) (alert (strcat "LowerLeft : " (vl-prin1-to-string ll) "\nUpperRight : " (vl-prin1-to-string ur) ) ) OK.
I'm so thankful about your description and altenative code. It is perfect and has a few arguman vs. my code.
It is so faster by using activex functions.
I hope that i learn this method as soon as possible.
页:
[1]