Author Topic: looking for a lisp - text with mask  (Read 18807 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« on: July 13, 2005, 02:43:27 PM »
i am looking for a macro or perhaps a lisp that would allow me to select as many text objects as i want. next i want to apply a background mask to all text selected. then i would like to bring all selected objects to front via draworder. i am using 2006 and know about the text to front command but everyone else is using 2005. if anyone could help me out i'd really appreciate it.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
looking for a lisp - text with mask
« Reply #1 on: July 13, 2005, 02:57:06 PM »
i have something similiar you might be able to modify.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
looking for a lisp - text with mask
« Reply #2 on: July 13, 2005, 02:57:58 PM »
Code: [Select]
(defun wiper ()
  (if (ssget "x" '((0 . "WIPEOUT")))
    (progn
      (imback)
      (COMMAND "_.wipeout" "_f" "_ON")
      (COMMAND "-LAYER" "m" "WIPEOUT" "c" "RED" "WIPEOUT" "")
      (setq ss1 (ssget "x" '((0 . "WIPEOUT"))))
      (COMMAND "_CHANGE" "p" "" "p" "la" "WIPEOUT" "")
      (setq ss1   (ssget "x" '((0 . "WIPEOUT")))
   SS1LEN (sslength SS1)
   ENT1   T
   COUNT  0
      )
;COUNT 0   )
      (REPEAT SS1LEN
(setq ent1 (ssname ss1 COUNT))
(COMMAND "_IREGFROMVEC" ENT1)
(SETQ COUNT (1+ COUNT))
      )
      (SETQ SS1REMS (ssget "x" '((0 . "AECIDBREMPOLYREG"))))
      (COMMAND "ERASE" SS1REMS "")
      (setq ss1 (ssget "x" '((0 . "WIPEOUT"))))
      (COMMAND "ERASE" SS1 "")
    )
  )
)
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
looking for a lisp - text with mask
« Reply #3 on: July 13, 2005, 02:59:18 PM »
This was written to remove wipeouts and create removals in a raster image.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
looking for a lisp - text with mask
« Reply #4 on: July 13, 2005, 03:01:29 PM »
Im thinking you will need to pull the corners of the text box to define your wipeout.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
looking for a lisp - text with mask
« Reply #5 on: July 13, 2005, 03:02:19 PM »
Code: [Select]
(defun imback ()
  (setq ss1 (ssget "x" '((0 . "IMAGE"))))
  (COMMAND "DRAWORDER" SS1 "" "b")
)
 this was called in the first routine, and can be changed to send your text forward
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #6 on: July 13, 2005, 03:07:16 PM »
mmm we have had problems with wipeouts in the past, people move the text and the frames get left behind so now that they have background mask it is the method we use for masking. i am trying to firgure out how to access the mask without manually doing it through properties or through mtext editor. i know you can setup a background mask in dimension styles but we use alot of old blocks which do not utilize this feature. i'm looking for a on the fly work around. i'll look at your code and see how much i can use. thanks

CADaver

  • Guest
looking for a lisp - text with mask
« Reply #7 on: July 13, 2005, 05:10:03 PM »
Express tools TEXTMASK, leave group select ON?

sourdough

  • Bull Frog
  • Posts: 367
you might also find this helpful.... these are some oldies
« Reply #8 on: July 14, 2005, 02:30:02 AM »
Here are a few of my retro oldies that still work great thru 2006

Code: [Select]

(defun c:tt () (setvar "pickstyle" 1)(c:textmask));shortcut that sets group text to mask



another oldie that will bring all mtext and text in the dwg to front

Code: [Select]

(defun C:MNA(/ mtext text pt1)
(setvar "cmdecho" 0)

  (setq mtext (ssget "X" ' ((0 . "MTEXT"))))
  (setq text (ssget "X" ' ((0 . "TEXT"))))

    (setq pt1 "0,0")
   
  (command "COPY" text "" pt1 pt1)
  (command "ERASE" "P" "")

  (command "COPY" mtext "" pt1 pt1)
  (command "ERASE" "P" "")

  (command "redraw")
  (setvar "cmdecho" 1)
)
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
looking for a lisp - text with mask
« Reply #9 on: July 14, 2005, 07:47:41 AM »
dan
I updated your title so it would at least hint at the subject.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #10 on: July 14, 2005, 09:17:52 AM »
thanks cab and everybody for your help. i haven't tried any of the ones you offered yet. I think i may have found one that does the job. here's what i found.

Code: [Select]
(defun C:MTMASK (/ MASK_LIST ENT SS)
;;(command "_.texttofront" "T")
;;(setq SS (ssget "x" '((0 . "mtext"))))
(setq ss (ssget))
(setq MASK_LIST
(list
(cons 90 3)
(cons 63 256)
(cons 45 1.5)
(cons 441 1616860)
)
N 0
)
(if SS
(repeat (sslength SS)
(setq ENT (entget (ssname SS N)))
(setq ENT (append ENT MASK_LIST))
(entmod ENT)
(setq N (1+ N))
)
)
(command "_.texttofront" "T")
(princ)
)

Hangman

  • Guest
looking for a lisp - text with mask
« Reply #11 on: July 19, 2005, 01:53:18 PM »
OK, this is in a very close proximity to my problem.  May I continue this line ???

I'm very intrigued by the lisp Eloquintet has posted here above.  I like the way it creates a mask around an mtext.  Now my question is, what type of mask is it and how is it taken off when no longer needed ???
Also, this leads into my masking a dimension string I have in the Vanilla side.  I tried the lisp above and have discovered that it does the same thing the mask does with the dimensions.  That is, it gives me a big black box when I plot the text to the printer.  How can I manipulate this ... whatever it is.  A text mask is a raster image so what is this ???

I am looking at creating a textmask lsp for masking dimensions because some of the users are exploding the dimension strings just to mask the text.  And I can't use the fillcolor in the dimension because it plots a black box.    To do, To do.   :?:

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #12 on: July 19, 2005, 03:08:00 PM »
i don't know how it does it hangman but i do have an unmask lisp as well. as far as exploding dimensions to apply a background, why doesn't applying a background in the dimension style work. and whoever is exploding dimensions needs to be canned period a definite no no  :evil:

Code: [Select]
(defun C:UNMTMASK (/ SS N)
(vl-load-com)
(setq SS (ssget "x" '((0 . "mtext")))
N 0
)
(if SS
(repeat (sslength SS)
(vla-put-backgroundfill
(vlax-ename->vla-object (ssname SS N))
0
)
(setq N (1+ N))
)
)
(princ)
)

Hangman

  • Guest
looking for a lisp - text with mask
« Reply #13 on: July 19, 2005, 06:52:44 PM »
Eloquintet,
Thanks for the unmasking lsp, it'll help in my search for peace.   :)

Quote
as far as exploding dimensions to apply a background, why doesn't applying a background in the dimension style work.


When plotting, I get a black box instead of the text.  I've heard people saying that it works great but no one can explain how their system is setup so I can find an answer to this problem.  The users explode the dimension string so they have dtext, then they can put a textmask around it.  This masking you have here is for the mtext and it works identical to the background in the dimension style.  The textmask I am speaking of is in the express tools, it creates a raster image.

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #14 on: July 20, 2005, 09:03:11 AM »
i guess you're talking about wipeout and i believe they had problems with that too here. i don't see why going into dimension style/text/fillcolor/background would not work for masking dimension text. then use the texttofront command. no black box here :?:

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #15 on: July 20, 2005, 09:08:11 AM »
you brought up something i hadn't really thought about hangman in that this lisp only works on mtext. could somebody help out with how to modify it so it would work on both mtext and dtext? that would be great thanks

Hangman

  • Guest
looking for a lisp - text with mask
« Reply #16 on: July 20, 2005, 01:49:52 PM »
ELOQUINTET said:
Quote
guess you're talking about wipeout and i believe they had problems with that too here. i don't see why going into dimension style/text/fillcolor/background would not work for masking dimension text. then use the texttofront command. no black box here


No, actually I am talking about the background fill similar to that being used in your lisp here.

Let me see if I can give you a pic:
...
        ...
                 ...
How the hell do I post a pic ???   :x

I have a 2% shade that I use for the background fill on the dimensions.  But when I plot the dwg, the 2% background fill comes out black as night, no legible text whatsoever.  One big black box.

We use textmask all the time because we can't print with the background fill.  But textmask doesn't work with the dimension string.  So I need to create a lisp file that will textmask dimension strings and group itself with the dimension string, or figure out how the background fill works for everybody else and not for me !!!   :x

What am I doing wrong that this stupid piece of ...   isn't working ???
Sorry, I'm frustrated.   :oops:

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #17 on: July 20, 2005, 03:14:31 PM »
did you try doing what i told you instead of trying to apply your 2% color to it. if i set my fill color to background it works great for dimensions. my problem was applying this to leaders but we have some old leaders which use dtext not mtext so it would be great if it worked on both. sorry that's all i can say about it

Hangman

  • Guest
looking for a lisp - text with mask
« Reply #18 on: July 21, 2005, 10:34:39 AM »
ELOQUINTET stated:
Quote
did you try doing what i told you ...


Yessir, I tried that, tried everything I could find and think of.  The background prints a solid, the fill prints a solid, None doesn't mask anything, the wireframe around text doesn't mask anything, express tools textmask doesn't work with associative dimensions, ...  I guess we explode them until we can find a solution.   :cry:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
looking for a lisp - text with mask
« Reply #19 on: July 21, 2005, 11:13:36 AM »
I don't use 2005 but this may help.
http://tinyurl.com/7nbkv
If not look here
http://tinyurl.com/axy3e
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #20 on: July 21, 2005, 11:32:52 AM »
cab i would like to enhance this routine by checking the entity to see if it is dtext or mtext. if it ismtext it would just mask it. if it is dtext it would first issue a prompt to the user identifying it as such. then it would give 2 choices. the user could choose to exit leaving it as dtext or the user could convert it to mtext using the express tool and then mask it. how would i go about modifying the existing routine?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
looking for a lisp - text with mask
« Reply #21 on: July 21, 2005, 11:42:32 AM »
I don't have the time, but look around for a routine txt2mtext.lsp
You can use it as a starter. You should be able to handle blending
two lisp together.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #22 on: July 21, 2005, 12:04:20 PM »
ok i have both lisps in a single file now but i'm just not clear on how to figure out if it's dtext or mtext and then prompt the user.

i'm guessing i could use getstring but maybe not.
then i'm guessing that i could use if and then based on the users choice when issued the prompt. i'm just terrible at formatting this stuff :oops:

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #23 on: July 21, 2005, 12:05:21 PM »
here's what i have right now  :?

Code: [Select]
; ----------------------------------------------------------------------
;                   (Converts Stack of TEXT to MTEXT)
;            Copyright (C) 1998 DotSoft, All Rights Reserved
;                      Website: www.dotsoft.com
; ----------------------------------------------------------------------
; DISCLAIMER:  DotSoft Disclaims any and all liability for any damages
; arising out of the use or operation, or inability to use the software.
; FURTHERMORE, User agrees to hold DotSoft harmless from such claims.
; DotSoft makes no warranty, either expressed or implied, as to the
; fitness of this product for a particular purpose.  All materials are
; to be considered ‘as-is’, and use of this software should be
; considered as AT YOUR OWN RISK.
; ----------------------------------------------------------------------

(defun col2str (inp)
  (cond
    ((= inp nil)(setq ret "BYLAYER"))
    ((= inp 256)(setq ret "BYLAYER"))
    ((= inp 0)(setq ret "BYBLOCK"))
    ((and (> inp 0)(< inp 255))(setq ret (itoa inp)))
    (t nil)
  )
)

(defun savprop ()
  (setq clayer (getvar "CLAYER"))
  (setq cecolor (getvar "CECOLOR"))
  (setvar "CECOLOR" "BYLAYER")
  (setq celtype (getvar "CELTYPE"))
  (setvar "CELTYPE" "BYLAYER")
  (setq thickness (getvar "THICKNESS"))
  (setvar "THICKNESS" 0)
  (if (>= (atoi (getvar "ACADVER")) 13)
    (progn
      (setq celtscale (getvar "CELTSCALE"))
      (setvar "CELTSCALE" 1.0)
    )
  )
)

(defun resprop ()
  (if (>= (atoi (getvar "ACADVER")) 13)
    (setvar "CELTSCALE" celtscale)
  )
  (setvar "THICKNESS" thickness)
  (setvar "CELTYPE" celtype)
  (setvar "CECOLOR" cecolor)
  (setvar "CLAYER" clayer)
)

(defun textrect (tent / ang sinrot cosrot t1 t2 p1 p2 p3 p4)
  (setq p0 (cdr (assoc 10 tent))
    ang (cdr (assoc 50 tent))
    sinrot (sin ang)
    cosrot (cos ang)
    t1 (car (textbox tent))
    t2 (cadr (textbox tent))
    p1 (list (+ (car p0)
       (- (* (car t1) cosrot) (* (cadr t1) sinrot)))
       (+ (cadr p0)
       (+ (* (car t1) sinrot) (* (cadr t1) cosrot))))
    p2 (list (+ (car p0)
       (- (* (car t2) cosrot) (* (cadr t1) sinrot)))
       (+ (cadr p0)
       (+ (* (car t2) sinrot) (* (cadr t1) cosrot))))
    p3 (list (+ (car p0)
       (- (* (car t2) cosrot) (* (cadr t2) sinrot)))
       (+ (cadr p0)
       (+ (* (car t2) sinrot) (* (cadr t2) cosrot))))
    p4 (list (+ (car p0)
       (- (* (car t1) cosrot) (* (cadr t2) sinrot)))
       (+ (cadr p0)
       (+ (* (car t1) sinrot) (* (cadr t2) cosrot))))
  )
  (list p1 p2 p3 p4)
)

(defun C:TXT2MTXT ( / mwid dset ibrk bitm bent sset rect mlay mcol mlst
                      bins bang tang nins num ndis chnd cent nhnd nstr
                      str pt1 pt2 pt3 dis dvx dvy dvz new)
  (if (< (atoi (getvar "ACADVER")) 13)
    (alert "This Function Requires\nRelease 13 or Higher")
    (progn
      (setq cmdecho (getvar "CMDECHO"))
      (setvar "CMDECHO" 0)
      (command "_.UNDO" "_G")
      (setq mwid 0.0)
      (setq dset (ssadd))
      ;
      (initget "Y N")
      (setq tmp (getkword "\nDS> Include Line Breaks <Y>/N: "))
      (if (/= tmp "N")(setq ibrk "Y")(setq ibrk "N"))
      ;
      (setq bitm (car (entsel "\nDS> Pick Base String: ")))
      (setq bent (entget bitm))
      (setq rect (textrect bent))
      (setq chk (distance (car rect)(cadr rect)))
      (if (> chk mwid)(setq mwid chk))
      ;
      (if (= "TEXT" (cdr (assoc 0 bent)))
        (progn
          (redraw bitm 3)
          (princ "\nDS> Select Remaining Text: ")
          (setq sset (ssget '((0 . "TEXT"))))
          (if sset
            (progn
              (setq rect (textrect bent))
              (setq orig rect)
              (setq mlay (cdr (assoc 8 bent)))
              (setq mcol (cdr (assoc 62 bent)))
              (setq mlst (list (cdr (assoc 1 bent))))
              ;
              (if (> (cdr (assoc 72 bent)) 0)
                (setq bins (cdr (assoc 11 bent)))
                (setq bins (cdr (assoc 10 bent)))
              )
              (setq bang (cdr (assoc 50 bent)))
              (setq tang (- bang (/ PI 2)))
              (setq nins bins)
              (ssdel bitm sset)
              (while (> (sslength sset) 0)
                (setq num (sslength sset) itm 0)
                (setq ndis 99999999.9)
                (while (< itm num)
                  (setq chnd (ssname sset itm))
                  (setq cent (entget chnd))
                  (if (> (cdr (assoc 72 cent)) 0)
                    (setq cins (cdr (assoc 11 cent)))
                    (setq cins (cdr (assoc 10 cent)))
                  )
                  (setq cdis (distance bins cins))
                  (if (< cdis ndis)
                    (setq ndis cdis nhnd chnd nent cent)
                  )
                  (setq itm (1+ itm))
                )
                (setq dset (ssadd nhnd dset))
                (ssdel nhnd sset)
                ;
                (setq rect (textrect nent))
                (setq chk (distance (car rect)(cadr rect)))
                (if (> chk mwid)(setq mwid chk))
                ;
                (setq nstr (cdr (assoc 1 nent)))
                (setq mlst (append mlst (list nstr)))
              )
              ;
              (entdel bitm)
              (setq num (sslength dset) itm 0)
              (while (< itm num)
                (setq hnd (ssname dset itm))
                (entdel hnd)
                (setq itm (1+ itm))
              )
              ;
              (savprop)
              (setvar "CLAYER" mlay)
              (if (/= mcol nil)
                (setvar "CECOLOR" (col2str mcol))
              )
              (setq mwid (+ mwid (* mwid 0.025)))
              (setq pt1 (car orig))
              (setq pt2 (cadr orig))
              (setq dis (distance pt1 pt2))
              (setq dvx (/ (- (car pt2)(car pt1)) dis))
              (setq dvy (/ (- (cadr pt2)(cadr pt1)) dis))
              (setq pt3 (list dvx dvy 0.0))
              (setq nins (list (car (cadddr orig))
                         (cadr (cadddr orig))
                         (nth 2 (cdr (assoc 10 bent)))))
              ;
              (setq new '((0 . "MTEXT")(100 . "AcDbEntity")(100 . "AcDbMText")))
              (setq new (append new (list (assoc 7 bent))))
              (setq new (append new (list (assoc 8 bent))))
              (setq new (append new (list (cons 10 nins))))
              (setq new (append new (list (cons 11 pt3))))
              (foreach lin mlst
                (if (= ibrk "Y")
                  (if (/= lin (last mlst))
                    (setq lin (strcat lin "\\P"))
                  )
                  (setq lin (strcat lin " "))
                )
                (setq new (append new (list (cons 1 lin))))
              )
              (setq new (append new (list (assoc 40 bent))))
              (setq new (append new (list (cons 41 mwid))))
              (setq new (append new (list (cons 71 1))))
              (setq new (append new (list (cons 72 1))))
              (entmake new)
              (resprop)
              ;
              (setq sset nil)
              (setq dset nil)
              (setq lst nil)
              (command "_.UNDO" "_E")
              (setvar "CMDECHO" cmdecho)
            )
            (redraw bitm 4)
          )
        )
      )
    )
  )
  (setq sset nil)
  (setq mlst nil)
  (princ)
)

(defun C:TMASK (/ MASK_LIST ENT SS)
;;(command "_.texttofront" "T")
;;(setq SS (ssget "x" '((0 . "mtext"))))
(setq ss (ssget))
(setq MASK_LIST
(list
(cons 90 3)
(cons 63 256)
(cons 45 1.5)
(cons 441 1616860)
)
N 0
)
(if SS
(repeat (sslength SS)
(setq ENT (entget (ssname SS N)))
(setq ENT (append ENT MASK_LIST))
(entmod ENT)
(setq N (1+ N))
)
)
(command "_.texttofront" "T")
(princ)
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
looking for a lisp - text with mask
« Reply #24 on: July 21, 2005, 12:42:16 PM »
As you can see from the lisp it not a trivial matter changing text to mtext.
You can re-write the main function to by pass the prompts by passing it the
information needed. The issue you will have is that the first dtext item
will control the layer & color & perhaps the text height. Then the user must
pick the additional dtext to include. This will be difficult to automate.

My suggestion would be to keep these as separate functions. This means the user
will have to process the dtext as you must do now. you could write a routine
to help the user locate the dtext.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7526
looking for a lisp - text with mask
« Reply #25 on: July 21, 2005, 12:53:16 PM »
Here is a simple lisp using CABS getboundingbox to add a mask to dim text without exploding.


Code: [Select]
(defun c:dmask (/ ename ent bbox)

  (defun getboundingbox (obj / minpt maxpt llc urc)
    (vla-getboundingbox obj 'minpt 'maxpt)
    (mapcar 'vlax-safearray->list (list minpt maxpt))
    (setq llc (vlax-safearray->list minpt)
 urc (vlax-safearray->list maxpt)
    )
    (list llc urc)
  )


  (setq ename (car (Nentsel)))
  (setq ent (vlax-ename->vla-object ename))
  (setq bbox (getboundingbox ent)
llc  (car bbox)
urc  (cadr bbox)
  )
  (command ".rectangle" llc urc)
  (command ".wipeout" "p" "l" "y" "")
  (command ".draworder" "l" "" "b")
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #26 on: July 21, 2005, 01:09:31 PM »
i personally don't know why one would not want to convert the dtext to mtext in the first place so i don't see the need for the prompt but my boss seems to think there's a need so...

Hangman

  • Guest
looking for a lisp - text with mask
« Reply #27 on: July 21, 2005, 07:29:44 PM »
Cab,
Thanks for the links.  Although it doesn't fix my problem, it did spark another thought I can try.

RonJonp, the lisp seems to be working only on mtext.  It does nothing when selecting dimensions, it dropped a masking box at the insert point of a dtext, but then the last two corners of the box overlap the first two corners, in essence, creating an overlapping line.  It works great for mtext though !!!   :)    thanks though.

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #28 on: July 22, 2005, 10:46:17 AM »
man i really need to learn this stuff. my boss wants me to create this but i don't really know where to go from here. i am going to start stuying stigs lisp tutorial again but that will take some time and she wants results right away so if anyone could find it in their heart to throw me a bone one last time i would most appreciate it. i was looking in the reference and saw something about dxf codes 100 and 200 but am not sure how to tell it to look for one or the other. sigh heeeeelp

tcdan

  • Guest
looking for a lisp - text with mask
« Reply #29 on: July 22, 2005, 11:40:07 AM »
Stig never did open his tutorial up to the public did he. . . ?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
looking for a lisp - text with mask
« Reply #30 on: July 22, 2005, 11:40:21 AM »
I though I posted this yesterday but must not have completed the POST before I jumped to
another site. So here it is again.
With this routine you need to pick the actual text in the dimension.

I think I found the original code: http://tinyurl.com/9t5d4
as there was a copy here http://tinyurl.com/b4lg8


The following is modified from the original

Code: [Select]
;; (2005) CAB added check for expresstools loaded & support for
;;  wipeout command change from ACAD2000

;;Modified By C Witt (2003)
;;
;;--------------------------Ma­skDimText---------------------­---------------
;;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 ()
;;
;;===========================================================
;;  CAB 03/20/2005
    ;;  Check for ExpressTools
    (if (member "acetutil.arx" (arx))
(if (wcmatch (getvar "ACADVER") "*16*")
           (or (NOT (arxload "acwipeout")) (setq et T))
           (or (not(member "wipeout.arx" (arx)))(setq et T))
)
    )
  et
  ;;============================================================
);wipeoutp

(defun C:maskdim ( / cecho oldlyr ent flag outer
                         boxmtext
                         lwrect
                 )
;;local functions
;;;--------------------boxmtex­t-----------------------------­--------
;;;  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
;;;-------------------------lw­rect--------------------------­----------
;;; 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" "M" "TEXT" "") ; CAB S to M
;;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")
  ;;  CAB  -----------------------------------------------------
  (if  (< (atof (getvar "acadver")) 16.0) ; nil = r2004 or later
    (command "_.wipeout" "n" (entlast) "y") ; < 2004
    (command "_.wipeout" "p" (entlast) "y") ; 2004+
  )
  ;;  CAB  -----------------------------------------------------
 
;;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
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #31 on: July 22, 2005, 12:29:33 PM »
cab is that post for me or tc because i am not looking to mask my dimension text or use wipeouts. i would like it to first determine what the entities are (dtext or mtext) then if it is dtext it would prompt the user to either convert to mtext  then mask it using the manner in the code not wipeout or just cancel. if it is mtext it would just mask it. i am reading through the tutorials now. i don't know the answer for tc i joined initially and can login to the learning center

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
looking for a lisp - text with mask
« Reply #32 on: July 22, 2005, 12:37:18 PM »
Quote from: Hangman
I am looking at creating a textmask lsp for masking dimensions because some of the users are exploding the dimension strings just to mask the text.  And I can't use the fillcolor in the dimension because it plots a black box.    To do, To do.   :?:


It was for Hangman. :roll:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
looking for a lisp - text with mask
« Reply #33 on: July 22, 2005, 01:01:07 PM »
sigh...thread hijacker

Hangman

  • Guest
looking for a lisp - text with mask
« Reply #34 on: July 22, 2005, 01:24:31 PM »
ELOQUINTET sighed:
Quote
sigh...thread hijacker


Sorry, I was struggling with my thread and you have a very close topic to my own problem.  It was very unintentional, I promise.   :oops:

 :P   So what can I do for you :?:
I'd write your lisp but you'll have to give me about two weeks, I'm in the same boat ...  just learning this stuff.  

BTW,  Thanks CAB, I really appreciate your help.

tcdan

  • Guest
looking for a lisp - text with mask
« Reply #35 on: July 24, 2005, 12:40:49 AM »
Quote
i am reading through the tutorials now. i don't know the answer for tc i joined initially and can login to the learning center

I guess stig's going public with his 10 week email-based course. . . although I bet not without a little fee
http://www.smadsen.com/course.htm