delta Posted January 11 Posted January 11 Hi I have used Autolisp to insert a line. (setq p1 (getpoint "\nPick top hole on LH Staunchon:")) (setq p2 (getpoint "\nPick top hole on RH Staunchon:")) (command "pline" p1 p2 "") (setq topline (entlast) Using Lisp I would like to get the mid point of "topline" so I can insert a block at that point. Can you help me with this please? Regards Tony Quote
marko_ribar Posted January 11 Posted January 11 (defun midp ( p1 p2 ) (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) p1 p2) ) Quote
BIGAL Posted January 11 Posted January 11 (edited) Another (setq mp (mapcar '* (mapcar '+ p1 p2) '(0.5 0.5))) or (setq mp (mapcar '/ (mapcar '+ p1 p2) '(2.0 2.0 2.0))) Edited January 13 by BIGAL Quote
Lee Mac Posted January 11 Posted January 11 2 minutes ago, BIGAL said: Another (setq mp (mapcar '/ (mapcar '+ p1 p2) 2.0)) This will not work - a lambda is required or '(2.0 2.0 2.0) Quote
Lee Mac Posted January 11 Posted January 11 (edited) Another alternative is use polar, e.g.: (polar p1 (angle p1 p2) (/ (distance p1 p2) 2.0)) Edited January 11 by Lee Mac 1 Quote
BIGAL Posted January 11 Posted January 11 (edited) OOPS, thanks Lee. Forgot it uses divide X, Y & Z, not the actual point. I think "Cal" has a midpoint function as well. Edited January 11 by BIGAL Quote
delta Posted January 12 Author Posted January 12 Thank you all very much for your input. That part is now working perfectly. I have another question. I hope I'm not over staying my welcome. Please see the attachment Sample Object 2.pdf Quote
BIGAL Posted January 12 Posted January 12 Does it have to use a Block ? For me just enter the sizes and pick pt1. Then just draw the objects. If the pdf is just showing a rectang as the block rather than a true object then why cant you put the X scale for the block. Re starting at 75 up to 1400 can use something like this. Need the vertical size of the rectang. What is the gap to the block. So if you have blocks that are not a rectang what is there names like 275rec etc ? The best thing here is post a real dwg I am sure can be automated. Quote
delta Posted January 13 Author Posted January 13 Thanks Bigal Thank you for your input. The rectangle is only symbolic of what I have to insert as a block. Its actually a very intricate shape. I didnt want to complicate the issue. Also I never measure the size of the shape I want to make. I am using Lisp to get the distances through picking points. i have the program almost there and all I need is the correct way to write the IF statement The IF statement needs to know that if the distance I have established through picking 2 points is between 2 amounts then I will use a setq BL and a specific block name. If the distance between another 2 points is larger then again I will setq BL and a different block name than the previous one. By doing this I can have differnt blocks for different width panels (if ((≥(- dist1 40.42) 200) (<(- dist1 40.42) 276) (setq BL "Infil_sq_1")) ((≥(- dist1 40.42) 275) (<(- dist1 40.42) 351) (setq BL "Infil_sq_2")) ((≥(- dist1 40.42) 350) (<(- dist1 40.42) 426) (setq BL "Infil_sq_3")) ) This if statement doesn't work. You can see that I am asking that if dist1-40.42 is greater than or equal to 200 and also if dist1-40.42 is is less that 275 then I want BL to be Infil_sq_1 and so on as the width increases I will eventually get BL to be Infil_sq_15. I have made 15 sepaate blocks. I hope i have explained myself clearly regards Tony Quote
BIGAL Posted January 13 Posted January 13 (edited) In lisp you need a and is it greater than or equal to but less than or equal to. ((and (>= (- dist1 40.42) 200) (<= (- dist1 40.42) 275.999999)) (setq BL "Infil_sq_1")) Maybe use 275.999999 than can use 276 in next if. Edited January 13 by BIGAL 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.