aliu22
发表于 2005-11-22 17:07:00
这个不行啊
jack2913
发表于 2006-3-28 22:38:00
我也希望版主们能改一下R14里的这个程序,好让我们这些小辈能在高版本的CAD里也可以用上
jack2913
发表于 2006-3-28 22:40:00
<P>我也希望版主们能改一下R14里的这个程序,好让我们这些小辈能在高版本的CAD里也可以用上</P>
<P>;;;<BR>;;; EXTRIM.LSP - Written by Randy Kintzley <BR>;;; <BR>;;; Copyright (C) 1997 by Autodesk, Inc.<BR>;;;<BR>;;; Permission to use, copy, modify, and distribute this software<BR>;;; for any purpose and without fee is hereby granted, provided<BR>;;; that the above copyright notice appears in all copies and<BR>;;; that both that copyright notice and the limited warranty and<BR>;;; restricted rights notice below appear in all supporting<BR>;;; documentation.<BR>;;;<BR>;;; AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.<BR>;;; AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF<BR>;;; MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.<BR>;;; DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE<BR>;;; UNINTERRUPTED OR ERROR FREE.<BR>;;;<BR>;;; Use, duplication, or disclosure by the U.S. Government is subject to<BR>;;; restrictions set forth in FAR 52.227-19 (Commercial Computer<BR>;;; Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)<BR>;;; (Rights in Technical Data and Computer Software), as applicable.<BR>;;;<BR>;;;<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;GLOBAL INFO.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>;Functions created as result of loading file: extrim.lsp<BR>; ANOTHER_OFFSET<BR>; ETRIM<BR>; GET_FENCE_POINTS<BR>; INTERSECT_CHECK<BR>; TRUNCATE_2_VIEW<BR>;<BR>;Variables created as result of loading file: extrim.lsp<BR>;<BR>;Functions created as a result of executing the commands in: extrim.lsp<BR>;<BR>;Variables created as a result of executing the commands in: extrim.lsp<BR>; BONUS_ALIVE<BR>; BONUS_OLD_ERROR<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;GLOBAL INFO.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</P>
<P>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>;Extended-TRIM - cookie-cutter routine<BR>;<BR>;Select a polyline, line, circle or arc and a side to trim on<BR>;<BR>(defun c:et ( / dxf na p1 redraw_it)</P>
<P>(if (and (not init_bonus_error) <BR> (equal -1 (load "ac_bonus.lsp" -1)) <BR> );and<BR> (progn (alert "Error:\n Cannot find AC_BONUS.LSP.")(exit))<BR>);if<BR>(init_bonus_error (list<BR> (list "cmdecho" 0 <BR> "highlight" 0<BR> "regenmode" 1<BR> "osmode" 0<BR> "ucsicon" 0<BR> "offsetdist" 0<BR> "attreq" 0 <BR> "plinewid" 0<BR> "plinetype" 1<BR> "gridmode" 0<BR> "celtype" "CONTINUOUS"<BR> )<BR> T ;flag. True means use undo for error clean up. <BR> '(if redraw_it (redraw na 4))<BR> );list <BR>);init_bonus_error</P>
<P> ;local function<BR> (defun dxf (a b / ) (cdr (assoc a b)));defun</P>
<P>(princ "\nPick a POLYLINE, LINE, CIRCLE, or ARC for cutting edge..")<BR>(setq na (single_select '((-4 . "<OR")<BR> (0 . "CIRCLE")<BR> (0 . "ARC")<BR> (0 . "LINE")<BR> (0 . "LWPOLYLINE")<BR> (-4 . "<AND")<BR> (0 . "POLYLINE")<BR> (-4 . "<NOT")<BR> (-4 . "&") <BR> (70 . 112) <BR> (-4 . "NOT>")<BR> (-4 . "AND>")<BR> (-4 . "OR>")<BR> )<BR> T<BR> );single_select<BR>);setq<BR>(if na <BR> (progn<BR> ;(setq e1 (entget na));;setq<BR> (redraw na 3)<BR> (setq redraw_it T)</P>
<P> (setq p1 (getpoint "\nPick the side to trim on:"));setq<BR> (redraw na 4)<BR> (setq redraw_it nil)</P>
<P> (if p1 (etrim na p1));if<BR> );progn<BR>);if</P>
<P>(restore_old_error)<BR>(princ)<BR>);defun c:extrim</P>
<P>;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<BR>;Entity-TRIM function<BR>;takes: na - entity name<BR>; a - a point, the side to trim on<BR>;NOTE: This function does not allow for the possible miss of<BR>; non-continuous linetypes. <BR>;<BR>(defun etrim ( na a / la dxf b d e1 lst lst2 n j k m ss na2 na3 na4 <BR> x y z flag flag2 flag3 <BR> )</P>
<P> ;local function<BR> (defun dxf (a b / ) (cdr (assoc a b)));defun</P>
<P>(setq e1 (entget na));setq<BR>(if (or (setq flag (equal (dxf 0 e1) "POLYLINE"))<BR> (setq flag (equal (dxf 0 e1) "LWPOLYLINE"))<BR> (equal (dxf 0 e1) "LINE")<BR> (equal (dxf 0 e1) "CIRCLE")<BR> (equal (dxf 0 e1) "ARC")<BR> );or<BR> (progn<BR> (if (and flag<BR> (equal 8 (logand 8 (dxf 70 e1)))<BR> );and<BR> (setq flag nil)<BR> );if<BR> (setq a (trans a 1 0));setq<BR> (command "_.ucs" "_View")<BR> <BR> (setq lst (ep_list na nil) ;;;find extents of selected cutting edge object<BR> lst (maxminpnt lst)<BR> x (- (car (cadr lst)) (car (car lst)))<BR> y (- (cadr (cadr lst)) (cadr (car lst)))<BR> x (* 0.075 x)<BR> y (* 0.075 y)<BR> z (list x y)<BR> x (list (+ (car (cadr lst)) (car z))<BR> (+ (cadr (cadr lst)) (cadr z))<BR> );list<BR> y (list (- (car (car lst)) (car z))<BR> (- (cadr (car lst)) (cadr z)) <BR> );list<BR> );setq<BR> (command "_.zoom" "_w" x y)<BR> (entupd na) ;;;update the ent. so it's curves display smoothly</P>
<P> (setq lst (ep_list na <BR> (/ (pixel_unit) 2.0)<BR> )<BR> );setq<BR> (if (or (not flag)<BR> (not (p_isect lst nil))<BR> );or <BR> (progn ;then the object is valid and not a self intersecting polyline.<BR> (if (and flag<BR> (equal (car lst) (last lst) 0.0001)<BR> );and<BR> (setq flag3 T);then the polyline could potentialy need a second offset<BR> );if<BR> (if (setq la (b_layer_locked (getvar "clayer")))<BR> (command "_.layer" "_unl" (getvar "clayer") "")<BR> );if<BR> <BR> (command "_.pline")<BR> (setq b nil)<BR> (setq n 0);setq<BR> (repeat (length lst)<BR> (setq d (nth n lst))<BR> (if (not (equal d b 0.0001))<BR> (progn<BR> (command d)<BR> (setq lst2 (append lst2 (list d)));setq<BR> (setq b d);setq <BR> );progn<BR> );if <BR> (setq n (+ n 1))<BR> );repeat<BR> (command "")<BR> (setq na2 (entlast)<BR> ss (ssadd)<BR> ss (ssadd na2 ss)<BR> lst nil <BR> );setq<BR> (ss_visible ss 1)<BR> (setq lst2 (get_fence_points na2 a lst2 flag3 flag));setq<BR> <BR> (if la<BR> (command "_.layer" "_lock" (getvar "clayer") "")<BR> );if<BR> (command "_.ucs" "_p") <BR> ;Move the ents to force a display update of the ents to avoid viewres problems. <BR> (setvar "highlight" 0)<BR> (if (setq ss (ssget "f" (last lst2)))<BR> (command "_.move" ss "" "0,0,0" "0,0,0")<BR> );if<BR> (if flag<BR> (progn<BR> (if (setq la (b_layer_locked (dxf 8 e1)))<BR> (command "_.layer" "_unl" (dxf 8 e1) "")<BR> );if <BR> (ucs_2_ent (dxf 210 e1))<BR> (command "_.copy" na "" "0,0,0" "0,0,0")<BR> (entdel na)<BR> (setq na3 na<BR> na (entlast)<BR> );setq<BR> (command "_.pedit" na "_w" "0.0" "_x")<BR> (command "_.ucs" "_p")<BR> (if la (command "_.layer" "_lock" (dxf 8 e1) ""));if <BR> );progn<BR> );if<BR> (command "_.trim" na "") <BR> (setq m (- (length lst2) 1));setq<BR> (setq k 0) ;@rk<BR> (repeat (length lst2)<BR> (setq lst (nth k lst2)) <BR> (setq a (trans (car lst) 0 1))<BR> (setq n 1)<BR> (repeat (- (length lst) 1) ;repeat each fence list<BR> (setq b (trans (nth n lst) 0 1))<BR> (if (equal a b 0.0001)<BR> (setq flag2 T)<BR> (setq flag2 nil)<BR> );if <BR> (setq na4 nil);setq<BR> (setq j 0);setq<BR> (while (not flag2) ;repeat each segment of the fence until no new ents are created. <BR> (setq na4 (entlast));setq<BR> (command "_F" a b "") <BR> (if (and (equal na4 (entlast))<BR> (or (not (equal k m))<BR> (> j 0)<BR> );or<BR> );and<BR> (setq flag2 T)<BR> );if<BR> (setq j (+ j 1));setq <BR> );while<BR> (setq a b);setq<BR> (setq n (+ n 1));setq<BR> );repeat <BR> <BR> (setq k (+ k 1))<BR> );repeat <BR> (command "") <BR> <BR> (if flag <BR> (progn<BR> (if (setq la (b_layer_locked (dxf 8 e1)))<BR> (command "_.layer" "_unl" (dxf 8 e1) "")<BR> );if <BR> (entdel na) ;get rid of the copy<BR> (entdel na3);bring back the original<BR> (if la (command "_.layer" "_lock" (dxf 8 e1) ""));if <BR> );progn<BR> );if<BR> );progn<BR> (progn<BR> (command "_.ucs" "_p")<BR> (princ "\nSelf intersecting edges are not acceptable.") <BR> );progn else invalid self intersecting polyline<BR> );if <BR> (command "_.zoom" "_p")<BR> );progn then it's a most likely a valid entity.<BR>);if<BR>);defun etrim</P>
<P>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>(defun another_offset ( pl1 pl2 a1 a2 b na2 lst2 a lst3 lst4 / na ss lst da1 da2)</P>
<P>(setq da1 (abs (- a2 a1)));setq<BR>(setq da2 (- (* b (max pl2 pl1))<BR> (/ (* b (abs (- pl2 pl1))) <BR> 2.0<BR> )<BR> )<BR>);setq<BR>(if (> (abs (- da2 da1))<BR> (* 0.01 (max a1 a2)) <BR> )<BR> (progn</P>
<P> (pline (list lst2))<BR> (setq na (entlast)<BR> na2 (entlast)<BR> ss (ssadd)<BR> ss (ssadd na ss)<BR> );setq<BR> (ss_visible ss 1)<BR> (command "_.offset" b na2 a "") <BR> (if (and (not (equal na (entlast)))<BR> (setq lst3 (vtlist (entlast)))<BR> (setq lst3 (intersect_check lst2 lst3 lst4))<BR> );and<BR> (progn<BR> (ss_visible (ssadd (entlast) (ssadd)) 1)<BR> (command "_.area" "_ob" (entlast))<BR> (setq pl2 (getvar "perimeter")<BR> a2 (getvar "area")<BR> );setq<BR> (setq lst (list (vtlist (list (entlast) 0))));setq<BR> (entdel (entlast));then offset was a success so delete the ent after getting it's info<BR> );progn then<BR> (if (not (equal na (entlast))) (entdel (entlast)));if else<BR> );if<BR> (entdel na2)<BR> );progn then let's do that second offset <BR>);if</P>
<P>lst<BR>);defun another_offset</P>
<P>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>(defun get_fence_points ( na2 a lst2 flag plflag / a1 a2 pl1 pl2 b c d n <BR> lst lst2 lst3 lst4 na <BR> )</P>
<P>(if flag<BR> (progn<BR> (setq lst2 (cdr lst2));setq<BR> (repeat (fix (/ (length lst2) 2))<BR> (setq lst2 (append (cdr lst2) (list (car lst2)));append<BR> );setq<BR> );repeat<BR> (setq lst2 (append lst2 (list (car lst2))));setq<BR> (command "_.area" "_ob" na2)<BR> (setq pl1 (getvar "perimeter")<BR> a1 (getvar "area")<BR> );setq<BR> );progn<BR>);if</P>
<P>(setq a (trans a 0 1)<BR> b (* (getvar "viewsize") 0.05);initial offset distance<BR> n 3.0 ;number of offsets<BR> d (/ b (- n 1)) ;delta offset<BR> c (pixel_unit)<BR> lst4 (viewpnts)<BR>);setq</P>
<P>(while (> b c)<BR>(setq na (entlast))<BR>(command "_.offset" b na2 a "") <BR>(if (and (not (equal na (entlast)))<BR> (setq lst3 (vtlist (entlast)))<BR> (or (not plflag)<BR> (setq lst3 (intersect_check lst2 lst3 lst4))<BR> );or<BR> );and <BR> (progn<BR> (setq lst3 (lsttrans lst3 1 0))<BR> (ss_visible (ssadd (entlast) (ssadd)) 1)<BR> (if flag<BR> (progn <BR> (command "_.area" "_ob" (entlast))<BR> (setq pl2 (getvar "perimeter")<BR> a2 (getvar "area")<BR> );setq<BR> );progn<BR> );if <BR> (setq lst (append lst (list lst3)));setq<BR> (entdel (entlast)) ;delete the ent after getting it's vertex info<BR> (if flag<BR> (setq lst (append lst <BR> (another_offset pl1 pl2 a1 a2 b na2 lst2 a lst3 lst4)<BR> );append<BR> );setq<BR> );if<BR> );progn then offset was a success<BR> (if (not (equal na (entlast))) (entdel (entlast)));if else<BR>);if<BR>(setq b (- b d));setq<BR>);while<BR>(setq na (entlast))<BR>(command "_.offset" c na2 a "") <BR>(if (and (not (equal na (entlast)))<BR> (setq lst3 (vtlist (entlast)))<BR> (or (not plflag)<BR> (setq lst3 (intersect_check lst2 lst3 lst4))<BR> );or<BR> );and <BR> (progn<BR> (setq lst3 (lsttrans lst3 1 0)) <BR> (ss_visible (ssadd (entlast) (ssadd)) 1)<BR> (if flag<BR> (progn <BR> (command "_.area" "_ob" (entlast))<BR> (setq pl2 (getvar "perimeter")<BR> a2 (getvar "area")<BR> );setq<BR> );progn<BR> );if <BR> (setq lst (append lst (list lst3)));setq<BR> (entdel (entlast));then offset was a success so delete the ent after getting it's info<BR> (if flag <BR> (setq lst (append lst <BR> (another_offset pl1 pl2 a1 a2 c na2 lst2 a lst3 lst4)<BR> );append<BR> );setq<BR> );if<BR> );progn then<BR> (if (not (equal na (entlast))) (entdel (entlast)));if else<BR>);if<BR>(entdel na2)</P>
<P>lst<BR>);defun get_fence_points</P>
<P>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>;returns a list of points on screen if the first two lists do not<BR>;contain segments that intersect each other.<BR>; <BR>(defun intersect_check ( lst lst2 lst3 / x x2 y y2 lst4 flag len len2 <BR> a aa b bb c d n j)</P>
<P>(setq len (length lst)<BR> len2 (length lst2)<BR> x (car (car lst3))<BR> x2 (car (cadr lst3))<BR> y (cadr (car lst3))<BR> y2 (cadr (cadr lst3))<BR>);setq</P>
<P>(setq n 0);setq<BR>(while (and (not flag) <BR> (< (+ n 1) len2)<BR> );and<BR>(setq aa (nth n lst2)<BR> bb (nth (+ n 1) lst2)<BR> a (truncate_2_view aa bb x y x2 y2)<BR> b (truncate_2_view bb aa x y x2 y2)<BR> lst4 (append lst4 (list a))<BR>);setq<BR>(if (or (not (equal a aa))<BR> (not (equal b bb))<BR> );or<BR> (setq lst4 (append lst4 (list b)))<BR>);if<BR>(setq j 0);setq <BR> (while (and (not flag) <BR> (< (+ j 1) len)<BR> );and<BR> (setq c (nth j lst)<BR> d (nth (+ j 1) lst)<BR> flag (inters a b c d) <BR> );setq</P>
<P> (setq j (+ j 1));setq<BR> );while</P>
<P>(setq n (+ n 1));setq<BR>);while<BR>(if (not (equal b (last lst4)))<BR> (setq lst4 (append lst4 (list b)));setq<BR>);if<BR>(if (not flag) <BR> (setq flag lst4)<BR> (setq flag nil)<BR>);if<BR>flag<BR>);defun intersect_check</P>
<P>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>(defun truncate_2_view ( a b x y x2 y2 / int)<BR> (if (and (< (car a) x)<BR> (setq int (inters a b (list x y 0.0) (list x y2 0.0)))<BR> );and<BR> (setq a int)<BR> (if (and (> (car a) x2)<BR> (setq int (inters a b (list x2 y 0.0) (list x2 y2 0.0)))<BR> );and<BR> (setq a int)<BR> );if else<BR> );if<BR> (if (and (< (cadr a) y)<BR> (setq int (inters a b (list x y 0.0) (list x2 y 0.0)))<BR> );and<BR> (setq a int)<BR> (if (and (> (cadr a) y2)<BR> (setq int (inters a b (list x y2 0.0) (list x2 y2 0.0)))<BR> );and<BR> (setq a int)<BR> );if else<BR> );if</P>
<P>a<BR>);defun truncate_2_view</P>
<P><BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>(princ "\n \"EXTRIM\" loaded.")<BR>(princ)<BR></P>
<P> </P>
<P> </P>
jxphklibin
发表于 2009-3-8 20:41:00
好,提供的程序很好,有时间我来看看,能不能修改成功!
cxj11849
发表于 2009-3-28 11:11:00
多谢高手指点~~
非常感谢!!!
qinxiangzhou
发表于 2009-5-24 23:12:00
<p>(defun c:cut()<br/> (setq b1 (getcorner<br/> (setq a1 (getpoint "\\n指定选择框"))<br/> )<br/> )<br/> (setq see (ssget "_c" a1 b1 ))<br/> (if (/= see nil)<br/> (command "_cutclip" see)<br/> )<br/> )</p><p>请您告诉我如何增加这个编程到那个位置才能实现2005框选剪切(同2006一样矩形剪切),谢谢</p>
飞诗(fsxm)
发表于 2009-5-25 17:24:00
<p>EXTRIM可以!但冒出头很小的线有时会剪不了!</p><p>可自己写一个程序~!比这个效果好哦!等6月1日我发布一个玩一下哈!</p>
liminnet
发表于 2009-5-26 11:09:00
liminnet
发表于 2009-5-26 11:11:00
bybyby
发表于 2009-5-26 12:46:00
龘<br/>