hello everyone, i'm trying a lisp called branch to creat a takeoff for ducts.but the problem is that when i select the lines its giving me an Error : bad argument type: 2D/3D point: nil. plz help me.
You need to be sure is that the first & the second lines selected should intersect with the third line.
Besides that, the three new variables that represents new coordinate points (pt1 , pt2 and pt3) should also be placed on the same curve object (line as in you example) to allow the command break slice them into tow pieces.
; library routine for midpoint of a line loaded at start up; note a pline need to use getpointatdist.(defun midptL (obj )(mapcar (function (lambda (a b) (/ (+ a b) 2)))(vlax-curve-getstartpoint obj) (vlax-curve-getendpoint obj)) ; mapcar) ; defun; using posted code(setq mp1 (midptL obj1))(setq mp3 (midptL obj3))
Xpr0 if you find your self when starting a code project that you need to repeat maybe 5-6 lines of code a lot you can make them a defun then you can generally just "CALL" them from 1 line through out the code. The example was to find the mid pt of a line or pline you add this defun to say Acaddoc.lsp then you only need (setq pt (midpt obj)) in your new code. As your code gets bigger 200 lines etc using little defuns saves a lot of typing time and reduces any typo errors.
The best example is http://www.lee-mac.com who has a vast library of useful little functions and you will see his defun code in lots of posts here.