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

0 Members and 1 Guest are viewing this topic.

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