PDA

View Full Version : Remove Text Mask On Select Dimension Objetcs



jpcadconsulting347236
2015-03-23, 06:37 PM
Hi folks,

I found this LISP routine below which works great to add a text mask to selected dimension objects (thanks Henrique Silva)

What I need now is the reverse routine, so I can remove text masks from selected dimension objects.


(defun c:test (/ CNT ENT ENTDATA NEWENTDATA NUM SS1) (vl-load-com)
(setq ss1 (ssget '((0 . "Dimension")))
num (sslength ss1)
cnt 0
)
(repeat num
(setq ent (entget (ssname ss1 cnt)))
(setq entdata '((-3 ("ACAD" (1000 . "DSTYLE") (1002 . "{") (1070 . 69) (1070 . 1) (1002 . "}")))))
(setq newentdata (append ent entdata))
(entmod newentdata)
(setq cnt (1+ cnt))
)
(vl-cmdf "_draworder" ss1 "" "f") )

Any help is as always, much appreciated.

hmsilva
2015-03-23, 09:54 PM
Hi,

to toggle dimension texto mask, perhaps something like this


(vl-load-com)
(defun c:demo (/ ent entdata hnd i newentdata ss xdata)
(if (setq ss (ssget '((0 . "Dimension"))))
(repeat (setq i (sslength ss))
(setq hnd (ssname ss (setq i (1- i)))
ent (entget hnd '("ACAD"))
)
(if (or (not (setq xdata (assoc -3 ent)))
(and (setq xdata (assoc -3 ent))
(member '(1000 . "DSTYLE") (last xdata))
(/= (cdr (assoc 1070 (reverse (last xdata)))) 1)
(setq ent (vl-remove-if '(lambda (x) (= -3 (car x))) ent))
);; and
);; or
(setq entdata '((-3 ("ACAD" (1000 . "DSTYLE")(1002 . "{")(1070 . 69)(1070 . 1)(1002 . "}"))))
newentdata (append ent entdata))
(setq ent (vl-remove-if '(lambda (x) (= -3 (car x))) ent)
entdata '((-3 ("ACAD"(1000 . "DSTYLE")(1002 . "{")(1070 . 69)(1070 . 0)(1002 . "}"))))
newentdata (append ent entdata))
);; if
(entmod newentdata)
);; repeat
);; if
(princ)
);; demo


Hope this helps
Henrique

jpcadconsulting347236
2015-05-04, 03:05 PM
Brilliant!!! Works like a charm.

Thanks very much for your time and effort!

hmsilva
2015-05-04, 03:23 PM
You're welcome, James
Glad I could help

Henrique

jpcadconsulting347236
2015-05-05, 03:19 PM
How hard would it be to include Mtext and Multileaders in this routine?

I though it might be as simple as changing the SSGET line to:


(if (setq ss (ssget '((0 . "Dimension,Multileader,Mtext"))))

As you might have guessed, I'm wrong about that. ;-)

Anyway, if its a big deal, don't sweat it. There are other text mask routines out there. Just though it might be nice to have one "catch all" command.

Again, thanks for your time and effort.

hmsilva
2015-05-05, 04:39 PM
How hard would it be to include Mtext and Multileaders in this routine?
I though it might be as simple as changing the SSGET line to:

(if (setq ss (ssget '((0 . "Dimension,Multileader,Mtext"))))
As you might have guessed, I'm wrong about that. ;-)
Anyway, if its a big deal, don't sweat it. There are other text mask routines out there. Just though it might be nice to have one "catch all" command.
Again, thanks for your time and effort.

James,

quick and dirty, and not fully tested...


(vl-load-com)
(defun c:TMask (/ ent entdata hnd i newentdata ob1 ss xdata)
(if (setq ss (ssget "_:L" '((0 . "DIMENSION,MTEXT,MULTILEADER"))))
(repeat (setq i (sslength ss))
(setq hnd (ssname ss (setq i (1- i)))
ent (entget hnd)
)
(cond ((= (cdr (assoc 0 ent)) "MTEXT")
(setq ob1 (vlax-ename->vla-object hnd))
(vlax-put ob1 'backgroundfill (~ (vlax-get ob1 'backgroundfill)))
)
((= (cdr (assoc 0 ent)) "MULTILEADER")
(setq ob1 (vlax-ename->vla-object hnd))
(vlax-put ob1 'textbackgroundfill (~ (vlax-get ob1 'textbackgroundfill)))
)
(T
(setq ent (entget hnd '("ACAD")))
(if (or (not (setq xdata (assoc -3 ent)))
(and (setq xdata (assoc -3 ent))
(member '(1000 . "DSTYLE") (last xdata))
(/= (cdr (assoc 1070 (reverse (last xdata)))) 1)
(setq ent (vl-remove-if '(lambda (x) (= -3 (car x))) ent))
)
)
(setq entdata '((-3 ("ACAD" (1000 . "DSTYLE") (1002 . "{") (1070 . 69) (1070 . 1) (1002 . "}"))))
newentdata (append ent entdata)
)
(setq ent (vl-remove-if '(lambda (x) (= -3 (car x))) ent)
entdata '((-3 ("ACAD" (1000 . "DSTYLE") (1002 . "{") (1070 . 69) (1070 . 0) (1002 . "}"))))
newentdata (append ent entdata)
)
)
(entmod newentdata)
)
)
)
)
(princ)
)


I hope this helps.
Henrique

jpcadconsulting347236
2015-05-05, 05:04 PM
Thanks again!!! I'm going to test now. I'll keep you posted.

jpcadconsulting347236
2015-05-05, 05:11 PM
Works fine after the following edit: I had to remove TEXT from line 3 as I realize plain text does not support this function anyway...


(vl-load-com)
(defun c:TMask (/ ent entdata hnd i newentdata ob1 ss xdata)
(if (setq ss (ssget "_:L" '((0 . "DIMENSION,MTEXT,MULTILEADER"))))
(repeat (setq i (sslength ss))
(setq hnd (ssname ss (setq i (1- i)))
ent (entget hnd)
)
(cond ((wcmatch (cdr (assoc 0 ent)) "*TEXT")
(setq ob1 (vlax-ename->vla-object hnd))
(vlax-put ob1 'backgroundfill (~ (vlax-get ob1 'backgroundfill)))
)
((= (cdr (assoc 0 ent)) "MULTILEADER")
(setq ob1 (vlax-ename->vla-object hnd))
(vlax-put ob1 'textbackgroundfill (~ (vlax-get ob1 'textbackgroundfill)))
)
(T
(setq ent (entget hnd '("ACAD")))
(if (or (not (setq xdata (assoc -3 ent)))
(and (setq xdata (assoc -3 ent))
(member '(1000 . "DSTYLE") (last xdata))
(/= (cdr (assoc 1070 (reverse (last xdata)))) 1)
(setq ent (vl-remove-if '(lambda (x) (= -3 (car x))) ent))
)
)
(setq entdata '((-3 ("ACAD" (1000 . "DSTYLE") (1002 . "{") (1070 . 69) (1070 . 1) (1002 . "}"))))
newentdata (append ent entdata)
)
(setq ent (vl-remove-if '(lambda (x) (= -3 (car x))) ent)
entdata '((-3 ("ACAD" (1000 . "DSTYLE") (1002 . "{") (1070 . 69) (1070 . 0) (1002 . "}"))))
newentdata (append ent entdata)
)
)
(entmod newentdata)
)
)
)
)
(princ)
)

I seem to be making a habit of thanking your for your hard work! ;-)

hmsilva
2015-05-05, 06:53 PM
:Oops:
Too much quick and dirty...
Code revised.

Henrique

jpcadconsulting347236
2015-05-12, 03:46 PM
Well, once more I'm trying to modify your code to turn off all text mask globally... but as usual, I'm failing. ;-)

Any insight would be helpful. it simply needs to turn off text mask in ALL Dims, Mleaders and Mtext. Should be simple... but not for me.

I've replaced the line:


(if (setq ss (ssget "_:L" '((0 . "DIMENSION,MTEXT,MULTILEADER"))))

With:


(if (setq ss (ssget "X" (list(cons 0 "DIMENSION,MTEXT,MULTILEADER"))))

So that it simply selects all those objects without prompting for user input. However, after that, i can't really figure out what's happening...

Thanks as always Henrique.

jpcadconsulting347236
2015-05-12, 04:11 PM
OK I got it!!! I'm sure it could be simplified as I don't think it really needs the IF/ELSE bit for DIMENSIONS anymore.

But it's now globally disabling background fill for DIMS, MTEXT and MLEADERS!!!




(vl-load-com)
(defun c:unmask (/ ent entdata hnd i newentdata ob1 ss xdata)
(if (setq ss (ssget "X" (list(cons 0 "DIMENSION,MTEXT,MULTILEADER"))))
(repeat (setq i (sslength ss))
(setq hnd (ssname ss (setq i (1- i)))
ent (entget hnd)
)
(cond ((wcmatch (cdr (assoc 0 ent)) "*TEXT")
(setq ob1 (vlax-ename->vla-object hnd))
(vlax-put ob1 'backgroundfill 0)
)
((= (cdr (assoc 0 ent)) "MULTILEADER")
(setq ob1 (vlax-ename->vla-object hnd))
(vlax-put ob1 'textbackgroundfill 0)
)
(T
(setq ent (entget hnd '("ACAD")))
(if (or (not (setq xdata (assoc -3 ent)))
(and (setq xdata (assoc -3 ent))
(member '(1000 . "DSTYLE") (last xdata))
(/= (cdr (assoc 1070 (reverse (last xdata)))) 1)
(setq ent (vl-remove-if '(lambda (x) (= -3 (car x))) ent))
)
)
(setq entdata '((-3 ("ACAD" (1000 . "DSTYLE") (1002 . "{") (1070 . 69) (1070 . 0) (1002 . "}"))))
newentdata (append ent entdata)
)
(setq ent (vl-remove-if '(lambda (x) (= -3 (car x))) ent)
entdata '((-3 ("ACAD" (1000 . "DSTYLE") (1002 . "{") (1070 . 69) (1070 . 0) (1002 . "}"))))
newentdata (append ent entdata)
)
)
(entmod newentdata)
)
)
)
)
(princ)
)

jpcadconsulting347236
2015-05-12, 04:50 PM
I found another way as well.

Using Lee Mac's StripMtext routine, you can issue the following code (assuming StrimMtext.lsp is loaded)


^C^C(if (setq ss (ssget "X" (list(cons 0 "DIMENSION,MTEXT,MULTILEADER"))))(StripMtext ss "M"))

Oddly enough, I can't seem to find StripMtext on his site anymore... not sure what's up with that. But it's available all over if you search for it.

hmsilva
2015-05-12, 06:16 PM
Hi James,

with the 'unmask' function, you are trying to unmask, DIMENSION,MTEXT and MULTILEADER objects?
Or just MTEXT and MULTILEADER objects?

StripMtext, by Steve Doman and Joe Burke (https://cadabyss.wordpress.com/2010/01/04/stripmtext-v5-0/)


Henrique

jpcadconsulting347236
2015-05-12, 06:31 PM
Everything. ;-)

DIMENSION,MTEXT and MULTILEADER.

hmsilva
2015-05-12, 06:49 PM
James,

as far as I can remembre, StripMtex, is not from Lee Mac, is from Steve Doman and Joe Burke...(Link in my previous post)

Henrique