Works for lines I think.
-EDITED FROM HERE-
This appears to work for Polylines - I haven't tested it fully and no error catching such as polyline segments shorter than the chamfer distance, or a full range of line angles. Could be made to work more like a regular chamfer, and perhaps could be called notchchamer as a LISP name, test wi;l do for now....
Should be able to be modified later to do lines and polylines
(defun c:test ( / chdist coords1 coords2 pline NL1 NL2 NL3 NL3PtA NL3 PtB int ptsa)
(defun MakeLine ( con10 con11 / )
(entmakex (append (list (cons 0 "LINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbLine")
(cons 10 con10)
(cons 11 con11)
))
)
)
;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-polyline-segment/td-p/1758253
(defun test ( / elst ename pt param preparam postparam)
(setq elst (entsel "\nSelect pline segment: "))
(setq ename (car elst))
(setq pt (cadr elst))
(setq pt (vlax-curve-getClosestPointTo ename pt))
(print (setq param (vlax-curve-getParamAtPoint ename pt)) )
(print (setq preparam (fix param)) )
(print (setq postparam (1+ preparam)) )
(list
(vlax-curve-getPointAtParam ename preparam)
(vlax-curve-getPointAtParam ename postparam)
elst
)
)
(defun trimlinetopt ( MyLine TrimPt1 TrimPt2 / MyLineDef MyLineEndA MyLineEndB Pt1Dist Pt2Dist TempPT MyLineA MyLineB)
(command "zoom" "Object" MyLine "")
(command "zoom" "0.95x")
(setq MyLineDef (entget MyLine))
(setq MyLineEndA (cdr (assoc 10 MyLineDef)))
(if (= (cdr (assoc 0 MyLineDef)) "LINE")
(setq MyLineEndB (cdr (assoc 11 MyLineDef)))
(setq MyLineEndB (cdr (assoc 10 (reverse MyLineDef))))
)
;;sort trimpts according to distance from end A
(setq Pt1Dist (vlax-curve-getdistatpoint MyLine (osnap TrimPt1 "nea")) )
(setq Pt2Dist (vlax-curve-getdistatpoint MyLine (osnap TrimPt2 "nea")) )
(if ( > Pt1Dist Pt2Dist)
(progn
(setq TempPt TrimPt1)
(setq TrimPt1 TrimPt2)
(setq TrimPt2 TempPt)
) ;end progn
) ;end if
(command "breakatpoint" MyLine TrimPt1)
(setq MyLineA (entlast))
(command "breakatpoint" MyLineA TrimPt2)
(setq MyLineB (entlast))
(entdel MyLineA)
(command "zoom" "Previous")
(command "zoom" "Previous")
MyLineA
)
;; add here something nice like "select lines or [option]"
;; Also add here something nice to remember value from last time
(setq chdist (getreal "Enter Chamfer Distance: "))
(setq coords1 (test))
(setq coords2 (test))
(setq pline (car (last coords1)))
(setq NL1 (makeline (car coords1) (cadr coords1)) ); templine 1
(setq NL2 (makeline (car coords2) (cadr coords2)) ); templine 2
; (setq chdist 25)
(command "chamfer" NL1 "Distance" chdist chdist NL2)
(setq NL3 (entlast))
(setq NL3PtA (cdr (assoc 10 (entget NL3))) )
(setq NL3PtB (cdr (assoc 11 (entget NL3))) )
(command "move" NL1 "" NL3PtA NL3PtB )
(command "move" NL2 "" NL3PtB NL3PtA )
(setq int (vLa-intersectwith (vLax-ename->vLa-Object NL1) (vLax-ename->vLa-Object NL2) acextendnone) )
(setq ptsa (vLax-safearray->List (vLax-variant-vaLue int)))
(entdel NL1)
(entdel NL2)
(setq NL1 (makeline ptsa NL3PtA) ); templine 3
(setq NL2 (makeline ptsa NL3PtB) ); templine 4
(entdel NL3)
(trimlinetopt pline NL3PtA NL3PtB)
(command "join" pline (entlast) NL1 NL2 "")
)