delta Posted Saturday at 08:05 AM Posted Saturday at 08:05 AM 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 Saturday at 08:10 AM Posted Saturday at 08:10 AM (defun midp ( p1 p2 ) (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) p1 p2) ) Quote
BIGAL Posted Saturday at 10:18 PM Posted Saturday at 10:18 PM Another (setq mp (mapcar '* (mapcar '+ p1 p2) '(0.5 0.5))) or (setq mp (mapcar '/ (mapcar '+ p1 p2) 2.0)) Quote
Lee Mac Posted Saturday at 10:21 PM Posted Saturday at 10:21 PM 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 Saturday at 10:22 PM Posted Saturday at 10:22 PM (edited) Another alternative is use polar, e.g.: (polar p1 (angle p1 p2) (/ (distance p1 p2) 2.0)) Edited Saturday at 10:22 PM by Lee Mac Quote
BIGAL Posted Saturday at 10:25 PM Posted Saturday at 10:25 PM (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 Saturday at 10:27 PM by BIGAL Quote
delta Posted 21 hours ago Author Posted 21 hours ago 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 20 hours ago Posted 20 hours ago 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
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.