Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Close

Visual LISP, AutoLISP and General Customization

- Autodesk Community
- >
- AutoCAD Customization
- >
- Visual LISP, AutoLISP and General Customization
- >
- What is the problem with the entmake in this?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

256 Views, 7 Replies

10-10-2012 11:32 PM

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 c2c()

(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."AcDbC

(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

Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-11-2012 12:39 AM 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")

)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-11-2012 12:40 AM 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."AcDbC

Like this

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

**Tharwat**

____________________________________________________

Get learn and learn and practice , to become experienced guy .

Get learn and learn and practice , to become experienced guy .

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-11-2012 01:10 AM in reply to:
pbejse

Thanks guys.

Hopefully I'll remember this.

Regards,

Ozitag

IV 2010

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-11-2012 02:26 AM 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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-11-2012 03:25 AM in reply to:
pbejse

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

IV 2010

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-14-2012 10:20 AM 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)) ) )

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-14-2012 07:50 PM 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

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements

If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Start with some of our most frequented solutions to get help installing your software.

Upgrading to a 2015 product? Make sure to check these out 1st!

- Privacy | Legal Notices & Trademarks | Report Noncompliance | Site map | © Copyright 2014 Autodesk Inc. All rights reserved

Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see the Autodesk Creative Commons FAQ for more information.