Jump to content

Obtain coordinate of a circle centerpoint


ajs

Recommended Posts

I have a situation in which I need to extract the coordinate of a circle's centerpoint in order to make a decision.

 

This information needs to be extracted without user input during the course of a lisp.

 

There is never more than 1 circle and additionally, it is on it's own layer.

 

I don't currently have the skill to know where to go to extract this information. If anyone can point me in the proper direction, that would be appreciated.

 

Thank You.

 

AJS

Link to comment
Share on other sites

Change to your layer name.

(defun c:test( / ss CenterPoint)
 (and
   (setq ss (ssget "X" '((0 . "CIRCLE")(8 . "Layer Name"))))
   (setq CenterPoint (cdr(assoc 10 (entget (ssname ss 0)))))
 )
 (princ)
 (princ CenterPoint)
 (princ)
)

Link to comment
Share on other sites

Here is more explination.

(defun c:test( / ss CenterPoint)
 (prompt "\nLooking for a circle center point.")
 (and ; keep evaluating as long as the return values are NOT NILL
   (setq ss (ssget "X" ; "X" will look in the entire DWG
                   ;; filter is next, AND is implied
                   '((0 . "CIRCLE")     ; only get Circle objects
                     (8 . "Layer Name") ; only get objects on this layer
                     )))
   (setq CenterPoint (cdr ; return the list without the first item
                       (assoc 10 ; return the list that starts with 10
                              (entget ; get the entity list from the entity name
                                (ssname ss 0) ; get the first entity name in the selection set
                                ))))
 )
 (print) ; Prints an expression to the command line with a New Line Character
 ;; in this case it advances to the next command line
 (princ CenterPoint) ; Prints an expression to the command line
 (princ) ; clear the return value so nothing else is echoed to the command line
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...