Author Topic: Toggle background fill color on a Dimension  (Read 7408 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Toggle background fill color on a Dimension
« on: August 13, 2012, 11:19:20 AM »
I want to write a program to toggle the background color of a dimension, ie. background mask. I want to use Fill Color of 'Background'. When I dump properties on a dimension I don't see TextFillColor change from 0 or TextFill change from 0.

Example (no background fill):
;   TextColor = 0
;   TextFill = 0
;   TextFillColor = 0

Example (background fill color 1):
;   TextColor = 0
;   TextFill = -1
;   TextFillColor = 1

Example (background fill color 'Background'):
;   TextColor = 0
;   TextFill = 0
;   TextFillColor = 0

So how is one supposed to toggle this using autolisp?
TheSwamp.org  (serving the CAD community since 2003)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Toggle background fill color on a Dimension
« Reply #1 on: August 13, 2012, 11:40:00 AM »
Haven't tried it:
http://www.theswamp.org/index.php?topic=39217.0

Did you need plain lisp only?
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.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Toggle background fill color on a Dimension
« Reply #2 on: August 13, 2012, 11:44:45 AM »
Thanks Alan, i'll look it over. :)

Don't know why i didn't do a search. oop's
TheSwamp.org  (serving the CAD community since 2003)

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Toggle background fill color on a Dimension
« Reply #3 on: August 13, 2012, 12:33:56 PM »
To toggle the background fill on/off, you should be able to use simply:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:dimmask ( / en ob )
  2.     (if
  3.         (and
  4.             (setq en (car (entsel "\nSelect Dimension: ")))
  5.             (wcmatch (cdr (assoc 0 (entget en))) "*DIMENSION")
  6.             (setq ob (vlax-ename->vla-object en))
  7.         )
  8.         (vlax-put ob 'textfill (~ (vlax-get ob 'textfill)))
  9.     )
  10.     (princ)
  11. )

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Toggle background fill color on a Dimension
« Reply #4 on: August 13, 2012, 01:08:04 PM »
To toggle the background fill on/off, you should be able to use simply:
that sets Fill Color to 'ByBlock'.
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Toggle background fill color on a Dimension
« Reply #5 on: August 13, 2012, 01:20:55 PM »
I don't see anyway of knowing when the dim has fill color set to 'background'.
TheSwamp.org  (serving the CAD community since 2003)

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Toggle background fill color on a Dimension
« Reply #6 on: August 13, 2012, 01:25:26 PM »
To toggle the background fill on/off, you should be able to use simply:
that sets Fill Color to 'ByBlock'.

Sorry, I should have clarified - it will simply switch the Text Fill on and off, the Text fill will use the fill colour as set in the Dim Style or by an Override. I think I misunderstood your intention  :-(

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Toggle background fill color on a Dimension
« Reply #7 on: August 13, 2012, 01:31:40 PM »
To toggle the background fill on/off, you should be able to use simply:
that sets Fill Color to 'ByBlock'.

Sorry, I should have clarified -
No problem. :)

I can use the dimstyle setting and forget about programming for now. :)
TheSwamp.org  (serving the CAD community since 2003)

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Toggle background fill color on a Dimension
« Reply #8 on: August 13, 2012, 01:33:56 PM »
I don't see anyway of knowing when the dim has fill color set to 'background'.

It would appear that the Dimension Style Override for a Background Text Fill Colour is Override Code 69:

Code - Auto/Visual Lisp: [Select]
  1.   (
  2.     (0 . "DIMENSION")
  3.     (5 . "52F")
  4.  
  5.  ... < irrelevant group codes removed > ...
  6.  
  7.     (100 . "AcDbRotatedDimension")
  8.     (-3
  9.       (
  10.         "ACAD"
  11.         (1000 . "DSTYLE")
  12.         (1002 . "{")
  13.         (1070 . 69) ;; <--------------- Background Text Fill Colour
  14.         (1070 . 1)  ;; <--------------- Background Text Fill Colour
  15.         (1002 . "}")
  16.       )
  17.     )
  18.   )

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Toggle background fill color on a Dimension
« Reply #9 on: August 13, 2012, 01:37:04 PM »
Thank ya sir! :)
TheSwamp.org  (serving the CAD community since 2003)

kruuger

  • Swamp Rat
  • Posts: 637
Re: Toggle background fill color on a Dimension
« Reply #10 on: August 13, 2012, 03:34:54 PM »
To toggle the background fill on/off, you should be able to use simply:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:dimmask ( / en ob )
  2.     (if
  3.         (and
  4.             (setq en (car (entsel "\nSelect Dimension: ")))
  5.             (wcmatch (cdr (assoc 0 (entget en))) "*DIMENSION")
  6.             (setq ob (vlax-ename->vla-object en))
  7.         )
  8.         (vlax-put ob 'textfill (~ (vlax-get ob 'textfill)))
  9.     )
  10.     (princ)
  11. )
this one work well <=2009. from 2010 autodesk messed up  :realmad: textfill  :x

i'm using this. little bit crappy but works for 90% cases:
Code - Auto/Visual Lisp: [Select]
  1. (Defun C:BMM (/ lst object SC STYL)
  2.   (setq lst (entsel "\nSelect dimension object: "))
  3.   (setq object (car lst))
  4.   (setq object (vlax-ename->vla-object object))
  5.   (if (wcmatch (vla-get-objectname object) "AcDb*Dimension")
  6.     (progn
  7.       (setq STYL (vla-get-StyleName object))
  8.       (command ".dimstyle" "r" STYL)
  9.       (setq SC (vla-get-ScaleFactor object))
  10.       (setvar "dimscale" SC)
  11.       (setvar "dimtfill" 1)
  12.       (command "DIM1" "UPDATE" lst "")
  13.       (command ".draworder" (car lst) "" "front")
  14.       (setvar "dimtfill" 0)
  15.     );progn
  16.   );if
  17. )
kruuger
« Last Edit: August 13, 2012, 03:40:04 PM by Mark »


rlxozzang

  • Guest
Re: Toggle background fill color on a Dimension
« Reply #12 on: August 16, 2012, 03:04:37 AM »
my routine is
Code: [Select]
(defun c:TextFill (/ ent)
(setq ent (nentsel));mtext,dimension
(if (= (vla-get-backgroundfill (vlax-ename->vla-object (car ent))) :vlax-false)
(progn
(vla-put-backgroundfill (vlax-ename->vla-object (car ent)) :vlax-true)
(entmod (subst (cons 45 1.1) (assoc 45 (entget (car ent))) (entget (car ent))))
)
(vla-put-backgroundfill (vlax-ename->vla-object (car ent)) :vlax-false)
)
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)
(princ)
)