Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Delete arcs from pline - lisp request
« previous
next »
Print
Pages:
1
[
2
]
All
|
Go Down
Author
Topic: Delete arcs from pline - lisp request (Read 4778 times)
0 Members and 1 Guest are viewing this topic.
ribarm
Gator
Posts: 3310
Marko Ribar, architect
WWW
Re: Delete arcs from pline - lisp request
«
Reply #15 on:
December 10, 2023, 04:32:55 PM »
Here you are... Just make sure start and end segments are straight... And you have to have at least single straight between arced segments...
Code - Auto/Visual Lisp:
[Select]
;; Decurve - Lee Mac
;; Equivalent to applying a zero-radius fillet to a polyline with arc-segments
(
defun
c:decurve
(
/
ptonline lwv
-
ptb LM:BulgeRadius unique k enx hed idx int lst ocs rtn sel
)
(
defun
ptonline
(
pt1 pt2 pt3
)
(
equal
(
distance
pt1 pt3
)
(
+
(
distance
pt1 pt2
)
(
distance
pt2 pt3
)
)
1e
-
8
)
)
(
defun
lwv
-
ptb
(
lst
)
(
if
(
setq
lst
(
member
(
assoc
10
lst
)
lst
)
)
(
cons
(
list
(
assoc
10
lst
)
(
assoc
42
lst
)
)
(
lwv
-
ptb
(
cdr
lst
)
)
)
)
)
;; Bulge Radius - Lee Mac
;; p1 - start vertex
;; p2 - end vertex
;; b - bulge
;; Returns the radius of the arc described by the given bulge and vertices
(
defun
LM:BulgeRadius
(
p1 p2 b
)
(
/
(
*
(
distance
p1 p2
)
(
1+
(
*
b b
)
)
)
4
(
abs
b
)
)
)
(
defun
unique
(
lst
/
a ll
)
(
while
(
setq
a
(
car
lst
)
)
(
if
(
vl-some
(
function
(
lambda
(
x
)
(
equal
x a 1e
-
6
)
)
)
(
cdr
lst
)
)
(
setq
ll
(
cons
a ll
)
lst
(
vl
-
remove
-
if
(
function
(
lambda
(
x
)
(
equal
x a 1e
-
6
)
)
)
(
cdr
lst
)
)
)
(
setq
ll
(
cons
a ll
)
lst
(
cdr
lst
)
)
)
)
(
reverse
ll
)
)
(
while
(
=
8
(
logand
8
(
getvar
'undoctl
)
)
)
(
vl-cmdf
"_.undo"
"_e"
)
)
(
vl-cmdf
"_.undo"
"_be"
)
(
if
(
and
(
setq
sel
(
ssget
"_:L"
'
(
(
0
.
"LWPOLYLINE"
)
(
-
4
.
"<NOT"
)
(
-
4
.
"&="
)
(
70
.
1
)
(
-
4
.
"NOT>"
)
)
)
)
(
not
(
initget
7
)
)
(
setq
rad
(
getdist
"
\n
Pick or specify top radius of curving to preserve curvature : "
)
)
)
(
repeat
(
setq
idx
(
sslength
sel
)
)
(
setq
enx
(
entget
(
ssname
sel
(
setq
idx
(
1-
idx
)
)
)
)
hed
(
reverse
(
member
(
assoc
38
enx
)
(
reverse
enx
)
)
)
ocs
(
cdr
(
assoc
210
enx
)
)
lst
nil
lst
(
lwv
-
ptb enx
)
rtn
nil
)
(
setq
k
-
1
)
(
foreach
x lst
(
setq
k
(
1+
k
)
)
(
cond
(
(
equal
0.0
(
cdr
(
assoc
42
x
)
)
1e
-
8
)
(
setq
rtn
(
cons
x rtn
)
)
)
(
t
(
if
(
>
(
LM:BulgeRadius
(
cdr
(
car
(
nth
k lst
)
)
)
(
cdr
(
car
(
nth
(
1+
k
)
lst
)
)
)
(
cdr
(
cadr
(
nth
k lst
)
)
)
)
rad
)
(
if
(
<=
(
+
k
2
)
(
1-
(
length
lst
)
)
)
(
progn
(
setq
int
(
inters
(
cdr
(
car
(
nth
(
1-
k
)
lst
)
)
)
(
cdr
(
car
(
nth
k lst
)
)
)
(
cdr
(
car
(
nth
(
1+
k
)
lst
)
)
)
(
cdr
(
car
(
nth
(
+
2
k
)
lst
)
)
)
nil
)
)
(
setq
rtn
(
cons
(
list
(
cons
10
(
cdr
(
car
(
nth
k lst
)
)
)
)
(
cons
42
0.0
)
)
rtn
)
)
(
setq
rtn
(
cons
(
list
(
cons
10
int
)
(
cons
42
0.0
)
)
rtn
)
)
(
setq
rtn
(
cons
(
list
(
cons
10
(
cdr
(
car
(
nth
(
1+
k
)
lst
)
)
)
)
(
cons
42
0.0
)
)
rtn
)
)
)
)
(
setq
rtn
(
cons
x rtn
)
)
)
)
)
)
(
setq
rtn
(
unique rtn
)
)
(
if
(
entmake
(
append
(
subst
(
cons
90
(
length
rtn
)
)
(
assoc
90
hed
)
hed
)
(
apply
'
append
(
reverse
rtn
)
)
(
list
(
cons
210
ocs
)
)
)
)
(
entdel
(
cdr
(
assoc
-
1
enx
)
)
)
)
)
)
(
vl-cmdf
"_.undo"
"_e"
)
(
princ
)
)
HTH.
M.R.
«
Last Edit: December 11, 2023, 07:13:58 AM by ribarm
»
Logged
Marko Ribar, d.i.a.
(graduated engineer of architecture)
M.R. on Youtube
Print
Pages:
1
[
2
]
All
|
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Delete arcs from pline - lisp request