嗯,如果这能解决问题,我会很高兴的。
我现在修改了lisp,如下所示:
- (initget "Yes No")
- (setq ans (getkword "\nDo you want to delete objects obviously not to be imported? [Yes/No]?: "))
- (while (= ans "Yes") ;While user decide YES
- (progn ;Commands to run
- (prompt "\nSelect objects by window") ;Tells user what to do
- (setq P1 (getpoint "\nFirst Corner: ")) ;Pick first corner
- (setq P2 (getpoint "\nSecond Corner: ")) ;Pick second corner
- (setq P3 (list (nth 0 P2)(nth 1 P1))) ;Create additional point for frame
- (setq P4 (list (nth 0 P1)(nth 1 P2))) ;Create additional point for frame
- (setq P5 (list (/ (+ (nth 0 P1)(nth 0 P2)) 2)(/ (+ (nth 1 P1)(nth 1 P2)) 2))) ;Select point in middle of frame
- (command "_Pline" P1 P3 P2 P4 "_c") ;Create frame
- (setq tmp (entlast)) ;Select created frame
-
- ;Identify point positions left/right & up/dn
- (setq xp1 (nth 0 P1)) ;set xp1 as x coord of P1
- (setq xp2 (nth 0 P2)) ;set xp2 as x coord of P2
- (setq yp1 (nth 1 P1)) ;set yp1 as y coord of P1
- (setq yp2 (nth 1 P2)) ;set yp2 as y coord of P2
- (if (< xp1 xp2) ;check x relative and set values
- (progn
- (setq xp6 (+ xp1 1))
- (setq xp7 (- xp2 1))
- )
- (progn
- (setq xp6 (- xp1 1))
- (setq xp7 (+ xp2 1))
- )
- )
- (if (< yp1 yp2) ;check y relative and set values
- (progn
- (setq yp6 (+ yp1 1))
- (setq yp7 (- yp2 1))
- )
- (progn
- (setq yp6 (- yp1 1))
- (setq yp7 (+ yp2 1))
- )
- )
- (setq P6 (list xp6 yp6)) ;define points inside of the frame as selection for trim
- (setq P7 (list xp7 yp7)) ;define points inside of the frame as selection for trim
- (setq tbe (ssget "_C" P6 P7)) ;Select objects touching the frame (tbe)
- (command "_Trim" tmp "") ;Open trim command
- (setq ct -1) ;reset counter
- (repeat (sslength tbe) ;run through all objects in tbe selection
- (command(list(ssname tbe (setq ct (1+ ct))) P5)) ;Fill required prompts for trim command
- ) ;End of repeat
- (command "") ;Leave trim function
- (command "._Erase" tmp "") ;Remove Frame
- (princ) ;
- (setq ct -1) ;Reset counter
- (setq tbe nil) ;Reset list tbe
- (setq tbe (ssget "_W" P1 P2)) ;Select all objects in the Window opened by P1 and P2
- (command "._Erase" tbe "") ;Delete former selected objects
- (setq tbe nil) ;Reset list tbe
- (vla-zoomextents (vlax-get-acad-object)) ;Zoom Extents
- (initget "Yes No") ;Allow user input
- (setq ans (getkword "\nDo you want to delete more? [Yes/No]?: ")) ;Ask user if more should be deleted
- (if (= ans "No") ;Start of if, cond. Answer of former question was no
- (setq ans nil) ;Set var. ans to nil
- (princ)
- ) ;end of if
- ) ;End of progn
- ) ;End of while
- (princ)
- (setq ct -1)
不幸的是,它没有解决这个问题。经过更多的测试,如果我把一条线的中心点用框架围起来,它看起来工作得很好,但只要它只在线上切了一个接近的开口,而没有围起来中间点,它就会删除整个剩余部分,包括框架外的部分 |