Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What is the problem with the entmake in this?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
ozitag
997 Views, 7 Replies

What is the problem with the entmake in this?

Hi,

Just learning a bit of Autolisp but I can't work out why this entmake doesn't work. The error says it is a bad DXF group: (0.0 "CIRCLE") which I assume means that the 0.0 is a real number instead of an integer. But why has it taken it in as a real number?

It is just a quick program to change a group of points into circles with a radius from two selected points.

Here is my code:

 

;Function for replacing points with circles of a given radius
(defun c:p2c()
  (setq radpt1 (getpoint "\nKlick första punkten: "))
  (setq radpt2 (getpoint "\nKlick andra punkten: "))
  (setq diffx (- (car radpt1) (car radpt2)))
  (setq diffy (- (cadr radpt1) (cadr radpt2)))
  (setq radius (sqrt (+ (expt diffx 2) (expt diffy 2))))
  (princ (strcat "\n" (rtos radius)))

  (if (setq pointset(ssget (list (Cons 0 "POINT")))) ;get set of points
    (progn
      (setq cntr 0) ;set counter to first item in set
      (while (< cntr (sslength pointset)) ;while counter is less than the length of the set
    (setq item(ssname pointset cntr)) ;get entity name of the item indexed
    (setq itemcodes(entget item)) ;get items group codes
;    (entdel item) ;delete point
    (setq cpnt (assoc 10 itemcodes)) ;get center point of item
    (entmake (append '((0."CIRCLE")(100."AcDbEntity")(8."0")(100."AcDbCircle"))
             (list cpnt)
             (list (cons 40 radius))
             '((210 0.0 0.0 1.0))
             ) ;end append
         );end entmake
    (setq cntr (+ cntr 1)) ;increment counter
    ) ;close while
;      (princ (strcat "\nCircles changed: " (itoa cntr))) ;print the number of circles after new line
      ) ;close progn
    (alert "No points selected")
    ) ;close if
  (princ)
  ) ;close defun

 

Thanks for your critic and help.

Ozitag.

IV 2010
7 REPLIES 7
Message 2 of 8
pbejse
in reply to: ozitag

(entmake (append '((0 . "CIRCLE")
		       (100 . "AcDbEntity")
		       (8 . "0")
		       (100 . "AcDbCircle")
		      )
		     (list cpnt)
		     (list (cons 40 radius))
		     '((210 0.0 0.0 1.0))
	     )				;end append
    )

 

See the diffrerence? 

 

((0. "CIRCLE")<--- no space between 0 and .  hence the error
(100. "AcDbEntity")
(8. "0")
(100. "AcDbCircle")
)

 

 

Message 3 of 8
_Tharwat
in reply to: ozitag

In regard to your question with entmake , you should keep space between the code that feed the entmake function

 

'((0."CIRCLE")(100."AcDbEntity")(8."0")(100."AcDbCircle"))

 

Like this

'((0 . "CIRCLE")(100 . "AcDbEntity")(8 . "0")(100 . "AcDbCircle"))

 

Tharwat

Message 4 of 8
ozitag
in reply to: pbejse

Thanks guys.

Hopefully I'll remember this.

Regards,

Ozitag

IV 2010
Message 5 of 8
pbejse
in reply to: ozitag


@ozitag wrote:

Thanks guys.

Hopefully I'll remember this.

Regards,

Ozitag


Good for you, I see that you have taken the entmake route this time. That is good.

 

BTW:

(setq diffx (- (car radpt1) (car radpt2)))
(setq diffy (- (cadr radpt1) (cadr radpt2)))
(setq radius (sqrt (+ (expt diffx 2) (expt diffy 2))))

 

and this

(distance radpt1 radpt2)

 

Will give you the same result.

 

Might as well use getdist  wherein you can input a value or pick two points for radius

 

(setq radius (getdist "\Enter Radius value/Pick two points: "))

 

HTH

 

Message 6 of 8
ozitag
in reply to: pbejse

Great, thanks for the tip. It would be great to know all the functions huh Smiley Very Happy

IV 2010
Message 7 of 8
wkiernan
in reply to: pbejse

Only if they have the same Z value.  If the Z value differs then (distance radpt1 radpt2) will be larger than the value those three lines of code assign to the "radius" variable.  As surveyor's measurements between coordinate pairs are generally not the 3D distance but the distance between the 2D projections, this came up so often in my programs that I have a subroutine called 2ddist which does the same thing

 

; 2DDIST(POINT1 POINT2), given two 3D (or 2D) points, returns the 2D distance
; between them.  Note that if either arg to DISTANCE is 2D, Z coord of other
; arg is ignored;

(defun-q 2ddist (point1 point2)
 (distance (2dvect point1) point2)
)

; 2DVECT(POINT), given 3D vector POINT = (X Y Z) returns a 2D point (X Y)

(defun-q 2dvect(point)
 (if point
  (list (car point)(cadr point))
 )
)

 

Message 8 of 8
pbejse
in reply to: wkiernan


@wkiernan wrote:

Only if they have the same Z value.  If the Z value differs then (distance radpt1 radpt2) will be larger than the value those three lines of code assign to the "radius" variable.  As surveyor's measurements between coordinate pairs are generally not the 3D distance but the distance between the 2D projections, this came up so often in my programs that I have a subroutine called 2ddist which does the same thing

 

 


wouldnt be easier if

(setvar 'osnapz 1 ) <------- set value to 1  prior to picking the points  Smiley Happy

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost