# Thread: EXTRIM Between Two Lines

1. Registered forum members do not see this ad.

Slightly different than I proposed with polygon - now obtaining points directly from middle distance of 2 radius...

Code:
```(defun c:trim_between_2_concentic_circles ( / inner_circle outer_circle c1 c2 c r1 r2 r k p pl )

(setq inner_circle (car (entsel "\nPick inner circle")))
(setq outer_circle (car (entsel "\nPick outer circle")))
(setq c1 (cdr (assoc 10 (entget inner_circle))))
(setq c2 (cdr (assoc 10 (entget outer_circle))))
(setq c (mapcar '* (mapcar '+ c1 c2) '(0.5 0.5 0.5)))
(setq r1 (cdr (assoc 40 (entget inner_circle))))
(setq r2 (cdr (assoc 40 (entget outer_circle))))
(setq r (/ (+ r1 r2) 2.0))
(setq k -1.0)
(repeat 360
(setq p (polar c (cvunit (setq k (1+ k)) "degrees" "radians") r))
(setq pl (cons p pl))
)
(setq pl (cons (polar c 0.0 r) pl))
(command "_.trim" inner_circle outer_circle "" "_F")
(foreach p pl
(command p)
)
(while (> (getvar 'cmdactive) 0) (command ""))
(princ)
)

(defun c:tb2cc nil (c:trim_between_2_concentic_circles))```
HTH, M.R.

2. Thank you marko. Works like a charm.

3. Originally Posted by ReMark
I can't because I don't have a link to it. Anyway, it did work the first time I used it in a test drawing but on two subsequent attempts in the same drawing it failed to work (it did trim but the results were not what was seen first time round). I don't know why that is. I'm still in "test" mode.

Second test failed. I guess it's back to searching for an answer.

It's ok no problem.

I found the LISP Code on the link given by OMEGA-ThundeR and tried it. But it can only trim the lines intersecting the Closed Objects. FYI, I drew the Circle just to let people understand my query otherwise I have sets of Open Polylines including Arcs & Straight Lines (irregular) So The MEXTRIM or the Polygon method (Described by Mr. Marko-Ribar) will not work.
will be grateful if there's something else you guys can do.

Thank you,

Regards,

Sidhu

4. sidhu: Did you not see the new lisp program marko included in his last post? It does what you asked for. Check it out.

5. Originally Posted by marko_ribar
Slightly different than I proposed with polygon - now obtaining points directly from middle distance of 2 radius...

Code:
```(defun c:trim_between_2_concentic_circles ( / inner_circle outer_circle c1 c2 c r1 r2 r k p pl )

(setq inner_circle (car (entsel "\nPick inner circle")))
(setq outer_circle (car (entsel "\nPick outer circle")))
(setq c1 (cdr (assoc 10 (entget inner_circle))))
(setq c2 (cdr (assoc 10 (entget outer_circle))))
(setq c (mapcar '* (mapcar '+ c1 c2) '(0.5 0.5 0.5)))
(setq r1 (cdr (assoc 40 (entget inner_circle))))
(setq r2 (cdr (assoc 40 (entget outer_circle))))
(setq r (/ (+ r1 r2) 2.0))
(setq k -1.0)
(repeat 360
(setq p (polar c (cvunit (setq k (1+ k)) "degrees" "radians") r))
(setq pl (cons p pl))
)
(setq pl (cons (polar c 0.0 r) pl))
(command "_.trim" inner_circle outer_circle "" "_F")
(foreach p pl
(command p)
)
(while (> (getvar 'cmdactive) 0) (command ""))
(princ)
)

(defun c:tb2cc nil (c:trim_between_2_concentic_circles))```
HTH, M.R.
Sir,

It works fine but still I need to specify the Fence Path. This is 90% of what I need. If you can only edit it little bit and remove the Fence Function, So it will trim every Line in between the Circel / Polyline 1 & Circle / Polyline 2.

Regards,

Sidhu

6. sidhu412, If your concentric circles lie in some UCS different than WCS, I suggest that you use this revision (also added OSMODE checking - you can add this 2 first lines and in previous code and one last before (princ))

Code:
```(defun c:trim_between_2_concentic_circles ( / osm inner_circle outer_circle c1 c1w c2 c2w cw c r1 r2 r k p pl )

(setq osm (getvar 'osmode))
(setvar 'osmode 0)
(setq inner_circle (car (entsel "\nPick inner circle")))
(while (/= (cdr (assoc 0 (entget inner_circle))) "CIRCLE")
(prompt "\nPicked entity isn't circle entity, try again...")
(setq inner_circle (car (entsel "\nPick inner circle")))
)
(setq outer_circle (car (entsel "\nPick outer circle")))
(while (/= (cdr (assoc 0 (entget outer_circle))) "CIRCLE")
(prompt "\nPicked entity isn't circle entity, try again...")
(setq outer_circle (car (entsel "\nPick outer circle")))
)
(setq c1 (cdr (assoc 10 (entget inner_circle))))
(setq c1w (trans c1 inner_circle 0))
(setq c2 (cdr (assoc 10 (entget outer_circle))))
(setq c2w (trans c2 outer_circle 0))
(setq cw (mapcar '* (mapcar '+ c1w c2w) '(0.5 0.5 0.5)))
(setq c (trans cw 0 1))
(setq r1 (cdr (assoc 40 (entget inner_circle))))
(setq r2 (cdr (assoc 40 (entget outer_circle))))
(setq r (/ (+ r1 r2) 2.0))
(setq k -1.0)
(repeat 360
(setq p (polar c (cvunit (setq k (1+ k)) "degrees" "radians") r))
(setq pl (cons p pl))
)
(setq pl (cons (polar c 0.0 r) pl))
(command "_.trim" inner_circle outer_circle "" "_F")
(foreach p pl
(command p)
)
(while (> (getvar 'cmdactive) 0) (command ""))
(setvar 'osmode osm)
(princ)
)

(defun c:tb2cc nil (c:trim_between_2_concentic_circles))```
BTW. This code by OMEGA-ThundeR is more general and I strongly suggest that you use it in many various situations, where EXTRIM can't provide desired results...

Code:
```;;; FenceTRim

(Defun C:ftr ()
(command "_trim" pause pause "" "f")
(princ)
)```
Regards, M.R.

7. Here is another approach... Try it and see if you get desired results...

Load posted code :

Code:
```(defun colect_entdata ( / ss i ent entdata )
(setq ss (ssget "_X"))
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq entdata (cons (entget ent) entdata))
)
entdata
)

(defun c:store_entdata nil
(setq entdata (colect_entdata))
(princ)
)

;;; Modify entities ;;;

(defun colect_modified_entdata ( / ss i ent entdatachk entdatamod )
(setq ss (ssget "_X"))
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq entdatachk (cons (entget ent) entdatachk))
)
(foreach data entdatachk
(if (not (vl-some '(lambda ( x ) (equal x data 1e-6)) entdata))
(setq entdatamod (cons data entdatamod))
)
)
entdatamod
)

(defun c:sel_mod_ents ( / ss )
(foreach data (colect_modified_entdata)
(ssadd (cdr (assoc -1 data)) ss)
)
(sssetfirst nil ss)
(princ)
)

(alert "\nFirstly type : store_entdata \nThen modify entities \nFinally type : sel_mod_ents \nAt the end type : (setq entdata nil)")
(princ)```
1. Firstly type : store_entdata
2. Use "EXTRIM" command - pick first curve and pick point inside area you want to be extrimmed...
3. Type : sel_mod_ents
4. Press ctrl+shift+c (copybase) and enter point : 0,0,0
5. Type : (setq entdata nil)
6. Type : U (undo) - drawing should be exactly like starting - before 2. process
7. Use "EXTRIM" command - pick second curve and pick point inside area you want to be extrimmed...
8. Press ctrl+v (paste) and enter point : 0,0,0

That's it... Try it and tell me how it works...
HTH, M.R.

8. I thought, why wouldn't I automate this steps into single lisp, and I did it... So try this version...

