entmake - DXF bad group code when creating a point object.

entmake - DXF bad group code when creating a point object.

Anonymous
Not applicable
1,239 Views
4 Replies
Message 1 of 5

entmake - DXF bad group code when creating a point object.

Anonymous
Not applicable
(vl-load-com)
(defun c:sphere3d (stacks latitudes radius / 2PI thetad phid)

  (defun nhemisphere (pole_rad / curtheta curphi)
    (setq curtheta thetad)
    (setq curphi phid)

    (while (< curtheta pole_rad)
      
      (setq loncircleradius (* (cos curtheta) radius))
      (setq loncircleelev (* (sin curtheta) radius))
      
      (while (< curphi 2PI)
	(setq x (* (cos curphi) radius))
	(setq y (* (sin curphi) radius))

	(print x)
	
	(entmake '((0 . "POINT")
		   (67 . 0)
		   (100 . "AcDbPoint")
		   (10 x y loncircleelev)
		   (210 0.0 0.0 1.0)
		   (50 . 0.0)
		  )
	)
	
	(setq curphi (+ curphi phid))
      )
      
      (setq curtheta (+ curtheta thetad))
    )
  )




  (setq 2PI (* PI 2))
  (setq thetad (/ PI latitudes))
  (setq phid (/ 2PI stacks))
  (setq radius 1)

  (nhemisphere (/ PI 2))
)

					;defunc:c

Things appear to end with a bad DXF group code in the console. I'm trying to draw the vertexes. Is there some solution?

0 Likes
Accepted solutions (1)
1,240 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution

I was able to solve the problem with some examples of entmakex from the swamp.

 

(vl-load-com)
(defun c:sphere3d (stacks latitudes radius / 2PI thetad phid)

  (defun Point (pt)
  (entmakex (list (cons 0 "POINT")
                  (cons 10 pt))))
  
  (defun nhemisphere (pole_rad / curtheta curphi)
    (setq curtheta 0)

    (while (< curtheta (- pole_rad thetad))
      (print "running...")
      (setq loncircleradius (* (cos curtheta) radius))
      (setq loncircleelev (* (sin curtheta) radius))

      (setq curphi 0)
      (while (< curphi 2PI)
	(setq x (* (cos curphi) loncircleradius))
	(setq y (* (sin curphi) loncircleradius))
	(Point (list x y loncircleelev))
	(setq curphi (+ phid curphi))
      )
      
      (setq curtheta (+ thetad curtheta))
    )
  )




  (setq 2PI (* PI 2))
  (setq thetad (/ PI latitudes))
  (setq phid (/ 2PI stacks))
  (setq radius 1)

  (nhemisphere (/ PI 2))
)

					;defunc:c
0 Likes
Message 3 of 5

john.uhden
Mentor
Mentor
Look back at what you did.

Here:
(entmake '((0 . "POINT")
		   (67 . 0)
		   (100 . "AcDbPoint")
		   (10 x y loncircleelev)
		   (210 0.0 0.0 1.0)
		   (50 . 0.0)
		  )
	)

you quoted an entity list, but that won't evaluate x, or y, or loncircleelev.
Then you used (list etc.) which is what you must do to have symbols evaluated within.

John F. Uhden

0 Likes
Message 4 of 5

Anonymous
Not applicable

The use of the string literals ''s and dotted pairs are a bit tough to get a handle on.

0 Likes
Message 5 of 5

john.uhden
Mentor
Mentor
The first item in a dotted pair is the dxf association code. Each one is tied to a property of an entity. The only time you don't see a dot is when the data is a list as in (0.0 0.0 1.0).
A string literal is just that; it doesn't rely on or refer to any variable symbol.
When you create a list in the form of '((0 . "LINE")(10 2.0 3.0 0.0)(8 . layername)), layername is treated as just a symbol name, not as the value of the symbol.
So if you want to include a symbol in a list (and have its value evaluated), you must use the format (list '(0 . "LINE")'(10 2.0 3.0 0.0)(cons 8 layername)), where each element of the list will be evaluated.

John F. Uhden