Lee Chu Chu Posted February 16, 2015 Posted February 16, 2015 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? Quote
hanhphuc Posted February 16, 2015 Posted February 16, 2015 Lee Chu Chu said: 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 Quote
GP_ Posted February 16, 2015 Posted February 16, 2015 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 "") ) ) Quote
Recommended Posts
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.