Code:
```(defun colect_entdata ( / ss i ent entdata )
(setq ss (ssget "_X"))
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq entdata (cons (entget ent) entdata))
)
entdata
)

(defun store_entdata nil
(setq entdata (colect_entdata))
(princ)
)

;;; Modify entities ;;;

(defun colect_modified_entdata ( / ss i ent entdatachk entdatamod )
(setq ss (ssget "_X"))
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq entdatachk (cons (entget ent) entdatachk))
)
(foreach data entdatachk
(if (not (vl-some '(lambda ( x ) (equal x data 1e-6)) entdata))
(setq entdatamod (cons data entdatamod))
)
)
entdatamod
)

(defun sel_mod_ents nil
(foreach data (colect_modified_entdata)
(ssadd (cdr (assoc -1 data)) ss)
)
(princ)
)

;;; Main command function ;;;

(defun c:extrim_between_2_curves ( / hig osm c1 c2 p ss entdata )

(setq hig (getvar 'highlight))
(setq osm (getvar 'osmode))
(setvar 'osmode 0)
(if (not (or etrim (not (vl-catch-all-error-p (vl-catch-all-apply 'load (list (findfile "extrim.lsp")))))))
(progn
(alert "\nExpress Tool EXTRIM not available - quitting...")
(exit)
)
)
(setq c1 (car (entsel "\nPick first curve")))
(while (not (numberp (vlax-curve-getstartparam c1)))
(prompt "\nPicked entity isn't curve entity. Try again...")
(setq c1 (car (entsel "\nPick first curve")))
)
(setq c2 (car (entsel "\nPick second curve")))
(while (not (numberp (vlax-curve-getstartparam c2)))
(prompt "\nPicked entity isn't curve entity. Try again...")
(setq c2 (car (entsel "\nPick second curve")))
)
(initget 1)
(setq p (getpoint "\nPick or specify point between 2 prviously picked curves where do you want extrim to be processed : "))
(store_entdata)
(etrim c1 p)
(sel_mod_ents)
(command "_.copybase" '(0.0 0.0 0.0) ss "")
(command "_.undo" "3")
(etrim c2 p)
(command "_.pasteclip" '(0.0 0.0 0.0))
(setvar 'osmode osm)
(setvar 'highlight hig)
(princ)
)

(defun c:exb2c nil (c:extrim_between_2_curves))```
HTH, M.R.
Regards...

9. oops forgot to read page two

A facet.lsp anyway for something like this problem a few extra lines and done trim between two circles. Like above new rad is just (rad1+rad2)/2, pick two circles then trim using Fence avoids using vlax-curve old fashioned lisp.

Code:
```(setq num (getreal "\nEnter number of facets"))
(setq cenpt (getpoint "\nPick centre pt"))
(setq ang 0.0)
(setq angdiff (/ (* pi 2.0) num))
(repeat (fix num)
(setq pt1 (polar cenpt ang rad))
(setq facets (cons pt1 facets))
(setq ang (+ angdiff ang))
)
(princ facets)```

10. Registered forum members do not see this ad.

Originally Posted by marko_ribar
I thought, why wouldn't I automate this steps into single lisp, and I did it... So try this version...

Code:
```(defun colect_entdata ( / ss i ent entdata )
(setq ss (ssget "_X"))
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq entdata (cons (entget ent) entdata))
)
entdata
)

(defun store_entdata nil
(setq entdata (colect_entdata))
(princ)
)

;;; Modify entities ;;;

(defun colect_modified_entdata ( / ss i ent entdatachk entdatamod )
(setq ss (ssget "_X"))
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq entdatachk (cons (entget ent) entdatachk))
)
(foreach data entdatachk
(if (not (vl-some '(lambda ( x ) (equal x data 1e-6)) entdata))
(setq entdatamod (cons data entdatamod))
)
)
entdatamod
)

(defun sel_mod_ents nil
(foreach data (colect_modified_entdata)
(ssadd (cdr (assoc -1 data)) ss)
)
(princ)
)

;;; Main command function ;;;

(defun c:extrim_between_2_curves ( / hig osm c1 c2 p ss entdata )

(setq hig (getvar 'highlight))
(setq osm (getvar 'osmode))
(setvar 'osmode 0)
(if (not (or etrim (not (vl-catch-all-error-p (vl-catch-all-apply 'load (list (findfile "extrim.lsp")))))))
(progn
(alert "\nExpress Tool EXTRIM not available - quitting...")
(exit)
)
)
(setq c1 (car (entsel "\nPick first curve")))
(while (not (numberp (vlax-curve-getstartparam c1)))
(prompt "\nPicked entity isn't curve entity. Try again...")
(setq c1 (car (entsel "\nPick first curve")))
)
(setq c2 (car (entsel "\nPick second curve")))
(while (not (numberp (vlax-curve-getstartparam c2)))
(prompt "\nPicked entity isn't curve entity. Try again...")
(setq c2 (car (entsel "\nPick second curve")))
)
(initget 1)
(setq p (getpoint "\nPick or specify point between 2 prviously picked curves where do you want extrim to be processed : "))
(store_entdata)
(etrim c1 p)
(sel_mod_ents)
(command "_.copybase" '(0.0 0.0 0.0) ss "")
(command "_.undo" "3")
(etrim c2 p)
(command "_.pasteclip" '(0.0 0.0 0.0))
(setvar 'osmode osm)
(setvar 'highlight hig)
(princ)
)

(defun c:exb2c nil (c:extrim_between_2_curves))```
HTH, M.R.
Regards...
Bingooooooooooo

Great.........!
That's 100% What I needed You are Genius Mr. Marko_Ribar.

Thanxxxxxx a lot

Regards,

Sidhu

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts