Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LINE Trim and/or Erase offset side

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
204 Views, 4 Replies

LINE Trim and/or Erase offset side

Ok guys,

I've over complicated this 1.

The base premise is to select the green line, pick the offset side, erase
all lines that exist entirely on the offset side, and trim lines that extend
thru the green line vector extended infinitely back to the vector. I've
started with clockwise tests for the 3 points ( 1 2 3 ). I'm stuck on a
good test to see if points are on the offset side or not. The end result
would be that only the blue lines remain. Any suggestions out there?
TIA -David




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.282 / Virus Database: 150 - Release Date: 9/26/01
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

David,

I'll give you what little expertise I have in this area. Lets assign the
boxes label 1, 2, and 3 to p1, p2, and p3. Using Tony's vector side
function you can determine where the endpoints of each line are relative to
your green vector.

First, to get the second argument to vector-side, subtract the coordinates
to get the direction vector.

(setq v2 (mapcar '- p2 p1))

Then find out which side p3 is on.

(vector-side p1 v2 p3)

Then trim or erase based on which side the two points of the line are on.
--
Cliff

;-----------------------------------------------------------------
;Here is one from the master Tony Tanzillo, enjoy

;;; (vector-side )
;;; Returns an integer code indicating position of
;;; in relation to the directed vector whose endpoints are
;;; and .
;;; Result Meaning
;;; -1 Point is to the right of vector.
;;; 0 Point is on (colinear with) vector
;;; 1 Point is to the left of vector.

(defun vector-side (v1 v2 p / r)
(setq
r
(-
(* (- (car v2) (car v1)) (- (cadr p) (cadr v1)))
(* (- (cadr v2) (cadr v1)) (- (car p) (car v1)))
)
)
(cond
((equal r 0.0 1e-8) 0)
(t (fix (/ (abs r) r)))
)
)



"David Bethel" wrote in message
news:BA5F77B301E27160ED742AB507C5AF51@in.WebX.maYIadrTaRb...
| Ok guys,
|
| I've over complicated this 1.
|
| The base premise is to select the green line, pick the offset side, erase
| all lines that exist entirely on the offset side, and trim lines that
extend
| thru the green line vector extended infinitely back to the vector. I've
| started with clockwise tests for the 3 points ( 1 2 3 ). I'm stuck on a
| good test to see if points are on the offset side or not. The end result
| would be that only the blue lines remain. Any suggestions out there?
| TIA -David
|
|
|
|
| ---
| Outgoing mail is certified Virus Free.
| Checked by AVG anti-virus system (http://www.grisoft.com).
| Version: 6.0.282 / Virus Database: 150 - Release Date: 9/26/01
|
|


----------------------------------------------------------------------------
----
Message 3 of 5
Anonymous
in reply to: Anonymous

Cliff, you were on the right track.

I don't think the vector direction is needed. p1 & p2 define the vector.
Tony's routine is looking the endpoints and a test point. I was testing for
the 3 points being clock/counterclock. Same principal just that vector-side
returns integer value that is very easy to test.

Here's what I have now & it works so far.

Thanks! -David


;;; From Tony Tanzillo
;;; (vector-side )
;;; Returns an integer code indicating position of
;;; in relation to the directed vector whose endpoints are
;;; and .
;;; Result Meaning
;;; -1 Point is to the right of vector.
;;; 0 Point is on (colinear with) vector
;;; 1 Point is to the left of vector.

(defun vector-side (v1 v2 p / r)
(setq
r
(-
(* (- (car v2) (car v1)) (- (cadr p) (cadr v1)))
(* (- (cadr v2) (cadr v1)) (- (car p) (car v1)))
)
)
(cond
((equal r 0.0 1e-8) 0)
(t (fix (/ (abs r) r)))
)
)

;;;STRING OF ALL VISIBLE LAYERS
(defun layer_show (/ ldef ls)
(setq ls "")
(while (setq ldef (tblnext "LAYER" (not ldef)))
(if (and (or (= 0 (cdr (assoc 70 ldef)))
(= 64 (cdr (assoc 70 ldef))))
(not (minusp (cdr (assoc 62 ldef)))))
(setq ls (strcat ls "," (cdr (assoc 2 ldef))))))
(substr ls 2))

;;;SIMPLE ENTMOD
(defun emod (enam grp val / entd ov nv)
(setq entd (entget enam '("*")))
(setq ov (assoc grp entd)
nv (cons grp val)
entd (subst nv ov entd))
(entmod entd))

;;;REMOVE ALL LINE SEGEMENTS ON 1 SIDE OF A SPECIFIED VECTOR

(defun c:trimside (/ p1 p2 op v1 ss i en ed p10 p11)

(initget 1)
(setq p1 (getpoint "\nFirst Trim Line Point: "))

(initget 1)
(setq p2 (getpoint p1 "\nSecond Trim Line Point: "))

(initget 1)
(setq op (getpoint "\nTrim Side: "))

(if (not (setq ss (ssget "X" (list (cons 0 "LINE")
(cons 8 (layer_show))))))
(exit))

(setq i (sslength ss)
v1 (vector-side p1 p2 op))

(while (not (minusp (setq i (1- i))))
(setq en (ssname ss i)
ed (entget en)
p10 (cdr (assoc 10 ed))
p11 (cdr (assoc 11 ed)))
(cond ((= (vector-side p1 p2 p10)
(vector-side p1 p2 p11) v1)
(entdel en))
((= (vector-side p1 p2 p10) v1)
(emod en 10 (inters p1 p2 p10 p11 nil)))
((= (vector-side p1 p2 p11) v1)
(emod en 11 (inters p1 p2 p10 p11 nil)))))
(prin1))


http://64.83.21.33/lisp/trimside.htm
Message 4 of 5
Anonymous
in reply to: Anonymous

Sounds too complicated for such a simple task.

You don't need to pick too many points.

Use 'entsel' to select the green line, then return the 10 and 11, then pick
point of side.

Using a little common sense you'll have the utility square the direction and
gather any lines crossing the line and you pretty much can figure the rest.

If you don't understand my explanation I'll gladly go into detail.

The only thing you'll have to predetermine is figure how far out you wish to
delete any additional lines.

--
Rudy@cadentity.com
Practical Utilities for Productive Solutions
www.cadentity.com

"David Bethel" wrote in message
news:43EA5AA6913867838A0DD2C700471371@in.WebX.maYIadrTaRb...
> Cliff, you were on the right track.
>
> I don't think the vector direction is needed. p1 & p2 define the vector.
> Tony's routine is looking the endpoints and a test point. I was testing
for
> the 3 points being clock/counterclock. Same principal just that
vector-side
> returns integer value that is very easy to test.
>
> Here's what I have now & it works so far.
>
> Thanks! -David
>
>
> ;;; From Tony Tanzillo
> ;;; (vector-side )
> ;;; Returns an integer code indicating position of
> ;;; in relation to the directed vector whose endpoints are
> ;;; and .
> ;;; Result Meaning
> ;;; -1 Point is to the right of vector.
> ;;; 0 Point is on (colinear with) vector
> ;;; 1 Point is to the left of vector.
>
> (defun vector-side (v1 v2 p / r)
> (setq
> r
> (-
> (* (- (car v2) (car v1)) (- (cadr p) (cadr v1)))
> (* (- (cadr v2) (cadr v1)) (- (car p) (car v1)))
> )
> )
> (cond
> ((equal r 0.0 1e-8) 0)
> (t (fix (/ (abs r) r)))
> )
> )
>
> ;;;STRING OF ALL VISIBLE LAYERS
> (defun layer_show (/ ldef ls)
> (setq ls "")
> (while (setq ldef (tblnext "LAYER" (not ldef)))
> (if (and (or (= 0 (cdr (assoc 70 ldef)))
> (= 64 (cdr (assoc 70 ldef))))
> (not (minusp (cdr (assoc 62 ldef)))))
> (setq ls (strcat ls "," (cdr (assoc 2 ldef))))))
> (substr ls 2))
>
> ;;;SIMPLE ENTMOD
> (defun emod (enam grp val / entd ov nv)
> (setq entd (entget enam '("*")))
> (setq ov (assoc grp entd)
> nv (cons grp val)
> entd (subst nv ov entd))
> (entmod entd))
>
> ;;;REMOVE ALL LINE SEGEMENTS ON 1 SIDE OF A SPECIFIED VECTOR
>
> (defun c:trimside (/ p1 p2 op v1 ss i en ed p10 p11)
>
> (initget 1)
> (setq p1 (getpoint "\nFirst Trim Line Point: "))
>
> (initget 1)
> (setq p2 (getpoint p1 "\nSecond Trim Line Point: "))
>
> (initget 1)
> (setq op (getpoint "\nTrim Side: "))
>
> (if (not (setq ss (ssget "X" (list (cons 0 "LINE")
> (cons 8 (layer_show))))))
> (exit))
>
> (setq i (sslength ss)
> v1 (vector-side p1 p2 op))
>
> (while (not (minusp (setq i (1- i))))
> (setq en (ssname ss i)
> ed (entget en)
> p10 (cdr (assoc 10 ed))
> p11 (cdr (assoc 11 ed)))
> (cond ((= (vector-side p1 p2 p10)
> (vector-side p1 p2 p11) v1)
> (entdel en))
> ((= (vector-side p1 p2 p10) v1)
> (emod en 10 (inters p1 p2 p10 p11 nil)))
> ((= (vector-side p1 p2 p11) v1)
> (emod en 11 (inters p1 p2 p10 p11 nil)))))
> (prin1))
>
>
> http://64.83.21.33/lisp/trimside.htm
>
>
>
>
Message 5 of 5
Anonymous
in reply to: Anonymous

Rudy,

>> Use 'entsel' to select the green line, then return the 10 and 11, then
pick point of side. <<

In the final application, the green line will not be present, so the user
will have to designate the vector.

>> Using a little common sense you'll have the utility square the direction
and
gather any lines crossing the line and you pretty much can figure the rest.
<<

AFAIK, windows and crossing are always WCS oriented. I need this to be
align with the specified vector.

>> The only thing you'll have to predetermine is figure how far out you wish
to
delete any additional lines. <<

Infinitly.

These line drawing are created using DXBIN. I'm looking to trim certain
areas as need. The 1 would put the emphisis on Box #2.

Thanks -David

"Rudy Tovar" wrote in message
news:4E5D5524627CFAC5ED9483570038CD2D@in.WebX.maYIadrTaRb...
> Sounds too complicated for such a simple task.
>




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.282 / Virus Database: 150 - Release Date: 9/27/01

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost