motee-z Posted January 3, 2007 Author Posted January 3, 2007 Hi fatty the routin still draw circle instead of line please check agian best regards and wellcom of vva to cadtutor forum your routin very nice but the line not represent center line sea image posted by SEANT in this thread to see the problem thank you waiting response Quote
ASMI Posted January 3, 2007 Posted January 3, 2007 Another one from me (defun c:midl(/ lSet ptLst ordLst) (defun GetLineVer(lnObj) (mapcar 'cdr (vl-remove-if-not '(lambda(x)(member(car x) '(10 11))) (entget lnObj))) ); end of GetLineVer (defun GetMidPt(pt1 pt2) (mapcar '- pt1 (mapcar '(lambda(x)(/ x 2)) (mapcar '- pt1 pt2) ); end mapcar ); end mapcar ); end of GetMidPt (princ "\n>>> Select two lines <<<\n") (if (and (setq lSet(ssget '((0 . "LINE")))) (= 2(sslength lSet)) ); end and (progn (setq ptLst (mapcar 'GetMidPt (GetLineVer(ssname lSet 0)) (GetLineVer(ssname lSet 1))) oldOsm(getvar "OSMODE") ); end setq (setvar "OSMODE" 0) (command "._line")(mapcar 'command ptLst)(command "") (setvar "OSMODE" oldOsm) ); end progn ); end if (princ) ); end of c:midl Quote
fixo Posted January 4, 2007 Posted January 4, 2007 Hi fattythe routin still draw circle instead of line please check agian best regards and wellcom of vva to cadtutor forum your routin very nice but the line not represent center line sea image posted by SEANT in this thread to see the problem thank you waiting response Hi, motee-z Yes, you are right, it's my bad again See how this will works for you Hope this will be better (defun C:ml3 (/ ang1 ang2 da dm en1 en2 ep1 ep2 flag ln1 ln2 ln3 p1 p2 pk1 pk2 pt1 sp1 sp2) ;;;(defun dtr (a) ;;; (* pi (/ a 180.0)) ;; (defun rtd (a) (* 180.0 (/ a pi)) ) (defun midpoint (p1 p2) (mapcar (function (lambda (a b) (* (+ a b) 0.5) ) ) p1 p2 ) ) (defun dxf (code elist) (cdr (assoc code elist) ) ) (setq en1 (entsel) en2 (entsel) ln1 (car en1) ln2 (car en2) pk1 (cadr en1) pk2 (cadr en2) ) (setq en1 (entget ln1) sp1 (dxf 10 en1) ep1 (dxf 11 en1) ang1 (angle sp1 ep1) ) (setq en2 (entget ln2) sp2 (dxf 10 en2) ep2 (dxf 11 en2) ang2 (angle sp2 ep2) ) (if (or (equal ang1 ang2 1e-08) (equal ang1 (+ pi ang2) 1e-08) ) ;parallel lines (setq flag t) (setq flag nil) ) (setvar "osmode" 0) (setvar "cmdecho" 0) (if flag (progn (if (< (distance sp1 sp2) (distance sp1 ep2)) (progn (setq p1 (midpoint sp1 sp2) p2 (midpoint ep1 ep2) ) ) (progn (setq p1 (midpoint sp1 ep2) p2 (midpoint ep1 sp2) ) ) ) (command "line" p1 p2 "") ) (progn (command "dimangular" pk1 pk2 (midpoint pk1 pk2)) (setq dm (entlast)) (setq da (rtd (/ (cdr (assoc 42 (entget dm))) 2))) (setq pt1 (inters sp1 ep1 sp2 ep2 nil)) (command "erase" dm "") (command "copy" ln1 "" pt1 pt1) (setq ln3 (entlast)) (command "rotate" ln3 "" pt1 da ) ) ) (setvar "osmode" 703) (setvar "cmdecho" 1) (princ) ) ~'J'~ Quote
motee-z Posted January 5, 2007 Author Posted January 5, 2007 things going not well same old problem regards Quote
CarlB Posted January 5, 2007 Posted January 5, 2007 Motee-z I don't see where you have ever explained just what you wanted for a "mid line". See pefi's question on page 2. Do you want a line that bisects the angle between 2 lines? how do you want the "in between line" length determined when lines are of unequal length? Quote
fixo Posted January 5, 2007 Posted January 5, 2007 things going not wellsame old problem regards Forgot to say about Select lines in counterclockwise order only ~'J'~ Quote
ASMI Posted January 5, 2007 Posted January 5, 2007 >Fatty See thread header 'Draw line in the mid distance of 2 existing lines'. No bisects. You work too much. Congratulate you with coming Orthodox Christmas and Old New Year! Quote
fixo Posted January 5, 2007 Posted January 5, 2007 >Fatty See thread header 'Draw line in the mid distance of 2 existing lines'. No bisects. You work too much. Congratulate you with coming Orthodox Christmas and Old New Year! Thanks friend, my best wishes to you too PS Haven't have a time to work with this further ~'J'~ Quote
motee-z Posted January 5, 2007 Author Posted January 5, 2007 Thank you friends for your efforts to reply my request especialy to mr Fatty what you did can help me but i try to improve the routin to make it perfect for all Quote
thejraj2k Posted July 21, 2016 Posted July 21, 2016 This has no error checking, but its a start for youDan (defun c:test ( / activedocument ename1 ename2 iacadapplication modelspace mp1 mp2 object1 object2) (setq IAcadApplication (vlax-get-acad-object) ActiveDocument (vla-get-ActiveDocument IAcadApplication) ModelSpace (vla-get-ModelSpace ActiveDocument) EName1 (car (entsel "\nSelect the first line: ")) EName2 (car (entsel "\nSelect the Second line: ")) object1 (vlax-ename->vla-object EName1) object2 (vlax-ename->vla-object EName2) mp (lambda (p1 p2) (mapcar (function(lambda(a b)(/(+ a b 0.0) 2.0))) p1 p2)) mp1 (mp (vlax-get object1 'StartPoint) (vlax-get object1 'EndPoint)) mp2 (mp (vlax-get object2 'StartPoint) (vlax-get object2 'EndPoint)) ) (vla-AddLine ModelSpace (vlax-3d-point mp1) (vlax-3d-point mp2)) (princ) ) In this Autolisp , you selected 2 lines, to draw line between these 2 lines, is it possible to draw polyline in between these 2 lines, and width of the polyline is equal to exact distance between these lines? 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.