mayur97 Posted March 4, 2020 Posted March 4, 2020 so i used a different lisp to get the length and width of a certain number of rectangles and it got me a nice table with the both of them very nicely filled in it. however the numbers are 12.8348 and 15.2848. i did change the decimal settings and got them to 12.83 and 15.28. here i actually just want them to be rounded off to 5 like 12.85 and 15.30. i cant seem to do that, id be grateful if anything could help me in rounding them off. p.s. is there just any lisp that gives me all three(length, width and area of a selected rectangle)? any help and advice would be helpful. thanks. refer image Quote
fuccaro Posted March 4, 2020 Posted March 4, 2020 Hello Mayur97 and welcome in the forum! If you already used a Lisp to create the table, I think the simplest approach would be to adjust that Lisp to give you what you need. Post the code if possible and for sure someone will jump in to help you Quote
Lee Mac Posted March 4, 2020 Posted March 4, 2020 You can use a rounding function such as: (defun roundm ( x m ) (* m (atof (rtos (/ x (float m)) 2 0))) ) _$ (roundm 15.2848 0.05) 15.3 _$ (roundm 12.8348 0.05) 12.85 And then convert the result to a string using rtos, e.g.: _$ (rtos (roundm 15.2848 0.05) 2 2) "15.30" _$ (rtos (roundm 12.8348 0.05) 2 2) "12.85" Quote
BIGAL Posted March 4, 2020 Posted March 4, 2020 Being a rectang you will have 4 vertices, so length is distance v1-v2 and width v2-v3. So use co-ords to work out lengths only problem is which is length and width due to start point. But you can check angle for Hor and Vert. (setq plent (entsel "\nPick rectang")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) (alert (Strcat "Length is " (rtos (abs (distance (nth 0 co-ord)(nth 1 co-ord))) 2 2) "\nWidth is " (rtos (abs (distance (nth 1 co-ord)(nth 2 co-ord))) 2 2))) Quote
mayur97 Posted March 5, 2020 Author Posted March 5, 2020 11 hours ago, fuccaro said: Hello Mayur97 and welcome in the forum! If you already used a Lisp to create the table, I think the simplest approach would be to adjust that Lisp to give you what you need. Post the code if possible and for sure someone will jump in to help you hi, thanks but since i used a lisp to create the table i can only set it to the limit where i can change the decimal values to just two digits. ill have the lisp i used attached with the text here. thank you. Count rectangle dims.LSP Quote
mayur97 Posted March 5, 2020 Author Posted March 5, 2020 8 hours ago, Lee Mac said: You can use a rounding function such as: (defun roundm ( x m ) (* m (atof (rtos (/ x (float m)) 2 0))) ) _$ (roundm 15.2848 0.05) 15.3 _$ (roundm 12.8348 0.05) 12.85 And then convert the result to a string using rtos, e.g.: _$ (rtos (roundm 15.2848 0.05) 2 2) "15.30" _$ (rtos (roundm 12.8348 0.05) 2 2) "12.85" I'm sorry i am not aware of how to do that(converting to a string using rtos). thank you for the helpful reply though. i am not much familiar with coding yet. Quote
mayur97 Posted March 5, 2020 Author Posted March 5, 2020 7 hours ago, BIGAL said: Being a rectang you will have 4 vertices, so length is distance v1-v2 and width v2-v3. So use co-ords to work out lengths only problem is which is length and width due to start point. But you can check angle for Hor and Vert. (setq plent (entsel "\nPick rectang")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) (alert (Strcat "Length is " (rtos (abs (distance (nth 0 co-ord)(nth 1 co-ord))) 2 2) "\nWidth is " (rtos (abs (distance (nth 1 co-ord)(nth 2 co-ord))) 2 2))) I'm still very new to the software, and just learned how to create a lisp using the codes. But i am not aware of how do I use the codes that you shared here. I'm thankful for the reply and will look further into this. Quote
fuccaro Posted March 5, 2020 Posted March 5, 2020 Oh, I see! Mayur97, I suggest you to write a private message to Stefan BMR and kindle ask him to have a look on this thread. 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.