Author Topic: Polylines with Chamfers should be removed.  (Read 770 times)

0 Members and 1 Guest are viewing this topic.

RogerMurray

  • Mosquito
  • Posts: 1
Polylines with Chamfers should be removed.
« on: August 21, 2022, 09:38:34 AM »
I honestly don't know where to begin with this one. Assume I have a polyline with chamfers and want to remove the chamfers, essentially restoring the polyline to its original state before using the chamfer command. I considered simply saving extended data to the entity of what the original vertexes were, but the problem with that approach is that if the polyline was modified after adding the chamfers, you would lose those edits as well. I'm guessing I'd have to specify a maximum chamfer size to remove, but beyond that, I'm stumped. Thank you for your help!

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: Polylines with Chamfers should be removed.
« Reply #1 on: August 21, 2022, 10:00:10 AM »
Similar question was raised in the past... Search www deeply...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

nekonihonjin

  • Newt
  • Posts: 103
Re: Polylines with Chamfers should be removed.
« Reply #2 on: August 21, 2022, 10:09:57 AM »
Why not just fillet with rad 0.0  the lines?

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: Polylines with Chamfers should be removed.
« Reply #3 on: August 21, 2022, 10:28:18 AM »
Quick one...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:unchamfer-unfillet ( / lw lwx pl ll f pre suf lll ) ;; *fuzz* - global variable ;;
  2.   (if
  3.     (and
  4.       (setq lw (car (entsel "\nPick chamfered/filleted LWPOLYLINE...")))
  5.       (and lw (= (cdr (assoc 0 (setq lwx (entget lw)))) "LWPOLYLINE"))
  6.       (or *fuzz* (initget 7) (setq *fuzz* (getdist "\nPick or specify guessing chamfer-fillet distance : ")))
  7.     )
  8.     (progn
  9.       (setq pl (mapcar (function cdr) (vl-remove-if (function (lambda ( x ) (/= (car x) 10))) lwx)))
  10.       (setq ll (mapcar (function (lambda ( a b c d / ip ) (if (and (setq ip (inters a b c d nil)) (<= (distance b ip) *fuzz*) (<= (distance c ip) *fuzz*)) (progn (setq f t) ip) (if (not f) b (setq f nil))))) (cons (last pl) (reverse (cdr (reverse pl)))) pl (append (cdr pl) (list (car pl))) (append (cddr pl) (list (car pl) (cadr pl)))))
  11.       (setq pre (reverse (cdr (member (assoc 10 lwx) (reverse lwx)))))
  12.       (setq suf (cdr (member (assoc 10 (reverse lwx)) lwx)))
  13.       (setq lll (append pre (mapcar (function (lambda ( x ) (cons 10 x))) ll) suf))
  14.       (entupd (cdr (assoc -1 (entmod lll))))
  15.     )
  16.   )
  17.   (princ)
  18. )
  19.  
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube