Jump to content

Recommended Posts

Posted

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

Posted

(defun midp ( p1 p2 )

  (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) p1 p2)

)

Posted

Another

(setq mp (mapcar '* (mapcar '+ p1 p2) '(0.5 0.5)))
or
(setq mp (mapcar '/ (mapcar '+ p1 p2) 2.0))

 

Posted
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)

Posted (edited)

Another alternative is use polar, e.g.:

(polar p1 (angle p1 p2) (/ (distance p1 p2) 2.0))

 

Edited by Lee Mac
Posted (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 by BIGAL
Posted

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

Posted

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.

 

image.png.5eccdf94700ed48b4a7ed64df38a18fc.png

 

 

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.

 

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...