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 (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 by BIGAL
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
  • Like 1
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.

 

 

Posted

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  

 

 

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

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...