Author Topic: weed pline by angle  (Read 2307 times)

0 Members and 1 Guest are viewing this topic.

mohobrien

• Guest
weed pline by angle
« on: May 28, 2008, 05:31:13 PM »
I have a pline that defines the boundary of a parcel. The pline is zero width and no special properties. I want to simplify the pline so that only major changes of direction, say more than 45° will be shown. All bends in the line are close to 90° so if I use 45 I should get what I want. I'm not interested in how far apart the vertices are. This little snippet is what I am using to weed the extra vertices. Most of the time it works, but sometimes it misses vetices to remove and sometimes removes what it shouldn't. I think it is a problem with my angle test. Any ideas? finalcoordlist is just that and newcoordlist is the unweeded list.
Code: [Select]
`;;;            remove vertices if major change in direction (setq finalcoordlist        newcoordlist       counter 0 ) (repeat (- (length newcoordlist) 2)   (setq pt1 (nth counter newcoordlist))   (setq pt2 (nth (+ counter 1) newcoordlist))   (setq pt3 (nth (+ counter 2) newcoordlist))   (if     (< (abs (- (angle pt1 pt2) (angle pt2 pt3)))        (* (/ 45.0 180.0) pi)     )      (setq finalcoordlist     (vl-remove (nth (+ counter 1) newcoordlist)        finalcoordlist     )    counter (1+ counter)      )      (setq counter (1+ counter))   ) )`

DEVITG

• Bull Frog
• Posts: 481
Re: weed pline by angle
« Reply #1 on: June 05, 2008, 08:50:40 AM »
Hi , can you upload some dwg sample .?
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

CAB

• Global Moderator
• Seagull
• Posts: 10401
Re: weed pline by angle
« Reply #2 on: June 05, 2008, 09:52:02 AM »
Make use of the function vlax-curve-getFirstDeriv like this
Code: [Select]
`(defun C:TEST ()  (vl-load-com)  (setq curve (car (entsel "\nSelect polyline: ")))  (setq end_param (vlax-curve-getendparam curve))  (setq par 0)  (repeat (fix end_param)    (print (angle '(0 0) (vlax-curve-getFirstDeriv curve par)))    (setq par (1+ par))  )  (princ))`
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

DEVITG

• Bull Frog
• Posts: 481
Re: weed pline by angle
« Reply #3 on: June 05, 2008, 07:08:25 PM »
;;;Hi Cab I did a test with your lisp , an it give not the , say, included angle among two consecutive lines .
;;;This is so, because  the first derivative [ FD ] give the  tangent of a curve at that point,
;;or also it give the idea how the curve is growing or decaying at that point.
;;;When curve is a line ,  it give the  tangent at that point that in this case is the same as the line angle.
;;;Also in this case , I do not know if ACAD take the value for the ending line or starting line at a given parameter.
;;;I think that if we take  the  the FD at ( - param 0.1)  , and at (+  param 0.1) , it will give 2 angles , and from it,
;; we can get angle between the lines.Not so sure.
;;;I'm doing now some test .
;;;From it I knew that the FD at Param give the angle for the after the param

Location @ Córdoba Argentina Using ACAD 2019  at Window 10

CAB

• Global Moderator
• Seagull
• Posts: 10401
Re: weed pline by angle
« Reply #4 on: June 05, 2008, 07:40:26 PM »
DEVITG,
Try this code:
Code: [Select]
`(defun C:TEST (/ curve end_param par MinAng LastAng RemoveLst)  (vl-load-com)  (setq curve (car (entsel "\nSelect polyline: ")))  (setq end_param (vlax-curve-getendparam curve))  (setq par 0        MinAng (/ pi 4) ; 45 deg        )  (repeat (fix end_param)    (cond      ((null LastAng) ; get the ang of the first segment       (setq LastAng (angle '(0 0) (vlax-curve-getFirstDeriv curve par))))      ((< (abs (- LastAng               (setq LastAng (angle '(0 0) (vlax-curve-getFirstDeriv curve par)))))          MinAng)       (setq RemoveLst (cons par RemoveLst))                      )      )    (setq par (1+ par))  )  (if RemoveLst ; need to remove these vertex    (princ RempveLst)  )  (princ))`
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

DEVITG

• Bull Frog
• Posts: 481
Re: weed pline by angle
« Reply #5 on: June 05, 2008, 08:17:07 PM »
Hi Cab, please can you check it on this dwg .
I did it , and I got NIL

maybe I´m doing something wrong.
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

CAB

• Global Moderator
• Seagull
• Posts: 10401
Re: weed pline by angle
« Reply #6 on: June 05, 2008, 09:10:35 PM »
Yes, all those angles are greater than 45 degrees.

See attached drawing.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

DEVITG

• Bull Frog
• Posts: 481
Re: weed pline by angle
« Reply #7 on: June 05, 2008, 09:17:52 PM »
Hi Cab ,  I toke a bad concept ,
I thought it was internal angles  at  the polyline .
Now I got it, it  was deviation angle from the prior segment .
cause my poor English.

Location @ Córdoba Argentina Using ACAD 2019  at Window 10

CAB

• Global Moderator
• Seagull
• Posts: 10401
Re: weed pline by angle
« Reply #8 on: June 05, 2008, 10:17:51 PM »
OK
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

DEVITG

• Bull Frog
• Posts: 481
Re: weed pline by angle
« Reply #9 on: June 06, 2008, 07:12:29 AM »
Hi Cad , and how it can be get the "internal"  angle of a poly ?

Location @ Córdoba Argentina Using ACAD 2019  at Window 10

fixo

• Guest
Re: weed pline by angle
« Reply #10 on: June 06, 2008, 08:34:52 AM »
Hi Cad , and how it can be get the "internal"  angle of a poly ?

DEVITG

• Bull Frog
• Posts: 481
Re: weed pline by angle
« Reply #11 on: June 06, 2008, 09:34:09 AM »
Hi Cad , and how it can be get the "internal"  angle of a poly ?