dimension varible question..

Discussion in 'AutoCAD' started by C Witt, Jul 8, 2003.

  1. C Witt

    C Witt Guest

    In the Dimension Style Manager.. there is an option to "Draw frame
    around text" (text tab). My question is.. can anyone think of a way to
    make this "frame" into a mask? ie: changing the dimension programming
    (if poss.).. or via some other route.. and still have it attached to
    the dimension..? (just one method i'm looking at).
     
    C Witt, Jul 8, 2003
    #1
  2. C Witt

    rewilson Guest

    Here's a routine that's not bad. You draw a box around the dim text, and it does a wipeout. To bring the text back, erase the box. Drawbacks........only does one dimension at a time, and osnaps & ortho are disabled during execution. Makes it a little inconvenient.It also doesn't handle stacked fractions very well.
    Written by Herman Mayfarth for R14.
    Hope it helps.



    ;;-----------------------C:MaskDimText------------------------------------ ;;Command to place a WIPEOUT behind selected DIMENSION text (one entity) ;;© 2001 Herman Mayfarth ;;Tested with AutoCAD Release 14.01 ;;Not tested with R15 ;;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. In R14.01, on my system, if the DIMENSION has been moved or copied, ;; the WIPEOUT is incorrectly placed at the *original* location of ;; the MTEXT object.(???) Don't know why, at this point. ;; ;; Feel free to modify to suit your own needs &/or whims. ;;------------------------------------------------------------------------ ;;global function ;;test function to see if wipeout.arx is available (defun wipeoutp () (if (member "wipeout.arx" (arx)) T (arxload "wipeout" nil) );if );wipeoutp ;; (defun C:MaskDimText ( / 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 2);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 wipeout.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" "M" "WIPEOUTS" "") ;;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" "n" (entlast) "y") ;;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:MaskDimText
     
    rewilson, Jul 9, 2003
    #2
  3. C Witt

    C Witt Guest

    I already have that file. and I wansn't asking for a seperate lisp..
     
    C Witt, Jul 9, 2003
    #3
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.