bpdav1 Posted August 15, 2012 Posted August 15, 2012 (edited) I want to extract values from objects such as a line, and use them as variables in Autolisp. For instance, say I draw a line: (command "line" "0,0" "@5000<37" "") It will draw a line 5000 units long from the origin at an angle of 37°, to an unknown point. If I inspect the properties of this line, I can find that end point END X = 4000 and END Y = 3000. Is there a way to extract these values through lisp and assign them to a variable? eg. (setq endx1 ("end x value")) (setq endy1 ("end y value")) Conversely I also want to be able to draw a line from absolute coords point1 to point2 and get the delta x and y values, as well as the length and angle. Edited August 15, 2012 by bpdav1 Quote
nod684 Posted August 15, 2012 Posted August 15, 2012 I want to extract values from objects such as a line, and use them as variables in Autolisp. For instance, say I draw a line: (command "line" "0,0" "@5000 It will draw a line 5000 units long from the origin at an angle of 37°, to an unknown point. If I inspect the properties of this line, I can find that end point END X = 4000 and END Y = 3000. Is there a way to extract these values through lisp and assign them to a variable? eg. (setq endx1 ("end x value")) (setq endy1 ("end y value")) Conversely I also want to be able to draw a line from absolute coords point1 to point2 and get the delta x and y values, as well as the length and angle. try reading this : http://www.jefferypsanders.com/autolispintr_dxf.html and take note of group Code 10 and 11 Quote
Tharwat Posted August 15, 2012 Posted August 15, 2012 This ... ? (command "_.line" "0,0" "@5000<37" "") (if (setq e (entlast)) (progn (setq elist (entget e)) (setq end (cdr (assoc 11 elist))) (setq x_end (car end)) (setq y_end (cadr end)) ) ) Quote
MSasu Posted August 15, 2012 Posted August 15, 2012 Since you know both starting point and the polar displacement, you can calculate the target point, don't need to list it from entity: (setq pointTemp (polar '(0 0) (* (/ 37.0 180.0) pi) 5000.0) endX (car pointTemp) endY (cadr pointTemp)) I believe you already had this information on your other thread. Also, please edit your post and add the code tags. Thank you. Quote
Tharwat Posted August 15, 2012 Posted August 15, 2012 This is much better and to guarantee that the last object is created and line entity . (if (setq e (entmakex (list '(0 . "LINE") '(10 0. 0. 0.) (cons 11 (polar '(0. 0. 0.) (* (/ 37.0 180.0) pi) 5000.0)) ) ) ) (progn (setq elist (entget e)) (setq end (cdr (assoc 11 elist))) (setq x_end (car end)) (setq y_end (cadr end)) ) ) Quote
SLW210 Posted August 15, 2012 Posted August 15, 2012 bpdav1, Please read the CODE POSTING GUIDELINES and edit your posts (in this thread and some previous threads) to include code tags. Quote
MSasu Posted August 15, 2012 Posted August 15, 2012 Sorry Tharwat, but that is totally counter-productive. Why add the entity and interrogate it later when you have access to all his features at design time?!? Even if OP was looking for such work-around, I believe that a better approach is to advice him/her to use an effective solution. Quote
Tharwat Posted August 15, 2012 Posted August 15, 2012 Sorry Tharwat, but that is totally counter-productive. Where is the counter-productive of the code ? Quote
MSasu Posted August 15, 2012 Posted August 15, 2012 Have you read my whole message? Why add the entity and interrogate it later when you have access to all his features at design time?!? Quote
Tharwat Posted August 15, 2012 Posted August 15, 2012 Have you read my whole message? I don't like these kinds of replies Mircea Quote
MSasu Posted August 15, 2012 Posted August 15, 2012 I just pointed to you that the answer was in my previous message. Sorry if you understood me wrong. Quote
Tharwat Posted August 15, 2012 Posted August 15, 2012 I just pointed to you that the answer was in my previous message. Sorry if you understood me wrong. It is ok , I know what you were referring to , i just added the entmakex and retrieved the needed dxf information just the same way that OP intended to do when they posted the command call of line entity , and i just replaced it with entmakex to guarantee that the last entity is in hand which is better that the use of the function entlast . Quote
MSasu Posted August 15, 2012 Posted August 15, 2012 Again, your solution is impeccable if is used to just demonstrate a principle – coordinates extraction from a line entity. From a practical point of view, please imagine how OP’s code will look if he/she need to draw a contour made of ~100 lines and retain the points for further processing. This is why I believe that this approach is counter-productive. My opinion is that a less experienced user should be adviced to switch to effective solutions instead of encouraging him to persist to not required work-arounds that will overcomplicate his code. I may be wrong, but this is what I fell. Quote
Tharwat Posted August 15, 2012 Posted August 15, 2012 One more time , You have an idea in mind and built your thoughts on it , my example was to give a better way than the use of enlast function and command call is well . Quote
Lee Mac Posted August 15, 2012 Posted August 15, 2012 Tharwat, The point that I believe Mircea is making is that in your code you have already calculated the line endpoint in order to construct the line, and are then querying the DXF data of the line to retrieve the endpoint that you already have. The OP was using the method of constructing the line to obtain the endpoint since evidently he/she was unaware of the polar function (even though this was suggested in a previous thread, by Mircea no less). Quote
Tharwat Posted August 15, 2012 Posted August 15, 2012 I do agree , and to go further in explanations won't hurt at all , IMO at least . Quote
bpdav1 Posted August 15, 2012 Author Posted August 15, 2012 (edited) Guys... I don't think its really appropriate to fill two pages of a public thread with a personal discussion, especially between senior members of the forum, who should set a good example. I would really appreciate if you didn't do it in my posts, at any rate. Thank you to everyone who posted constructive, helpful posts, and I appologise for not posting code in the code tags. I have gone and changed this in all my previous posts. Edited August 15, 2012 by bpdav1 Quote
Lee Mac Posted August 16, 2012 Posted August 16, 2012 Guys... I don't think its really appropriate to fill two pages of a public thread with a personal discussion, especially between senior members of the forum, who should set a good example. I would really appreciate if you didn't do it in my posts, at any rate. Thank you to everyone who posted constructive, helpful posts, and I appologise for not posting code in the code tags. I have gone and changed this in all my previous posts. If you hadn't realised, the 'personal discussion' was actually for your benefit, to explain why one particular method is more effective than another. But since you had clearly ignored the previous advice given in your last thread, we are evidently wasting our time in trying to help you. Quote
Tharwat Posted August 16, 2012 Posted August 16, 2012 Nice reply Lee . @Mircea , if you took the discussion as a personal attack or so as the following guy says , i have to apologize from you . And for you bb , if you didn't get the benefit of that constructive discussion , it really means that we are wasting our time with you and with your unaccepted way of talking . Guys... I don't think its really appropriate to fill two pages of a public thread with a personal discussion, especially between senior members of the forum, who should set a good example. I would really appreciate if you didn't do it in my posts, at any rate. Thank you to everyone who posted constructive, helpful posts, and I appologise for not posting code in the code tags. I have gone and changed this in all my previous posts. Quote
MSasu Posted August 16, 2012 Posted August 16, 2012 @Lee Mac: Thank you for your intervention. @Tharwat: Please don't be afraid, I really didn't considered any of your posts in such way. If you have felt that on mines, then I have to apologize too. 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.