Negative numbers causing DXF BAD GROUP CODE 10.

Negative numbers causing DXF BAD GROUP CODE 10.

Anonymous
Not applicable
901 Views
3 Replies
Message 1 of 4

Negative numbers causing DXF BAD GROUP CODE 10.

Anonymous
Not applicable
(defun c:icosahedron ()
  (setq X 0.525731112119133606)
  (setq Z 0.850650808352039932)

  (setq	vertices (list (* X -1)  0.0 Z   X   0.0 Z   (* X -1)  0.0 (* Z -1)  X   0.0 (* Z -1)
		       0.0 Z   X   0.0 Z   (* X -1)  0.0 (* Z -1)  X   0.0 (* Z -1)  (* X -1)
		       Z   X   0.0 (* Z -1)  X   0.0 Z   (* X -1)  0.0 (* Z -1)  (* X -1)  0.0
		      )
  )

  (setq	indices	(list
		  0  4	1  0  9	 4  9  5  4  4	5  8  4	 8  1  8  10 1
		  8  3	10 5  3	 8  5  2  3  2	7  3  7	 10 3  7  6  10
		  7  11	6  11 0	 6  0  1  6  6	1  10 9	 0  11 9  11 2
		  9  2	5  7  2	 11
		 )
  )

  ;;A function that uses entmakex to draw a point
  (defun Point (pt)
    (entmakex
      (list (cons 0 "POINT") (cons 10 pt))
    )
  )

  ;;A function that draws a 3DFace. Pass in four xyz point lists
  (defun 3DFace	(p1 p2 p3 p4)
    (entmakex (list (cons 0 "3DFACE")
		    (cons 10 p1)
		    (cons 11 p2)
		    (cons 12 p3)
		    (cons 13 p4)
	      )
    )
  )

  (setq i 0)
  (while (< i 20)

    (setq ix (+ i 0))
    (setq iy (+ i 1))
    (setq iz (+ i 2))

    (setq i1 (nth ix indices))
    (setq i2 (nth iy indices))
    (setq i3 (nth iz indices))

    (setq v1 (nth i1 vertices))
    (setq v2 (nth i2 vertices))
    (setq v3 (nth i3 vertices))

    (3DFace v1 v2 v3 v1)

    (setq i (+ i 3))
  )








  (princ "done...")
)

In regards to the following code which I have transcribed from:

http://glprogramming.com/red/chapter02.html

 

There seems to be a problem processing the vertices that are negated (or have a value less than zero). Does anyone know how to work around this problem I keep getting a DXF BAD GROUP CODE 10 error. Thank you.

0 Likes
Accepted solutions (1)
902 Views
3 Replies
Replies (3)
Message 2 of 4

john.uhden
Mentor
Mentor
Accepted solution

If I'm not mistaken, your vertices looks like a flat list '(x1 y1 z1 x2 y2 z2 ... xn yn zn) instead of a list of points in the format '((x1 y1 z1)(x2 y2 z2) ... (xn yn zn)).

 

Might that be your problem?

 

Also, I guess I missed where your Point function is used.

John F. Uhden

0 Likes
Message 3 of 4

Anonymous
Not applicable
(defun c:icosodebug ()
  (setq X 0.525731112119133606)
  (setq Z 0.850650808352039932) (setq vertices (list (list (* X -1) 0.0 Z) (list X 0.0 Z) (list (* X -1) 0.0 (* Z -1)) (list X 0.0 (* Z -1)) (list 0.0 Z X) (list 0.0 Z (* X -1)) (list 0.0 (* Z -1) X) (list 0.0 (* Z -1) (* X -1)) (list Z X 0.0) (list (* Z -1) X 0.0) (list Z (* X -1) 0.0) (list (* Z -1) (* X -1) 0.0) ) ) (setq indices (list (list 0 4 1) (list 0 9 4) (list 9 5 4) (list 4 5 8) (list 4 8 1) (list 8 10 1) (list 8 3 10) (list 5 3 8) (list 5 2 3) (list 2 7 3) (list 7 10 3) (list 7 6 10) (list 7 11 6) (list 11 0 6) (list 0 1 6) (list 6 1 10) (list 9 0 11) (list 9 11 2) (list 9 2 5) (list 7 2 11) ) ) ;;A function that draws a 3DFace. Pass in four xyz point lists (defun 3DFace (p1 p2 p3 p4) (entmakex (list (cons 0 "3DFACE") (cons 10 p1) (cons 11 p2) (cons 12 p3) (cons 13 p4) ) ) ) (setq i 0) (while (< i 20) (setq indexl (nth i indices)) (setq i1 (nth 0 indexl)) (setq i2 (nth 1 indexl)) (setq i3 (nth 2 indexl)) (setq point1 (nth i1 vertices)) (setq point2 (nth i2 vertices)) (setq point3 (nth i3 vertices)) (3DFace point1 point2 point3 point1) (setq i (+ i 1)) ) (print "done...") )

It does work. My first attempt was not quite functional. Thank you for your help.

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

By the way, the negative of a number can be just a (-) function with the number as the only argument, without multiplying the number by -1.  Instead of

 

(list (* X -1) 0.0 Z)

 

you can do simply

 

(list (- X) 0.0 Z)

Kent Cooper, AIA
0 Likes