Express tools "EXtrim" possible bug? AutoCAD Mechanical 2013

Express tools "EXtrim" possible bug? AutoCAD Mechanical 2013

SORONW
Advocate Advocate
963 Views
5 Replies
Message 1 of 6

Express tools "EXtrim" possible bug? AutoCAD Mechanical 2013

SORONW
Advocate
Advocate

I've encountered an issue with the express tools Extrim command in Autocad Mechanical 2013. When used with the attached drawing, Extrim will not trim the dashed line shown. This issue only seems to effect the top dashed line, and not the bottom.

 

Does anyone have any idea why this would be the case? 

 

0 Likes
Accepted solutions (2)
964 Views
5 Replies
Replies (5)
Message 2 of 6

marko_ribar
Advisor
Advisor
Accepted solution

Try this...

 

(defun c:extrim-MR ( / *error* *adoc* cmde highlight ss i ent enxl lay laxl s e p int pt ptl pt1 pt2 ptll ee )

  (vl-load-com)

  (defun *error* ( msg )
    (if cmde (setvar 'cmdecho cmde))
    (if highlight (setvar 'highlight highlight))
    (vla-endundomark *adoc*)
    (vla-regen *adoc* acactiveviewport)
    (if msg (prompt msg))
    (princ)
  )

  (setq *adoc* (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark *adoc*)
  (setq cmde (getvar 'cmdecho))
  (setq highlight (getvar 'highlight))
  (setvar 'cmdecho 0)
  (setq ss (ssget "_A" (list (cons 410 (if (= 1 (getvar 'cvport)) (getvar 'ctab) "Model")))))
  (if ss
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (if (eq 0 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (cdr (assoc 8 (entget ent))))))))
        (if (eq "Continuous" (cdr (assoc 6 (tblsearch "LAYER" (cdr (assoc 8 (entget ent)))))))
          (if (assoc 6 (entget ent))
            (if (not (eq "Continuous" (cdr (assoc 6 (entget ent)))))
              (progn
                (setq enxl (cons (entget ent) enxl))
                (entupd (cdr (assoc -1 (entmod (subst (cons 6 "ByLayer") (assoc 6 (entget ent)) (entget ent))))))
              )
            )
          )
          (progn
            (setq lay (tblobjname "LAYER" (cdr (assoc 8 (entget ent)))))
            (setq laxl (cons (entget lay) laxl))
            (entupd (cdr (assoc -1 (entmod (subst (cons 6 "Continuous") (assoc 6 (entget lay)) (entget lay))))))
            (if (assoc 6 (entget ent))
              (if (not (eq "Continuous" (cdr (assoc 6 (entget ent)))))
                (progn
                  (setq enxl (cons (entget ent) enxl))
                  (entupd (cdr (assoc -1 (entmod (subst (cons 6 "ByLayer") (assoc 6 (entget ent)) (entget ent))))))
                )
              )
            )
          )
        )
      )
    )
  )
  (vla-regen *adoc* acactiveviewport)
  (load "extrim.lsp")
  (prompt "\nPick a POLYLINE, LINE, CIRCLE, ARC, ELLIPSE, IMAGE or TEXT for cutting edge...")
  (setq s (ssget "_+.:E:S" '((0 . "*POLYLINE,LINE,CIRCLE,ARC,ELLIPSE,IMAGE,TEXT"))))
  (while (not s)
    (prompt "\nMissed... Pick a POLYLINE, LINE, CIRCLE, ARC, ELLIPSE, IMAGE or TEXT for cutting edge again...")
    (setq s (ssget "_+.:E:S" '((0 . "*POLYLINE,LINE,CIRCLE,ARC,ELLIPSE,IMAGE,TEXT"))))
  )
  (setq e (ssname s 0))
  (while (not (setq p (getpoint "\nSpecify the side to trim on:"))))
  (etrim e p)
  (foreach enx enxl
    (setq ent (entmakex (vl-remove-if '(lambda ( x ) (vl-position (car x) '(-1 5 330 360))) enx)))
    (entupd ent)
    (if (setq int (vlax-invoke (vlax-ename->vla-object ent) 'intersectwith (vlax-ename->vla-object e) acextendnone))
      (progn
        (repeat (/ (length int) 3)
          (setq pt (list (car int) (cadr int) (caddr int)))
          (setq ptl (cons pt ptl))
          (setq int (cdddr int))
        )
        (foreach pt ptl
          (setq pt1 (vlax-curve-getpointatparam ent (+ (vlax-curve-getparamatpoint ent pt) 1e-2)))
          (setq pt2 (vlax-curve-getpointatparam ent (- (vlax-curve-getparamatpoint ent pt) 1e-2)))
          (setq ptll (cons (list pt1 pt2) ptll))
        )
        (if (entget ent) (entdel ent))
        (if (entget ent) (entdel ent))
        (foreach pt1pt2 ptll
          (if (and (car pt1pt2) (ssget "_C" (car pt1pt2) (car pt1pt2) (list (assoc 0 enx)))) (setq ee (ssname (ssget "_C" (car pt1pt2) (car pt1pt2) (list (assoc 0 enx))) 0)))
          (if (and (cadr pt1pt2) (ssget "_C" (cadr pt1pt2) (cadr pt1pt2) (list (assoc 0 enx)))) (setq ee (ssname (ssget "_C" (cadr pt1pt2) (cadr pt1pt2) (list (assoc 0 enx))) 0)))
          (if (and ee (eq (type ee) 'ename)) (entupd (cdr (assoc -1 (entmod (append (entget ee) (list (assoc 6 enx))))))))
        )
      )
    )
    (setq int nil pt nil ptl nil pt1 nil pt2 nil ptll nil ee nil)
  )
  (foreach lax laxl
    (entupd (cdr (assoc -1 (entmod lax))))
  )
  (vl-cmdf "_.-overkill" "all" "" "_o" 1e-4 "_i" "_a" "_p" "_y" "")
  (*error* nil)
)

(defun c:et-MR nil (c:extrim-MR))
Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 3 of 6

CodeDing
Advisor
Advisor
Accepted solution

@SORONW ,

 

The linetype appears to be the affecting factor here.. Changing the linetype to continuous or reducing its scale alleviates the issue. Not sure WHY it's occurring though. Probably has to do with the way EXTRIM handles itself.. I'm pretty sure EXTRIM uses pixels to determine where linework is and how it should be handled (that's why it zooms to the area briefly during the command).. Whereas TRIM I believe uses mathematical calculation and intersection values to determine where lines should break/end. That may explain why we see a difference here.

 

Best,

~DD

0 Likes
Message 4 of 6

SORONW
Advocate
Advocate

@CodeDing Thats very interesting. I would have assumed that the two used similar calculations for the trimming process.

 

@marko_ribar Thank you, that seems like it will solve my issue. For my understanding, what does this code do differently than the express tools version that solves this issue?

0 Likes
Message 5 of 6

marko_ribar
Advisor
Advisor

@SORONW wrote:

@CodeDing Thats very interesting. I would have assumed that the two used similar calculations for the trimming process.

 

@marko_ribar Thank you, that seems like it will solve my issue. For my understanding, what does this code do differently than the express tools version that solves this issue?


It does what @CodeDing explained and performs extrim through routine...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

Another that I use is cookie cutter.lsp

 

; Cuts all objects within closed pline
;; What does CC2 do which ExpressTools extrim, AKA CookieCutter, doesn't?
;; Works with blocks, hatches and regions by exploding them.
;; Other object types which cannot be trimmed are left intact.
;; Works with objects which do not use a Continuous linetype.
;; Offers an option to delete all objects on visible layers either
;; inside or outside the selected trim object.

0 Likes