dimension text mask

Discussion in 'AutoCAD' started by jon, Jun 30, 2004.

  1. jon

    jon Guest

    I found an old post discussing a lisp routine for masking dimension text.. Anywhere to be found?
    Thanks!
     
    jon, Jun 30, 2004
    #1
  2. jon

    C Witt Guest

    attached the lisp you are looking for..

    ona side note, if you are using 2K5.. you are far better off using
    background masks.
    ;;Modified By C Witt (2003)
    ;;
    ;;--------------------------MaskDimText------------------------------------
    ;;Command to place a WIPEOUT behind selected DIMENSION text (one entity)
    ;;© 2001 Herman Mayfarth
    ;;Tested with AutoCAD Release 16 (2K4)
    ;;Known limitations:
    ;; 1. This routine works by asking the user to select a nested MTEXT object,
    ;; and uses that object's entity data to define the WIPEOUT boundary.
    ;; If you have dimension text stacked over/under the dimension line,
    ;; i.e. using the \X code, this routine will _not_ mask all the text,
    ;; since the over/under text are separate MTEXT entities.
    ;; (A better & more sophisticated way would be to walk through the
    ;; DIMENSION block & determine the bounding box of all MTEXT objects in the
    ;; block, but this is a Q & D 1st attempt)
    ;; 2. This lisp command is designed for R16 (2K4).
    ;;
    ;; Feel free to modify to suit your own needs &/or whims.
    ;;------------------------------------------------------------------------
    ;;global function
    ;;test function to see if acwipeout.arx is available
    (defun wipeoutp ()
    (if (member "acwipeout.arx" (arx))
    T
    (arxload "acwipeout" nil)
    );if
    );wipeoutp
    ;;
    (defun C:maskdim ( / cecho oldlyr ent flag outer
    boxmtext
    lwrect
    )
    ;;local functions
    ;;;--------------------boxmtext-------------------------------------
    ;;; Purpose: draws a lwpolyline rectangle to enclose an MTEXT entity
    ;;; Parameter: entity name of MTEXT entity
    ;;; External function: lwrect to draw the rectangle
    ;;;-----------------------------------------------------------------
    (defun boxmtext (ename / mtxtnt p10 h ang1 delta d1 boxang boxdia
    attach vec p1 p3 hor vert)
    (setq mtxtnt (entget ename)
    p10 (cdr (assoc 10 mtxtnt))
    h (cdr (assoc 40 mtxtnt))
    hor (cdr (assoc 42 mtxtnt))
    vert (cdr (assoc 43 mtxtnt))
    ang1 (cdr (assoc 50 mtxtnt))
    attach (cdr (assoc 71 mtxtnt))
    vec (getvar "UCSXDIR")
    ang1 (+ (atan (cadr vec) (car vec)) ang1)
    delta (* h 0.35);adjust as req'd
    d1 (+ hor (* 2 delta))
    boxang (atan (+ vert (* 2 delta)) d1)
    boxdia (* (/ 1 (cos boxang)) d1)
    );setq
    (cond ((= attach 1);top left
    (setq p1 (polar p10 (+ (/(* 3 pi) 2) ang1) (+ vert delta))))
    ((= attach 2);top center
    (setq p1
    (polar (polar p10 (+ pi ang1) (/ hor 2)) (+ (/(* 3 pi) 2) ang1) (+ vert

    delta))))

    ((= attach 3);top right
    (setq p1
    (polar (polar p10 (+ pi ang1) hor) (+ (/(* 3 pi) 2) ang1) (+ vert delta))))
    ((= attach 4);middle left
    (setq p1 (polar p10 (+ (/(* 3 pi) 2) ang1) (+ (/ vert 2) delta))))
    ((= attach 5);middle center
    (setq p1
    (polar (polar p10 (+ pi ang1) (/ hor 2)) (+ (/(* 3 pi) 2) ang1) (+ (/ vert 2)

    delta))))

    ((= attach 6);middle right
    (setq p1
    (polar (polar p10 (+ pi ang1) hor) (+ (/(* 3 pi) 2) ang1) (+ (/ vert 2)

    delta))))

    ((= attach 7) ;bottom left
    (setq p1 (polar p10 (+ (/(* 3 pi) 2) ang1) delta)))
    ((= attach 8);bottom center
    (setq p1
    (polar (polar p10 (+ pi ang1) (/ hor 2)) (+ (/(* 3 pi) 2) ang1) delta)))
    ((= attach 9);bottom right
    (setq p1
    (polar (polar p10 (+ pi ang1) hor) (+ (/(* 3 pi) 2) ang1) delta)))
    );cond
    (setq
    p1 (polar p1 (+ pi ang1) delta)
    p3 (polar p1 (+ boxang ang1) boxdia)
    );setq
    (lwrect p1 p3 ang1 (getvar "CLAYER") 256 (getvar "CELTYPE"))
    );boxmtext
    ;;;-------------------------lwrect------------------------------------
    ;;; Purpose: draws a lightweight polyline rectangle
    ;;; Params: p1,p3 - WCS points at opposite corners
    ;;; rotate - rotation angle of selected axis in radians
    ;;; layer, color, ltype what they say
    ;;; Returns: EAL of entity
    (defun lwrect (p1 p3 rotate layer color ltype / d13 abox p2 p4 elist)
    (setq d13 (distance p1 p3)
    abox (- (angle p1 p3) rotate)
    p2 (polar p1 rotate (* (cos abox) d13))
    p4 (polar p1 (+ rotate (/ pi 2)) (* (sin abox) d13))
    )
    (entmake (list '(0 . "LWPOLYLINE")
    '(100 . "AcDbEntity")
    '(100 . "AcDbPolyline")
    (cons 6 ltype)
    (cons 8 layer)
    '(43 . 0)
    (cons 62 color)
    '(90 . 4)
    (cons 10 p1)
    (cons 10 p2)
    (cons 10 p3)
    (cons 10 p4)
    '(70 . 1);closed pline - must follow G.C. 10s
    )
    )
    );lwrect
    ;;Main program
    ;;if acwipeout.arx is available
    (if (wipeoutp)
    ;;proceed
    (progn
    ;;save sysvars
    (setq cecho (getvar "CMDECHO") oldlyr (getvar "CLAYER"))
    ;;start UNDO group
    (command "_.UNDO" "BEGIN")
    (setvar "CMDECHO" 1)
    ;;setup a layer for WIPEOUTs
    (command "_.LAYER" "S" "TEXT" "")
    ;;loop until an MTEXT entity in a DIMENSION is selected
    (setq flag T)
    (while flag
    (setq alist (nentsel "\nSelect Dimension Text to Mask: ")
    ent (car alist)
    outer (car(last alist))
    )
    (if (= "MTEXT" (cdr (assoc 0 (entget ent))))
    (setq flag nil)
    )
    );while
    ;;draw a LWPOLYLINE rectangle enclosing the MTEXT
    (boxmtext ent)
    ;;call command to draw the WIPEOUT using the preceding LWPOLYLINE
    (command "_.wipeout" "" (entlast) "y")
    ;;change WIPEOUT to color 255
    (command "chprop" (entlast) "" "c" "255" "")
    ;;now call draworder to bring the DIMENSION to the front
    ;;it would be nice if there is a better way, that doesn't force a regen
    ;;the only sure way I can think of is to delete the DIMENSION and remake it
    (command "_.draworder" outer "" "front");causes a regen
    ;;restore sysvars & end UNDO group
    (setvar "CMDECHO" cecho)
    (setvar "CLAYER" oldlyr)
    (command "_.UNDO" "END")
    );progn
    (alert "Wipeouts Not Available.")
    );if
    (princ)
    );C:MD
     
    C Witt, Jun 30, 2004
    #2
  3. jon

    jon Guest

    thanks!

     
    jon, Jun 30, 2004
    #3
  4. jon

    jon Guest

    exactly what do you type at the command prompt?


     
    jon, Jun 30, 2004
    #4
  5. jon

    C Witt Guest

    *looks at lisp*

    maskdim

    that should work, been a while since we needed to use it. ;Þ
     
    C Witt, Jun 30, 2004
    #5
  6. jon

    C Witt Guest

    btw, jon.

    this lisp was "changed" so we could screen out the wipeout color thus
    preventing any problems with printing a pdf'ed drawing.

    just a little fyi
     
    C Witt, Jun 30, 2004
    #6
  7. jon

    jon Guest

    i'm getting this when i type mask dim..

    Enter layer name to make current or <select object>: TEXT
    Cannot find layer "TEXT".
    ; error: Function cancelled
     
    jon, Jun 30, 2004
    #7
  8. jon

    C Witt Guest

    one of the "tweeks" I made. it drops the mask on the "text" layer..
    you can change that to what ever layout you want.
     
    C Witt, Jun 30, 2004
    #8
  9. jon

    jon Guest

    thanks much! works great!
     
    jon, Jun 30, 2004
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.