Jump to content

Boundery Trimming Route


VisDak

Recommended Posts

hi to all,

 

im just wondering why it's not working this LiPS, Please see attached image that the route must happen like this, pick point 1 to point 2 as rectangular boundery and it will be trimmed on rectangular that i windowed, heres the code:

 

(defun c:cut () (graphscr)
       [color=red](setvar "osmode" 31743)[/color]
       (setvar "cmdecho" 0)
       (initget 32)
       (setq pnt1 (getpoint "First corner of rectangle: ")) (terpri)
       (setq pnt3 (getcorner "Second corner: " pnt1 ))(terpri)
       (setq pnt2 (list (car pnt1) (cadr pnt3)))
       (setq pnt4 (list (car pnt3) (cadr pnt1)))
       (command "Pline" pnt1 pnt2 pnt3 pnt4 "c")
       (setq el (entlast))
       (repeat 3
       (setq pt1 (list (+ (car pnt1) 0.05)(+ (cadr pnt1) 0.05)))
       (setq pt2 (list (+ (car pnt2) 0.05)(- (cadr pnt2) 0.05)))    
       (setq pt3 (list (- (car pnt3) 0.05)(- (cadr pnt3) 0.05)))   
       (setq pt4 (list (- (car pnt4) 0.05)(+ (cadr pnt4) 0.05)))   
       (command "trim" el "" "f" pt1 pt2 pt3 pt4 pt1 "" "" ) 
       )
       [color=black](command "erase" "w" pnt1 pnt3 "" )[/color]
[color=black]       (command "erase" el "" )[/color]
       (setvar "cmdecho" 1)
       [color=red](setvar "osmode" 15359)[/color]
(princ)
)
cls

 

i don't understand why it delete all selected line:oops: kindly please help me on this route,

 

Advance thanks to all,

trimmer.jpg

Link to comment
Share on other sites

yes JohnM, i already tried i recognized that when first corner pick will be left down to up right second corner pick it works ok ,:roll: but why that when i pick the first corner on the right or upper left upto selected boundery the line will be deleted,:oops:

 

Many thanks JohnM, i will add in the code the snap off:D

Link to comment
Share on other sites

It is probably due to the size of your pickbox. -David

 

Also implied selections have their own rules.

slect.jpg

Link to comment
Share on other sites

A quickie...

(defun c:cut (/ p1 p2 ofd clst ll lr ur ul ent trimpts)
 (graphscr)
 (setvar "cmdecho" 0)
 (setq p1 (getpoint "\nFirst corner of rectangle: "))
 (initget 32)
 (setq p2 (getcorner "\nSecond corner: " p1))
 (if (and p1 p2)
   (progn
     (command "_.undo" "begin")
     (setq ofd  0.05         ; offset distance
           clst (list p1 p2)
     )
     ;; get lower left corner
     (setq ll (list (apply 'min (mapcar 'car clst))
                    (apply 'min (mapcar 'cadr clst))
              )
     )
     ;;  get upper right corner
     (setq ur (list (apply 'max (mapcar 'car clst))
                    (apply 'max (mapcar 'cadr clst))
              )
     )
     (setq lr (list (car ur) (cadr ll)))
     (setq ul (list (car ll) (cadr ur)))
     (command "Pline" "_non" ll "_non" lr "_non" ur "_non" ul "c")
     (setq ent (entlast))

     (setq trimpts (list
                     (polar ll (* pi 0.25) ofd)
                     (polar lr (* pi 0.75) ofd)
                     (polar ur (* pi 1.25) ofd)
                     (polar ul (* pi 1.75) ofd)
                     (polar ll (* pi 0.25) ofd)
                   )
     )
     (repeat 2
       (command "trim" ent "" "f")
       (foreach x trimpts (command "_non" x))
       (command "" "")
     )

     (if (setq x (ssget "wp" trimpts))
       (command "erase" x "")
     )

     (entdel ent)
     (command "_.undo" "end")
   )
 )
 (setvar "cmdecho" 1)
 (princ)
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...