Jump to content

Get point of when there are no entities selected.


Lee Chu Chu

Recommended Posts

I have this code:

 

(setq PT1 (getpoint))
(setq PT2 (getpoint PT1))
(command "LINE" PT1 PT2)
(command) 
(setq obj1 (entget (entlast)))
       (setq ent (car (nentsel "\nSelect Entity: \n")))
(cond 
	((/= ent nil)
		(setq obj2 (entget ent))
                       (command "chamfer" obj ent)
               )
               ((= ent nil)
                       (setq PT3 (getpoint ent))
                       (command "LINE" PT2 PT3)
               )
        )
)

 

Its supposed to be able to draw a line when if there is no entity it draws the line up till that point where I tried to select the entity. However when I execute this code, it will state that I have an inappropriate data type. How should I modify the code to be able to draw the line from the last point to the point of which I tried to select an entity if an entity doesn't exist at that particular point?

Link to comment
Share on other sites

Its supposed to be able to draw a line when if there is no entity it draws the line up till that point where I tried to select the entity. However when I execute this code, it will state that I have an inappropriate data type. How should I modify the code to be able to draw the line from the last point to the point of which I tried to select an entity if an entity doesn't exist at that particular point?

 

i prefer IF statement (your code using cond)

 

example

(if ent
 (alert "Do chamfer")
 (alert "Draw line")
 ) ;_ end of if

Link to comment
Share on other sites

Try this:

 

(defun c:test ( / pt1 pt2 obj1 ent PT3)
   (setq PT1 (getpoint))
   (setq PT2 (getpoint PT1))
   (command "_LINE" "_non" PT1 "_non" PT2 "")
   (setq obj1 (entlast))
   (setq ent (entsel "\nSelect Entity: \n"))
   (setq PT3 (cadr (grread T)))
   (if ent 
       (command "_chamfer" obj1 ent)
       (command "_LINE" "_non" PT2 "_non" PT3 "")
   )
)

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