Jump to content

Recommended Posts

Posted

I'm creating a routine that will select a line insert a symbol and break then break the line ( I got this all working). However I would like to add the functionality that after 2 tries and no line is selected the point from the last attempt is used. Any suggestions on how to easily get this point without adding an additional user getpoint prompt?

 

Here is a portion of the program I'm using to pick the line

 

(while (and (not linent) (< countr 2))
   (setq linent (entsel "\nPick Line for Block Insertion Point:  "))
   (if    linent
     (progn
   (setq ed (entget (car linent)))
   (setq edd (dxf 0 ed))
   (if (and (/= edd "LINE") (/= edd "POLYLINE"))
     (setq linent nill)
   )
     )                    ;progn
   )                    ;if    

   (setq countr (1+ countr))
   (if    (not linent)
     (prompt "\nYou must select a LINE as Insertion Point !  ")
   )
 )    ;while

Posted

Another approach to Point/Object retrieval:

 

(while
 (progn
   (setq pt (getpoint "\nSelect Point for Block: "))

   (cond (  (not pt) nil)

         (  (not (setq ent (car (nentselp pt))))

            (princ "\n ** No Object Found at Point **"))

         (  (not (eq "LINE" (cdr (assoc 0 (entget ent)))))

            (princ "\n  ** Object Must be a Line **")))))

Posted

for those that prefer short code lines, it can be use something like, maybe:

 

equal

(eq (cdadr (entget ename)) "LINE")

 

not

(/= (cdadr (entget ename)) "LINE")

 

as function

(defun enameTarget (name) (eq (cdadr (entget ename)) name))

 

maybe, and so on and on, and on and on... :)

Posted

got a chance to play a little with lisp... and if I understood maybe something like:

 

(defun C:TEST (/ tryouts data pt take)
 (setq tryouts 0)
 (while (<= tryouts 1)
   (if (and (setq data (entsel "\nSelect line: "))
     (eq (cdadr (entget (car data))) "LINE")
)
     (setq tryouts 2
    pt     (cadr data) ;;(osnap (cadr data) "_nea") in case it is close to a line
     )
   )
   (if (and (= tryouts 1)
     (not pt)
     (= (car (setq take (grread 't))) 5)
)
     (setq pt (cadr take))
   )
   (setq tryouts (1+ tryouts))
 )
 (if pt
   ;; test output
   (progn (command "_.point" pt) (princ))
 )
)

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