Bill Tillman Posted June 29, 2017 Posted June 29, 2017 I'm trying this code: (setq entdata (entsel "\nSelect Line: ")) (setq pt1 (cdr (assoc 10 entdata))) (setq pt2 (cdr (assoc 11 entdata))) But instead of pt1 and pt2 getting set to the start and endpoints of the line I'm getting bad association list: ( (17387.7 1093.65 0.0)) ??? Quote
BIGAL Posted June 29, 2017 Posted June 29, 2017 Some days its so simple its just looking at you no matter how many times you look at it. (setq entdata (entget (car (entsel "\nSelect Line: ")))) (setq pt1 (cdr (assoc 10 entdata))) (setq pt2 (cdr (assoc 11 entdata))) or Quote
Grrr Posted June 29, 2017 Posted June 29, 2017 Another, will work for ACAD 2012 or higher version: (and getpropertyvalue (setq e (car (entsel "\nSelect a line: "))) (setq pt1 (getpropertyvalue e "StartPoint")) (setq pt2 (getpropertyvalue e "EndPoint")) ) Read more about getpropertyvalue / setpropertyvalue / dumpallproperties . Third option is to use ActiveX, obviously. Quote
Bill Tillman Posted June 29, 2017 Author Posted June 29, 2017 Thanks. Those work really great. I double checked the website I got the code from and sure enough, they were not using the ENTGET syntax. This article was from 2008 so perhaps it's just outdated. Nonetheless, I'm off and working with your assistance, This is for that handrail picket code I'm working on. The horizontal stuff is easy, it's the sloped handrails that I'm having to take extra steps with. Like does the stair slope from the lower left to the upper right, of the other way. Plus, using the above method to choose the line only instead of the start and endpoints of a line selected by the user, it all depends on how the user drew the line. Which as any programmer knows, they don't always do it the same way. I think I have some ideas on how to constrain what input the code gets so it will work no matter what the user drew. Quote
BIGAL Posted June 29, 2017 Posted June 29, 2017 I use "pick one side rule" say pick line at lower end then you can do a simple swap of the points to work out which is start and finish. ; create a library defun ;(setq msg "\nSelect left side inner wall near end : ") ;(leftside msg) (defun leftside (msg / tp1 tpp1 pt3) (setq tp1 (entsel msg)) (setq tpp1 (entget (car tp1))) (setq pt1 (cdr (assoc 10 tpp1))) (setq pt2 (cdr (assoc 11 tpp1))) (setq pt3 (cadr tp1)) (setq d1 (distance pt1 pt3)) (setq d2 (distance pt2 pt3)) (if (> d1 d2) (progn (setq temp pt1) (setq pt1 pt2) (setq pt2 temp) ) ) (setq ang (angle pt1 pt2)) ) Quote
Bill Tillman Posted July 2, 2017 Author Posted July 2, 2017 Thanks again BIGAL, I've made the program work much better by adapting this code into mine. 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.