how to use chamfer in lisp only for perpedicular lines

how to use chamfer in lisp only for perpedicular lines

E.S.7.9
Advocate Advocate
2,260 Views
2 Replies
Message 1 of 3

how to use chamfer in lisp only for perpedicular lines

E.S.7.9
Advocate
Advocate

hello 

i wanna use automatic chamfer only for perpendicular plines . which code  should i add to lisp below

i found function 

(defun angle90 (p1 p2 p3)
  (vl-some '(lambda (ang) (equal (abs (- (angle p1 p2) (angle p2 p3))) ang 1e-4))
            (list (* pi 0.5) (* pi 1.5) (+ pi pi))
    )
  )

something like that but i think i can use it only if i use getpoint in my function ... how to do it on multiple point polyline set ?

 

thanks for help 

 

 

(defun c:test ()

(command "_.pline")
(while (> (getvar 'cmdactive) 0)
(command pause)
(setq aa (entlast))
); while
(command "_.chamfer" "_polyline" aa)

 (princ))

0 Likes
Accepted solutions (1)
2,261 Views
2 Replies
Replies (2)
Message 2 of 3

dbhunia
Advisor
Advisor

Try this......Roughly tested.....Assuming "chamfer distance" is predefined/you can take care of it (by setting/getting the value of System Variable CHAMFERA CHAMFERB)...

 

(defun c:test ();;Put temp Variables

(defun angle90 (p1 p2 p3)
  (vl-some '(lambda (ang) (equal (abs (- (angle p1 p2) (angle p2 p3))) ang 1e-4))
            (list (* pi 0.5) (* pi 1.5) (+ pi pi))
    )
)
(defun Poly_Cor_Extr (key cor / val cor_list)
   (foreach val cor
	(if (eq key (car val)) (setq cor_list (cons (cdr val) cor_list)))
   )
(reverse cor_list)
)
(defun GBX (ent);;Put temp Variables
   (vla-getBoundingBox (vlax-ename->vla-object ent) 'll 'ur)
   (setq LL (vlax-safearray->list ll))
   (setq UR (vlax-safearray->list ur))
)

(command "_.pline")
(while (> (getvar 'cmdactive) 0)
    (command pause)
    (setq aa (entlast))
);while

(setq cmd (getvar 'cmdecho))
(setvar 'cmdecho 0)
(setq lst (Poly_Cor_Extr 10 (entget aa)))
(setq l 0)
(repeat (setq N (- (length lst) 2))
	(if (= T (ANGLE90 (nth l lst) (nth (setq l (+ l 1)) lst) (nth (+ l 1) lst)))
	    (progn
		(setq PT1 (nth (- l 1) lst)
		      PT2 (nth l lst)
		      PT3 (nth (+ l 1) lst)
		      M1 (polar PT1 (angle PT1 PT2) (/ (distance PT1 PT2) 2))
		      M2 (polar PT2 (angle PT2 PT3) (/ (distance PT2 PT3) 2))
		)
		(command "_point" M1)
		(GBX (entlast))
		(setq p11 ll p12 ur)
		(entdel (entlast))
		(command "_point" M2)
		(GBX (entlast))
		(setq p21 ll p22 ur)
		(entdel (entlast))
		(command "_.chamfer" (ssget "c" p11 p12) (ssget "c" p21 p22))
	    )
	)
)
(setvar 'cmdecho cmd)
(princ)
)

 


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

Kent1Cooper
Consultant
Consultant
Accepted solution

@E.S.7.9 wrote:

.... i wanna use automatic chamfer only for perpendicular plines . ... how to do it on multiple point polyline set ?

....


 

Here's one [the attached ChamferPline90.lsp with its CP90 command] that:

A.  Does not include the drawing of a Polyline inside it, but asks you to select, and you can select as many as you want at once;

B.  Handles Polylines with arc segments without error [ignoring corners where either adjacent segment is an arc];

C.  Works with both "lightweight" and "heavy" [but only 2D, not 3D] Polylines;

D.  Does all qualifying corners of closed [and even of only-"visually"-closed] Polylines;

E.  Avoids "Chamfer distance is too large" errors by skipping corners where adjacent segments are not at least as long as Chamfer distance settings;

F.  Uses current Chamfer distances, but if either of them is set to zero, asks for non-zero values.

 

See further comments at the top of the file.

Kent Cooper, AIA
0 Likes