Jump to content

select objects inside circle


mauro

Recommended Posts

lpseifert, the ssget function line looks weird to me. I don't understand the filter. Isn't the vertex list nothing but point data? I don't have Autocad available to test this with visual lisp. Anyway the error message seems to be complaining about the data submitted to the ssget so I would verify that the vertex list really is nothing but point data.

Link to comment
Share on other sites

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • mauro

    7

  • smorales02

    5

  • fuccaro

    4

  • CALCAD

    3

The argument to the "_WP" filter is a list of points extracted from the vertexes of the created polygon. When queried the variable 'vertex_list' does indeed show a list of points.... I don't know, seems odd it works, then doesn't work.

Lesson in futility I guess.

Thanks-

Link to comment
Share on other sites

Thank you very much for your help. fuccaro's program functioned perfectly. but calcad´s program did not function, perhaps because my autocad 2005 is the spanish version. thanks likewise.

Link to comment
Share on other sites

lpseifert,

The following code works reliably on my system. I use Intellicad.

 

 
;;--------------------------------------------------------------------
;;  get pline vertex list for LWPline only by CAB
;(defun get_pline_cor (elst)
;  (mapcar 'cdr
;      (vl-remove-if-not '(lambda (x) (= 10 (car x))) elst)
;  )

;;----------------------------------------------------------------------------
(defun gpc (elst / plst ptlist pc ec)
 (setq plst (- (length elst) (length (member (assoc 10 elst) elst))))
 (setq ptlist nil)
 (setq pc plst)
 (setq plst (- (length elst) 1))
 (while (< pc plst)
   (setq ec (nth pc elst))
   (setq ec (cdr ec))
   (setq ptlist (cons ec ptlist))
   (setq pc (+ pc 4))
 )
 ptlist
)
(defun c:CIC (/          circ      
           circle_list   pt_center        circle_radius
           vertex_list
              )
 (setq old_echo (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq    circ          (entsel "Select a circle: ")
   circle_list   (entget (car circ))
   pt_center     (cdr (assoc 10 circle_list))
   circle_radius (cdr (assoc 40 circle_list))
 )

 (command "_polygon" 360 pt_center "I" circle_radius)

 (setq    elst (entget (entlast))
 )

 (entdel (entlast))
 (setq    vertex_list
    (gpc elst)
 )

 (alert (strcat "There are "
        (itoa (sslength (ssget "_WP" vertex_list '((0 . "circle")(8 . "Clientes")))))
        " objects inside the circle"
        )
 )
 (setvar "cmdecho" old_echo)
 (princ)
)

 

As you can see, the main difference is that I replaced the visual lisp based function get_pline_cor with my old-style lisp function gpc. I also deleted the pt_on variable because it is not used anywhere. The fact that this code works on my system shows that your logic and syntax are basically correct. It doesn't prove that there is anything wrong with the get_pline_cor function, but something is still causing instability in your system. All I can suggest now is that, at the beginning of the main program, you could try saving the OSMODE value and set it to zero, then restore the saved OSMODE at the end. I have seen object snap settings screw up lisp execution in Autocad. Good luck.

Link to comment
Share on other sites

Thanks, but using your code I get the same error message 'error: bad argument type: lselsetp nil'; the vertex_list returns a list of point data, but when I enter (ssget "_WP" vertex_list) it returns nil....

I dunno, the concept is good, and it did work a few times.

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...