Jump to content

Recommended Posts

Posted

Hi

i'm looking for some method to trim objects automatically

at the moment i use simple function

(defun trim_entity (ss en point / )
(command "_trim" ss "" (list en point) "")
)

but is there any other method (i don't want to use "command") to trim objects in lisp code?

Posted

You need to post a image etc of what you want, specific trim lisps usually do just that 1 style of trim. There lots of them out there.

Posted

what i need is just information about any other method of trim object (for example vla method),

i'm going to write routine which trim all objects above vertical (or horizontal) xline on drawings

and i dont want to base it on (command "_trim"... and I'm looking for some alternative

Posted

Are you talking strictly 2D and always WCS ? - David

Posted
what i need is just information about any other method of trim object (for example vla method),

i'm going to write routine which trim all objects above vertical (or horizontal) xline on drawings

and i dont want to base it on (command "_trim"... and I'm looking for some alternative

 

Look for lisp from ExpressTools...

ET - (c:extrim)

Posted

Like marko_ribar extrim takes away all the hard work only problem is you must load the express lisp first to use, a simple example a object and a point. Note also the command ETRIM not extrim caught me out at first but found help.

 

(load "Extrim")
(etrim obj pt1)

Posted

does expresstools are available only for autocad? i'm using both acad and bricscad and a can't load expresstools in bricscad unfortunately

Posted
... i dont want to base it on (command "_trim"...

it's impossible.

 

 

...i'm using both acad and bricscad and a can't load expresstools in bricscad unfortunately

Try this, quick and dirty.

 

(defun c:test ( / xL p dir dirx Emax Emin d_off px xL2 px1 px2)
   (if (and
           (setq xL (car (entsel "\nPick a XLine for cutting edge... ")))
           (setq p (getpoint "\nSpecify the side to trim on: "))
           (setq dir (cdr (assoc 11 (entget xL))))
           (setq dir (list (abs (car dir)) (abs (cadr dir)) (last dir)))
           (or
               (setq dirx (equal dir '(1.0 0.0 0.0) 1e-5))
               (equal dir '(0.0 1.0 0.0) 1e-5)
           )
       )
       (progn
           (setq Emax (getvar 'extmax))
           (setq Emin (getvar 'extmin))
           (setq d_off (/ (distance Emax Emin) 4000)); <- change depending on the
                                                     ;    size of the model you have. 
           (command "_offset" d_off xL "_non" p "")
           (setq xL2 (entlast))
           (setq px (cdr (assoc 10 (entget xL2))))
           (if dirx
               (setq px1 (list (car Emin) (cadr px))
                     px2 (list (car Emax) (cadr px)))
               (setq px1 (list (car px) (cadr Emin) )
                     px2 (list (car px) (cadr Emax)))
           )
           (command "_zoom" "_w" "_non" px1 "_non" px2)
           (command "_trim" xL "" "_f" "_non" px1 "_non" px2 "" "")
           (entdel xL2)
           (command "_zoom" "_p")
       )
   )
   (princ)
)

Posted

The link I sent you above Post #4, shows you how to extend/trim, WITHOUT using the "command" function. It is entirely possible to do what you are looking for without using "command", however you need to do some research and learning on your own. Also works perfectly in BricsCAD as you indicated you are also using.

Posted

Try this:

(defun c:ltr (/ CMDECHO F3 OS F8 OTH P1 LOOP GR P2 DP SE2 SE1 N K EN ENL) 
 (defun *error* (s)
   (princ s)
   (setvar 'cmdecho cmdecho)
   (setvar 'osmode os)
   (setvar 'ORTHOMODE oth)
   )
 (setq cmdecho (getvar 'cmdecho))
 (setq f3 (getvar 'osmode) os f3)
 (setq f8 (getvar 'ORTHOMODE) oth f8)
 (setvar 'cmdecho 0)
   (initget 7)
 (setq p1 (getpoint "\nFirst point:"))
 (setq loop t)
 (while loop
   (setq gr (grread t 15))
   (redraw)
   (cond
     ((= 5 (car gr))
 (setq p2 (cadr gr))
 (if (= 1 f8)
   (progn
     (setq
       dp (mapcar '-
                  (apply 'mapcar (cons 'max (list p1 p2)))
                  (apply 'mapcar (cons 'min (list p1 p2)))
          )
     )
     (if (> (car dp) (cadr dp))
       (setq p2 (list (car p2) (cadr p1)))
       (setq p2 (list (car p1) (cadr p2)))
       )
     )
   )
      (grdraw p1 p2 1 -1)
      )
     ((= 3 (car gr))
      (setq loop nil)
      (setq p2 (cadr (grread t 15)))
      (if (= 1 f8)
   (progn
     (setq
       dp (mapcar '-
                  (apply 'mapcar (cons 'max (list p1 p2)))
                  (apply 'mapcar (cons 'min (list p1 p2)))
          )
     )
     (if (> (car dp) (cadr dp))
       (setq p2 (list (car p2) (cadr p1)))
       (setq p2 (list (car p1) (cadr p2)))
       )
     )
   )
      )
     ((equal gr '(2 6));
            (if (< f3  16384)
              (progn (setq f3 (+ f3 16384))(prompt "\n<Osnap off>"))
              (progn (setq f3 (- f3 16384))(prompt "\n<Osnap on>"))
             )
          (setvar "OSMODE" f3)
         )         
        ((equal gr '(2 15));
           (if (= f8 0)
              (progn(setq f8 1)(prompt "\n<Ortho on>"))
              (progn(setq f8 0)(prompt "\n<Ortho off>"))
             )
         (setvar "orthomode" f8)
         )
     )
   )
 (setq se2 (ssget "f" (list p1 p2)))
 (if (null se2) (abcdefg))
 (command "line" "non" p1 "non" p2 "")
 (setq se1 (entlast))
 (grdraw p1 p2 1 -1)
 (initget 7 "  ")
 (setq p1 (getpoint "\nWhich side trim?:"))
 (if (= "" p1) (abcdefg))
 (setq n (sslength se2) k 0)
 (repeat n
   (progn
     (setq en (ssname se2 k)
          enl (list en p1)
          )
     (command "trim" se1 "" enl "")
      (setq k (1+ k))
     )
   )
 (entdel se1)
 (redraw)
 (setvar 'cmdecho cmdecho)
   (setvar 'osmode os)
   (setvar 'ORTHOMODE oth)
 (princ)
 )

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...