Jump to content

Recommended Posts

Posted

Hi guys,

 

Is it possible to use (entsel) as (getpoint). My goal is to select a block and get it's insertion point and if it nil or I click on a blank area it will just get the point on where I click and missed. Thank you.

Posted (edited)

with entsel , select the object , (cdr (assoc 10 (entget object)));

 

If you're wanting the prompt to conitnue when you "missed"

 

(if (not (while
       (progn (setvar 'errno 0) (setq en (car (entsel)))
           (cond
               (   (= 7 (getvar 'errno))
                   (princ "\nMissed, try again.")
               )
               (   (eq 'ename (type en))
                   (if (not (eq (cdr (assoc 0 (entget en))) "INSERT"))
                       (princ "\nInvalid Object Selected.")
                   )
               )
           )
       )
    )
)
(cdr (assoc 10 (entget en))))

 

kudos to Lee Mac et al

Edited by pBe
Posted

Thank you Pbe but that is not my goal. If I missed, then I just need to get the point on where I clicked.

 

It's either get the insertion point of a block or get the point on where I missed when I click.

 

 

If you're wanting the prompt to conitnue when you "missed"

 

Posted

For completeness, getting the second item in the list returned by Entsel is the point of selection, which is not the same as the insertion point of a block. One could easily evaluate if a block is returned by Entsel, if so returning the insertion point, and if not then return the point of selection.

Posted

Maybe this

(defun sel_block ( / p1 s e)
 (if
   (setq p1 (getpoint "\nSelect block: "))
   (if
     (setq s (nentselp p1))
     (if
       (and
         (eq (type (setq e (car (cadddr s)))) 'ENAME)
         (eq (cdr (assoc 0 (entget e))) "INSERT")
         )
       (cdr (assoc 10 (entget e)))
       (progn
         (princ "\nNot a block")
         (sel_block)
         )
       )
     p1
     )
   )
 )

(defun C:TEST ()
 (sel_block)
 )

Posted
Thank you Pbe but that is not my goal. If I missed, then I just need to get the point on where I clicked.

 

It's either get the insertion point of a block or get the point on where I missed when I click.

 

Thing with entsel, when you "missed" you wont get anything at all.

You can however use grread

 

 

(if (or (setq ent (entsel))
       (setq gr   (grread t 15 0)
             code (car gr)))
     (setq pt (if  ent 
                    (cdr (assoc 10 (entget (Car ent))))
                    (cadr gr)))
         )

 

Ooops

Posted

Thanks Stefan and pBe your code is exactly what I'm looking for. I've spend half a day to figure this out to no avail. Thanks again!

 

pBe,

Just wondering, what is the purpose of the "code" variable?

 

Thing with entsel, when you "missed" you wont get anything at all.

You can however use grread

 

 

(if (or (setq ent (entsel))
       (setq gr   (grread t 15 0)
             [color="red"]code (car gr)[/color]))
     (setq pt (if  ent 
                    (cdr (assoc 10 (entget (Car ent))))
                    (cadr gr)))
         )

 

Ooops

Posted

Pbe,

Just wondering, what is the purpose of the "code" variable?

 

Cool beans

 

Pay no attention to it. its a left-over from the routine i copied the snippet. :D

Anyways FYI

(= 5 code) ;; Mouse has been dragged

(= 2 code) ;; Keyboard has been pressed

(= 3 code) ;; Left-Click of the mouse

 

HTH

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