Create Relief Hole

Create Relief Hole

bedros.j
Enthusiast Enthusiast
1,632 Views
19 Replies
Message 1 of 20

Create Relief Hole

bedros.j
Enthusiast
Enthusiast

Hi Guys,

 

see the Screen Recording attached

 

Can we do Something like this Automated? it could be like Fillet command picking the 2 lines to create a Hole of size we enter.

- Command RH (Relief Hole)

- Type in the Diameter of the Hole - for example 2mm

- Pick the 2 Lines - user picks the 2 lines

 

2mm hole is drawn on the intersection and trimmed as the gif attached

what do you think?

 

many thanks!

 

Bedros

 

0 Likes
Accepted solutions (1)
1,633 Views
19 Replies
Replies (19)
Message 2 of 20

dbhunia
Advisor
Advisor

Check this out....... Lightly tested.......

 

(defun c:RH ( / sset Line1_Ent Line2_Ent Line1_Obj Line2_Obj Rad Point IP_Lines Tmp_Line_Obj Cir_Ent Cir_Obj IP_Temp Arc_SA Arc_SPt Arc_EA Arc_EPt)
	(vl-load-com)
	(defun Get_line ( No / Ent)
		(while
			(progn  (setvar 'errno 0)(setq Ent (car(entsel (strcat "\nSelect Line-" (rtos No 2 0) "..."))))
					(cond ((= 7 (getvar 'errno)) (princ (strcat "\nMissed Line-" (rtos No 2 0) ", try again.")))
						  ((= 'ename (type Ent))
							(if (/= "LINE" (cdr (assoc 0 (entget Ent))))
								(princ "\nSelected object is not a Line.")
							)
						  )
					)
			)
		)
		Ent
	)
	(setq sset (ssadd))
	(setq Line1_Ent (Get_line 1))(ssadd Line1_Ent sset)
	(setq Line2_Ent (Get_line 2))(ssadd Line2_Ent sset)
	(setq Line1_Obj (vlax-ename->vla-object Line1_Ent))
	(setq Line2_Obj (vlax-ename->vla-object Line2_Ent))
	(setq IP_Lines  (inters (vlax-get Line1_Obj "startpoint")(vlax-get Line1_Obj "endpoint")(vlax-get Line2_Obj "startpoint")(vlax-get Line2_Obj "endpoint")))
	(if IP_Lines
		(progn
			(setq Rad (getreal "\nEnter Radius of Circle: "))
			(setq Point (getpoint "\nClick on the side to TRIM: "))
			(entmake (list (cons 0 "LINE")(cons 100 "AcDbEntity")(cons 100 "AcDbPolyline")(cons 10 IP_Lines)(cons 11 Point)))
			(setq Tmp_Line_Obj (vlax-ename->vla-object (setq Cir_Ent (entlast))))
			(entmake (list (cons 0 "CIRCLE")(cons 100 "AcDbEntity")(cons 100 "AcDbCircle")(cons 10 IP_Lines)(cons 40 Rad)))
			(setq Cir_Obj (vlax-ename->vla-object (setq Cir_Ent (entlast))))
			(setq IP_Temp (vlax-safearray->list (vlax-variant-value (vla-intersectwith Cir_Obj Tmp_Line_Obj acextendnone))))
			(vla-delete Tmp_Line_Obj)
			(vla-GetBoundingBox (vlax-ename->vla-object Cir_Ent) 'minPt 'maxpt)
			(vla-ZoomWindow (vlax-get-acad-object) minPt maxpt)(setvar 'cmdecho 0)
			(command "_.trim" sset "" "f"
						"_none" (polar IP_Temp (angle IP_Temp IP_Lines) (/ Rad 100))
						"_none" (polar IP_Temp (angle IP_Temp Point) (/ Rad 100)) 
						"" ""
			)
			(setq Arc_SA (cdr (assoc 50 (entget Cir_Ent))))
			(setq Arc_SPt (polar IP_Lines Arc_SA Rad))
			(setq Arc_EA (cdr (assoc 51 (entget Cir_Ent))))
			(setq Arc_EPt (polar IP_Lines Arc_EA Rad))
			(if (vlax-curve-getDistAtPoint Line1_Obj Arc_SPt)
				(command "break" Line1_Ent "_none" IP_Lines "_none" Arc_SPt)
				(command "break" Line2_Ent "_none" IP_Lines "_none" Arc_SPt)
			)
			(if (vlax-curve-getDistAtPoint Line2_Obj Arc_EPt)
				(command "break" Line2_Ent "_none" IP_Lines "_none" Arc_EPt)
				(command "break" Line1_Ent "_none" IP_Lines "_none" Arc_EPt)
			)	
			(vla-zoomprevious (vlax-get-acad-object))(setvar 'cmdecho 1)
		)
		(princ "\nSelected Lines are not Intersecting with each other...")
	)
	(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 3 of 20

Moshe-A
Mentor
Mentor

@bedros.j  hi,

 

check this one, you pick the 2 lines + specify relief hole diameter, that's it 😀 

 

enjoy

Moshe

 

 

(defun c:RH (/ select_line qang ; local functions
	       pick0 pick1 hole_dia elist0 elist1 crs ang p0 p1 t0 t1 t2 t3 t10 t11 t12)

 (defun select_line (msg / pick ename elist)
  (if (and 
       (setq pick (entsel (strcat "\nPick " msg " line: ")))
       (setq ename (car pick))
       (setq elist (entget ename))
       (eq (cdr (assoc '0 elist)) "LINE")
       (not (redraw ename 3))
     )
   pick ; return
   (progn
    (vlr-beep-reaction)
    (prompt "\ninvalid selection.")
   ); progn
  ); if
 ); select_line
  
  
 ; return middle angle
 (defun qang (a0 a1 / included_angle ; local function
	              a2)

  (defun included_angle ()  
   (if (> a0 a1)
    (- a0 a1)
    (- a1 a0)
   )
  ); included_angle
   
  ; start qang
  (setq a2 (included_angle)) 

  (if (> a2 pi)
   (progn 
    (if (< a0 a1)
     (setq a0 (+ a0 (* pi 2)))
     (setq a1 (+ a1 (* pi 2)))
    )
  
    (setq a2 (included_angle)) 
   ); progn 
  ); if
    
  (if (< a0 a1)
   (+ a0 (/ a2 2))
   (+ a1 (/ a2 2))
  )
 ); qang


 ; here starts C:RH 
 (setvar "cmdecho" 0)
 (command "._undo" "_begin") 
  
 (if (and
       (setq pick0 (select_line "first"))
       (setq pick1 (select_line "second"))
       (setq hole_dia (getdist "\nRelief hole diameter: "))
     )
  (progn 
   (setq p0 (osnap (cadr pick0) "nea"))
   (setq p1 (osnap (cadr pick1) "nea"))

   (setq elist0 (entget (car pick0)))
   (setq t0 (cdr (assoc '10 elist0)))
   (setq t1 (cdr (assoc '11 elist0)))
   
   (setq elist1 (entget (car pick1)))
   (setq t2 (cdr (assoc '10 elist1)))
   (setq t3 (cdr (assoc '11 elist1)))

   (if (setq crs (inters t0 t1 t2 t3))
    (progn
     (setq t10 (polar crs (angle crs p0) (/ hole_dia 4)))
     (setq t11 (polar crs (angle crs p1) (/ hole_dia 4)))

     (command "._circle" "_none" crs "_diameter" hole_dia)
     (setq ang (qang (angle crs p0) (angle crs p1)))
     (setq t12 (polar crs ang (/ hole_dia 2)))
     (command "._trim" (entlast) pick0 pick1 "" "_none" t10 "_none" t11 "_none" t12 "")
    ); progn
   ); if
   
  ); progn
 ); if

 (command "._undo" "_end")
 (setvar "cmdecho" 1)
  
 (princ) 
); C:RH
0 Likes
Message 4 of 20

bedros.j
Enthusiast
Enthusiast

oh great i liked how it works and how you pick inside or outside the area for it to trim

is it possible to have the circle size as Diameter instead of Radius @dbhunia ?

 

 

0 Likes
Message 5 of 20

dbhunia
Advisor
Advisor

Replace the line.......

(setq Rad (getreal "\nEnter Radius of Circle: "))

with.......

(setq Rad (/ (getreal "\nEnter Diameter of Circle: ") 2))

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 6 of 20

bedros.j
Enthusiast
Enthusiast

@Moshe-A  i liked how simple is this i tried at different angles, thanks!

 

some acute angles were not trimming maybe I clicked before it happened... since the commands are running as script

 

when I miss to Select line one for example, the script is terminating maybe it will be better if the command insists that i pick line one till i click it right

 

 

0 Likes
Message 7 of 20

bedros.j
Enthusiast
Enthusiast

@dbhunia that was awesome!

 

I was testing this over different examples I realized if the lines are not intersecting it is not working

 

can we do it in a way if the lines do not intersect wherever they project to intersect it creates a hole?

0 Likes
Message 8 of 20

dbhunia
Advisor
Advisor

Check this....... Lightly tested.......

 

 

(defun c:RH ( / sset Line1_Ent Line2_Ent Line1_Obj Line2_Obj Rad Point IP_Lines IP_Lines_Nil Tmp_Line_Obj Cir_Ent Cir_Obj IP_Temp Arc_SA Arc_SPt Arc_EA Arc_EPt)
	(vl-load-com)
	(defun Get_line ( No / Ent)
		(while
			(progn  (setvar 'errno 0)(setq Ent (car(entsel (strcat "\nSelect Line-" (rtos No 2 0) "..."))))
					(cond ((= 7 (getvar 'errno)) (princ (strcat "\nMissed Line-" (rtos No 2 0) ", try again.")))
						  ((= 'ename (type Ent))
							(if (/= "LINE" (cdr (assoc 0 (entget Ent))))
								(princ "\nSelected object is not a Line.")
							)
						  )
					)
			)
		)
		Ent
	)
	(setq sset (ssadd))
	(setq Line1_Ent (Get_line 1))(ssadd Line1_Ent sset)
	(setq Line2_Ent (Get_line 2))(ssadd Line2_Ent sset)
	(if (not (eq Line1_Ent Line2_Ent))
		(progn
			(setq Line1_Obj (vlax-ename->vla-object Line1_Ent))
			(setq Line2_Obj (vlax-ename->vla-object Line2_Ent))
			(if (not (setq IP_Lines  (inters (vlax-get Line1_Obj "startpoint")(vlax-get Line1_Obj "endpoint")(vlax-get Line2_Obj "startpoint")(vlax-get Line2_Obj "endpoint"))))
					 (setq IP_Lines_Nil  (inters (vlax-get Line1_Obj "startpoint")(vlax-get Line1_Obj "endpoint")(vlax-get Line2_Obj "startpoint")(vlax-get Line2_Obj "endpoint") nil))
			)		 
			(setq Rad (/ (getreal "\nEnter Diameter of Circle: ") 2))
			(setq Point (getpoint "\nPick the side you want to TRIM: "))
			(if (and Rad Point)
				(progn
					(vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
					(setvar 'cmdecho 0)
					(if IP_Lines_Nil
						(if (vlax-curve-getDistAtPoint Line1_Obj IP_Lines_Nil)
							(command "_extend" Line1_Ent "" Line2_Ent "")
							(if (vlax-curve-getDistAtPoint Line2_Obj IP_Lines_Nil)
								(command "_extend" Line2_Ent "" Line1_Ent "")
								(command "_fillet" "r" 0 "_fillet" Line1_Ent Line2_Ent)
							)
						)
					)
					(setq IP_Lines IP_Lines_Nil)
					(entmake (list (cons 0 "LINE")(cons 100 "AcDbEntity")(cons 100 "AcDbPolyline")(cons 10 IP_Lines)(cons 11 Point)))
					(setq Tmp_Line_Obj (vlax-ename->vla-object (setq Cir_Ent (entlast))))
					(entmake (list (cons 0 "CIRCLE")(cons 100 "AcDbEntity")(cons 100 "AcDbCircle")(cons 10 IP_Lines)(cons 40 Rad)))
					(setq Cir_Obj (vlax-ename->vla-object (setq Cir_Ent (entlast))))
					(setq IP_Temp (vlax-safearray->list (vlax-variant-value (vla-intersectwith Cir_Obj Tmp_Line_Obj acextendnone))))
					(vla-delete Tmp_Line_Obj)
					(vla-GetBoundingBox (vlax-ename->vla-object Cir_Ent) 'minPt 'maxpt)
					(vla-ZoomWindow (vlax-get-acad-object) minPt maxpt)
					(command "_.trim" sset "" "f"
								"_none" (polar IP_Temp (angle IP_Temp IP_Lines) (/ Rad 100))
								"_none" (polar IP_Temp (angle IP_Temp Point) (/ Rad 100)) 
								"" ""
					)
					(setq Arc_SA (cdr (assoc 50 (entget Cir_Ent))))
					(setq Arc_SPt (polar IP_Lines Arc_SA Rad))
					(setq Arc_EA (cdr (assoc 51 (entget Cir_Ent))))
					(setq Arc_EPt (polar IP_Lines Arc_EA Rad))
					(if (vlax-curve-getDistAtPoint Line1_Obj Arc_SPt)
						(command "break" Line1_Ent "_none" IP_Lines "_none" Arc_SPt)
						(command "break" Line2_Ent "_none" IP_Lines "_none" Arc_SPt)
					)
					(if (vlax-curve-getDistAtPoint Line2_Obj Arc_EPt)
						(command "break" Line2_Ent "_none" IP_Lines "_none" Arc_EPt)
						(command "break" Line1_Ent "_none" IP_Lines "_none" Arc_EPt)
					)	
					(vla-zoomprevious (vlax-get-acad-object))(setvar 'cmdecho 1)
					(vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
				)
			)
		)
		(princ "\nPicked Lines are Same, Try again.......")
	)
	(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 9 of 20

bedros.j
Enthusiast
Enthusiast

getting better and better !!! thanks

 

one last request since I am testing this now if I have 2 collinear lines and i want to pick line 1 and line 2 it is not doing the procedure

 

2 lines like below let's say

___________     ______________

 

 

 

 

0 Likes
Message 10 of 20

Moshe-A
Mentor
Mentor

@bedros.j 

 

post an example with acute angles. remember that you must be close enough in order it to work smoothly much the same as you done in manually (cause this is based on trim command)

 

'when I miss to Select line one for example, the script is terminating'

Yes, this is true, just the same as most AutoCAD commands works, if you miss to select object or just press enter the command is terminated and if the lines are not intersecting this is also a condition to terminate the command cause the trim will fail right there 😀

 

Moshe

 

 

 

Message 11 of 20

bedros.j
Enthusiast
Enthusiast

@dbhunia  when you fixed the non-interesting lines now the interesting lines are not working and giving an error as below

Pick the side you want to TRIM: ; error: bad DXF group: (10)

0 Likes
Message 12 of 20

dbhunia
Advisor
Advisor
Accepted solution

Sorry 

 

Try this.......

 

(defun c:RH ( / sset Line1_Ent Line2_Ent Line1_Obj Line2_Obj Rad Point IP_Lines IP_Lines_Nil Tmp_Line_Obj Cir_Ent Cir_Obj IP_Temp Arc_SA Arc_SPt Arc_EA Arc_EPt)
	(vl-load-com)
	(defun Get_line ( No / Ent)
		(while
			(progn  (setvar 'errno 0)(setq Ent (car(entsel (strcat "\nSelect Line-" (rtos No 2 0) "..."))))
					(cond ((= 7 (getvar 'errno)) (princ (strcat "\nMissed Line-" (rtos No 2 0) ", try again.")))
						  ((= 'ename (type Ent))
							(if (/= "LINE" (cdr (assoc 0 (entget Ent))))
								(princ "\nSelected object is not a Line.")
							)
						  )
					)
			)
		)
		Ent
	)
	(setq sset (ssadd))
	(setq Line1_Ent (Get_line 1))(ssadd Line1_Ent sset)
	(setq Line2_Ent (Get_line 2))(ssadd Line2_Ent sset)
	(if (not (eq Line1_Ent Line2_Ent))
		(progn
			(setq Line1_Obj (vlax-ename->vla-object Line1_Ent))
			(setq Line2_Obj (vlax-ename->vla-object Line2_Ent))
			(if (not (setq IP_Lines  (inters (vlax-get Line1_Obj "startpoint")(vlax-get Line1_Obj "endpoint")(vlax-get Line2_Obj "startpoint")(vlax-get Line2_Obj "endpoint"))))
					 (setq IP_Lines_Nil  (inters (vlax-get Line1_Obj "startpoint")(vlax-get Line1_Obj "endpoint")(vlax-get Line2_Obj "startpoint")(vlax-get Line2_Obj "endpoint") nil))
			)		 
			(setq Rad (/ (getreal "\nEnter Diameter of Circle: ") 2))
			(setq Point (getpoint "\nPick the side you want to TRIM: "))
			(if (and Rad Point)
				(progn
					(vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
					(setvar 'cmdecho 0)
					(if IP_Lines_Nil
						(if (vlax-curve-getDistAtPoint Line1_Obj IP_Lines_Nil)
							(if (< (distance IP_Lines_Nil (getpropertyvalue Line2_Ent "startpoint")) (distance IP_Lines_Nil (getpropertyvalue Line2_Ent "endpoint")))
								(setpropertyvalue Line2_Ent "startpoint" IP_Lines_Nil)
								(setpropertyvalue Line2_Ent "endpoint" IP_Lines_Nil)
							)
							(if (vlax-curve-getDistAtPoint Line2_Obj IP_Lines_Nil)
								(if (< (distance IP_Lines_Nil (getpropertyvalue Line1_Ent "startpoint")) (distance IP_Lines_Nil (getpropertyvalue Line1_Ent "endpoint")))
									(setpropertyvalue Line1_Ent "startpoint" IP_Lines_Nil)
									(setpropertyvalue Line1_Ent "endpoint" IP_Lines_Nil)
								)								
								(command "_fillet" "r" 0 "_fillet" Line1_Ent Line2_Ent)
							)
						)
					)
					(if IP_Lines_Nil (setq IP_Lines IP_Lines_Nil))
					(entmake (list (cons 0 "LINE")(cons 100 "AcDbEntity")(cons 100 "AcDbPolyline")(cons 10 IP_Lines)(cons 11 Point)))
					(setq Tmp_Line_Obj (vlax-ename->vla-object (setq Cir_Ent (entlast))))
					(entmake (list (cons 0 "CIRCLE")(cons 100 "AcDbEntity")(cons 100 "AcDbCircle")(cons 10 IP_Lines)(cons 40 Rad)))
					(setq Cir_Obj (vlax-ename->vla-object (setq Cir_Ent (entlast))))
					(setq IP_Temp (vlax-safearray->list (vlax-variant-value (vla-intersectwith Cir_Obj Tmp_Line_Obj acextendnone))))
					(vla-delete Tmp_Line_Obj)
					(vla-GetBoundingBox (vlax-ename->vla-object Cir_Ent) 'minPt 'maxpt)
					(vla-ZoomWindow (vlax-get-acad-object) minPt maxpt)
					(command "_.trim" sset "" "f"
								"_none" (polar IP_Temp (angle IP_Temp IP_Lines) (/ Rad 100))
								"_none" (polar IP_Temp (angle IP_Temp Point) (/ Rad 100)) 
								"" ""
					)
					(setq Arc_SA (cdr (assoc 50 (entget Cir_Ent))))
					(setq Arc_SPt (polar IP_Lines Arc_SA Rad))
					(setq Arc_EA (cdr (assoc 51 (entget Cir_Ent))))
					(setq Arc_EPt (polar IP_Lines Arc_EA Rad))
					(if (vlax-curve-getDistAtPoint (vlax-ename->vla-object Line1_Ent) Arc_SPt)
						(command "break" Line1_Ent "_none" IP_Lines "_none" Arc_SPt)
						(command "break" Line2_Ent "_none" IP_Lines "_none" Arc_SPt)
					)
					(if (vlax-curve-getDistAtPoint (vlax-ename->vla-object Line2_Ent) Arc_EPt)
						(command "break" Line2_Ent "_none" IP_Lines "_none" Arc_EPt)
						(command "break" Line1_Ent "_none" IP_Lines "_none" Arc_EPt)
					)	
					(vla-zoomprevious (vlax-get-acad-object))(setvar 'cmdecho 1)
					(vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
				)
			)
		)
		(princ "\nPicked Lines are Same, Try again.......")
	)
	(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 13 of 20

bedros.j
Enthusiast
Enthusiast

Thanks @dbhunia 

All worked except Linear 2 Lines

like below line 1 space then line 2 gives ; error: bad DXF group: (10)

________    __________

0 Likes
Message 14 of 20

dbhunia
Advisor
Advisor

What was your requirement........ you mentioned that.......

 

.......

2mm hole is drawn on the intersection and trimmed as the gif attached

.......

 

In another word "Need" no one can define that..... you can include endless need ........ 

 

So point out your actual need to yourself first..... 🙂

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 15 of 20

bedros.j
Enthusiast
Enthusiast

@dbhunia All is working now Many Many Thanks,

 

just asking if below 2 linear lines are possible to get as shown with hole trimmed with the same lisp

 

111.png

0 Likes
Message 16 of 20

dbhunia
Advisor
Advisor

Ok @bedros.j  do it latter .......

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 17 of 20

bedros.j
Enthusiast
Enthusiast

@dbhunia  i was trying more and more the lisp and it was very useful, thanks

 

  • can it be done in a way that the Diameter to be like a system variable? for example, if I enter it as diameter as 1 it stays as 1 till I change it to other value?? this is just for Fewer picks and Clicks
  • can it be done also that I select as cross polygon the Line 1 and Line 2 or I Pick Line 1 and Line 2 - I mean whatever if possible?

Some common errors

- when the lines are polylines it is not accepting it - so I do explode them it doesn't mind

- when the lines are not in the same plane it is drawing the circle in an intersection without trimming it and drawing a line wherever I pick to trim - again all the errors are for info only

 

thanks again

 

 

0 Likes
Message 18 of 20

dbhunia
Advisor
Advisor

Check this ....... (lightly tested)

 

(defun c:RH ( / sset Line1_Ent Line2_Ent Line1_Obj Line2_Obj Dia Rad Point IP_Lines IP_Lines_Nil Tmp_Line_Obj Cir_Ent Cir_Obj IP_Temp Arc_SA Arc_SPt Arc_EA Arc_EPt)
	(vl-load-com)
	(defun Get_Line ( No / ss )
		(defun Sng_Sel ( msg / sel )
			(princ msg)
			(setvar 'nomutt 1)
			(setq sel (vl-catch-all-apply 'ssget (list '((0 . "LINE")))))
			(setvar 'nomutt 0)
			(if (not (vl-catch-all-error-p sel)) sel)
		)
		(while 	(not (and (setq ss (Sng_Sel (strcat "\nSelect Line-" (rtos No 2 0) "...")))
					(= 1 (sslength ss))
					)
				)
				(if (< 1 (sslength ss))(princ "\nSelect Single Line Only......."))
		)
	(if ss (ssname ss 0))
	)
	
	(setq sset (ssadd))
	(setq Line1_Ent (Get_line 1))(ssadd Line1_Ent sset)
	(setq Line2_Ent (Get_line 2))(ssadd Line2_Ent sset)
	(if (not (eq Line1_Ent Line2_Ent))
		(progn
			(setq Line1_Obj (vlax-ename->vla-object Line1_Ent))
			(setq Line2_Obj (vlax-ename->vla-object Line2_Ent))
			(if (not (setq IP_Lines  (inters (vlax-get Line1_Obj "startpoint")(vlax-get Line1_Obj "endpoint")(vlax-get Line2_Obj "startpoint")(vlax-get Line2_Obj "endpoint"))))
					 (setq IP_Lines_Nil  (inters (vlax-get Line1_Obj "startpoint")(vlax-get Line1_Obj "endpoint")(vlax-get Line2_Obj "startpoint")(vlax-get Line2_Obj "endpoint") nil))
			)		 
			(if (or IP_Lines IP_Lines_Nil)
				(progn
					(if (getenv "Dia") (setq Dia (atof (getenv "Dia")))(setq Dia nil))
					(setq Dia
						(cond
							((getreal (strcat "\nEnter Diameter of Circle" (if Dia (strcat " <" (rtos Dia 2 2) ">: ") ": "))))
							(Dia)
						)
					)
					(if Dia
						(progn
							(setenv "Dia" (rtos Dia 2))
							(setq Rad (/ Dia 2))
							(setq Point (getpoint "\nPick the side you want to TRIM: "))
						)
					)
					(if (and Rad Point)
						(progn
							(vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
							(setvar 'cmdecho 0)
							(if IP_Lines_Nil
								(if (vlax-curve-getDistAtPoint Line1_Obj IP_Lines_Nil)
									(if (< (distance IP_Lines_Nil (getpropertyvalue Line2_Ent "startpoint")) (distance IP_Lines_Nil (getpropertyvalue Line2_Ent "endpoint")))
										(setpropertyvalue Line2_Ent "startpoint" IP_Lines_Nil)
										(setpropertyvalue Line2_Ent "endpoint" IP_Lines_Nil)
									)
									(if (vlax-curve-getDistAtPoint Line2_Obj IP_Lines_Nil)
										(if (< (distance IP_Lines_Nil (getpropertyvalue Line1_Ent "startpoint")) (distance IP_Lines_Nil (getpropertyvalue Line1_Ent "endpoint")))
											(setpropertyvalue Line1_Ent "startpoint" IP_Lines_Nil)
											(setpropertyvalue Line1_Ent "endpoint" IP_Lines_Nil)
										)								
										(command "_fillet" "r" 0 "_fillet" Line1_Ent Line2_Ent)
									)
								)
							)
							(if IP_Lines_Nil (setq IP_Lines IP_Lines_Nil))
							(entmake (list (cons 0 "LINE")(cons 100 "AcDbEntity")(cons 100 "AcDbPolyline")(cons 10 IP_Lines)(cons 11 Point)))
							(setq Tmp_Line_Obj (vlax-ename->vla-object (setq Cir_Ent (entlast))))
							(entmake (list (cons 0 "CIRCLE")(cons 100 "AcDbEntity")(cons 100 "AcDbCircle")(cons 10 IP_Lines)(cons 40 Rad)))
							(setq Cir_Obj (vlax-ename->vla-object (setq Cir_Ent (entlast))))
							(setq IP_Temp (vlax-safearray->list (vlax-variant-value (vla-intersectwith Cir_Obj Tmp_Line_Obj acextendnone))))
							(vla-delete Tmp_Line_Obj)
							(vla-GetBoundingBox (vlax-ename->vla-object Cir_Ent) 'minPt 'maxpt)
							(vla-ZoomWindow (vlax-get-acad-object) minPt maxpt)
							(command "_.trim" sset "" "f"
										"_none" (polar IP_Temp (angle IP_Temp IP_Lines) (/ Rad 100))
										"_none" (polar IP_Temp (angle IP_Temp Point) (/ Rad 100)) 
										"" ""
							)
							(setq Arc_SA (cdr (assoc 50 (entget Cir_Ent))))
							(setq Arc_SPt (polar IP_Lines Arc_SA Rad))
							(setq Arc_EA (cdr (assoc 51 (entget Cir_Ent))))
							(setq Arc_EPt (polar IP_Lines Arc_EA Rad))
							(if (vlax-curve-getDistAtPoint (vlax-ename->vla-object Line1_Ent) Arc_SPt)
								(command "break" Line1_Ent "_none" IP_Lines "_none" Arc_SPt)
								(command "break" Line2_Ent "_none" IP_Lines "_none" Arc_SPt)
							)
							(if (vlax-curve-getDistAtPoint (vlax-ename->vla-object Line2_Ent) Arc_EPt)
								(command "break" Line2_Ent "_none" IP_Lines "_none" Arc_EPt)
								(command "break" Line1_Ent "_none" IP_Lines "_none" Arc_EPt)
							)	
							(vla-zoomprevious (vlax-get-acad-object))(setvar 'cmdecho 1)
							(vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
						)
					)
				)
				(Princ "\nLines are not Intersecting check Lines (Elevations).......")
			)
		)
		(princ "\nPicked Lines are Same, Try again.......")
	)
	(princ)
)

 

There are two question to you....... Answer me logically & programmatically first ....... then I should move further .......

 

  1.   When two lines are collinear, how can you decide the point of intersection.
  2.   When you select two Poly line, what should be its point of intersection (whether they are intersecting with each other Or the intersection point will get by extending two pairs of end point taking one end from each poly lines).

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 19 of 20

bedros.j
Enthusiast
Enthusiast

@dbhunia 

Good Question. if we have linear i need to pick the Point which will draw the circle and join the lines and trim it - i might pick mid between two points or either end... so we might do that as separate lisp?? if it conflicts with the first one - 

 

as for the Selection with cross polygon and picking object it worked - but Can you please if i pick Line 1 or Select Line 1 - Let it do Enter Automatically and not me hit enter - that will reduce hit and picks

 

as for picking radius and keeping Records - it worked thanks

0 Likes
Message 20 of 20

bedros.j
Enthusiast
Enthusiast

@dbhunia 

can we after selecting a line or picking get an Enter automatically without me hitting enter, please? thanks!

0 Likes