Jump to content

Draw line in the mid distance of 2 existing lines


Recommended Posts

Posted

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

  • Replies 29
  • Created
  • Last Reply

Top Posters In This Topic

  • fixo

    9

  • motee-z

    8

  • Danielm103

    4

  • SEANT

    2

Top Posters In This Topic

Posted Images

Posted

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

Posted
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

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'~

Posted

things going not well

same old problem

regards

Posted

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?

Posted
things going not well

same old problem

regards

 

Forgot to say about

Select lines in counterclockwise order only

 

~'J'~

Posted

>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! :)

Posted
>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'~

Posted

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

  • 9 years later...
Posted
This has no error checking, but its a start for you

Dan

 

(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?

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