Discussion in english > General discussion about BabaCAD

How to insert an object via mid of two points (lisp file half.lsp)

<< < (2/4) > >>

babadmin:
Copy this to m2p.lsp file

(Defun HALF (/ a b)
(SETQ A (GETPOINT "\nFirst Point ")
B (GETPOINT A "\nOther Point "))
(POLAR A (ANGLE A B)(/ (DISTANCE A B) 2)))
(defun c:m2p (/)
(command "insert" "b1" (half) 1.0 0.0))


Block named 'b1' must exists in drawing before starting command 'm2p' in BabaCAD. I've tested this lisp with success.

calubax:
Yes, this works fine! - but in Autocad this function makes it possible to make much more than  just inserting a block.

So, if for example a line, point or something future input should work with the half lisp function of cause every input (line, rectangle, circle, point, xline an so on) has to get its on Half.lsp or m2p..... much work...

babadmin:
It can do all same in BabaCAD too. I just gave example with block insert (command "insert"), but you can use any command.
If you want use mid point for line, than put (command "line" (half) '(25 30) "") , and this will draw line with startPoint= [midpoint as output calculated from func 'half'] and lastPoint=[some point ex. 25,30], or you can put some other variable instead of exact value for second point.

calubax:
Hello babadmin,
here with the attachment version (m2P.lsp) everything works fine.
Maybe that funktion better could be included globaly to the fetch functions that are already bulid in.
 What I have found is that if I erase the line that was created with the m2p funktion the startpoint of the line stays there (looks like a Point). This rest (that Point, startpoint) of the erased line must then separatly erased.

babadmin:
You have bug in your m2p.lsp cause your second point parameter is bad and third parameter must be "" (to specify end of command, as line command does not end until last space or enter key).

You have three parameters: (half) 0.0 0.0, but 0.0 0.0 must be enclosed in parenthesis like this '(0.0 0.0) or "0.0 0.0". Also, "line" command must have "" at the end. So, your m2p.lsp must look like this:

(Defun HALF (/ a b)
(SETQ A (GETPOINT "\nFirst Point ")
B (GETPOINT A "\nOther Point "))
(POLAR A (ANGLE A B)(/ (DISTANCE A B) 2)))
(defun c:m2p (/)
(command "line" (half) '(0.0 0.0) ""))

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version