Author Topic: How do I override a dimension?  (Read 2495 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
How do I override a dimension?
« on: March 09, 2017, 05:20:21 PM »
I am trying to suppress or turn off a dimension extension line.
These are the dimstyles but I cannot find the entity. I hope I have the terminology correct. Or perhaps I don't know how to override a dimension correctly.

Code: [Select]
dxf 75 dimse1
dxf 76 dimse2

My basic script
Code: [Select]
     
(setq en (car(entsel)))
(setq ed (entget en))
(setq ed (subst (cons 75 1) (assoc 75 ed) ed))
(entmod ed)

BKT

  • Newt
  • Posts: 27
Re: How do I override a dimension?
« Reply #1 on: March 10, 2017, 10:36:29 AM »

dubb

  • Swamp Rat
  • Posts: 1105
Re: How do I override a dimension?
« Reply #2 on: March 10, 2017, 11:40:48 AM »
That works, however I was wondering if we can accomplish it with entmod.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: How do I override a dimension?
« Reply #3 on: March 10, 2017, 12:35:36 PM »
An example:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:dimextsuppress ( / a i s x )
  2.     (initget "First Second Both")
  3.     (setq a (cond ((getkword "\nExtension line to suppress [First/Second/Both] <Both>: ")) ("Both")))
  4.     (if (setq s (ssget "_:L" '((0 . "*DIMENSION"))))
  5.         (progn
  6.             (regapp "ACAD")
  7.             (setq x
  8.                 (list
  9.                     (list -3
  10.                         (append
  11.                            '("ACAD" (1000 . "DSTYLE") (1002 . "{"))
  12.                             (if (member a '("First"  "Both")) '((1070 . 75) (1070 . 1)))
  13.                             (if (member a '("Second" "Both")) '((1070 . 76) (1070 . 1)))
  14.                            '((1002 . "}"))
  15.                         )
  16.                     )
  17.                 )
  18.             )  
  19.             (repeat (setq i (sslength s))
  20.                 (entmod (append (entget (ssname s (setq i (1- i)))) x))
  21.             )
  22.         )
  23.     )
  24.     (princ)
  25. )

Note that this example will remove any existing overrides.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: How do I override a dimension?
« Reply #4 on: March 10, 2017, 12:41:44 PM »
Pre-empting your next question, here is a (potentially incomplete) reference for the dimension style override codes.

lamarn

  • Swamp Rat
  • Posts: 636
Re: How do I override a dimension?
« Reply #5 on: March 12, 2017, 06:29:53 PM »
Dear mr. Lee Mac. Amazing efficient stuff.
Could you point out what part is the 'make it 0' that makes DIMSE1 and DIMSE1 turn off.
Could use it to toggle. Kind regards Hans

@Dubb
Here is one of mine about the same thing..
Maybe helps a bit

https://www.theswamp.org/index.php?topic=51581.msg566568#msg566568

« Last Edit: March 12, 2017, 06:33:34 PM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

dubb

  • Swamp Rat
  • Posts: 1105
Re: How do I override a dimension?
« Reply #6 on: March 13, 2017, 11:23:29 AM »
Beautiful! Thanks Lee & lmarn.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: How do I override a dimension?
« Reply #7 on: March 13, 2017, 02:36:01 PM »
Dear mr. Lee Mac. Amazing efficient stuff.
Beautiful! Thanks Lee

Thank you  :-)

Could you point out what part is the 'make it 0' that makes DIMSE1 and DIMSE1 turn off.
Could use it to toggle.

Note that the sample program above is applying a dimension style override only to the selected dimensions and not an override to the active dimension style itself, therefore the program will not affect the values of the DIMSE1 & DIMSE2 system variables.

A toggle of this nature is possible but far more complex to implement, as the program would need to retrieve the dimension style override xdata, parse the xdata into pairs of system variable codes and associated values, test for the presence of 75 & 76 and toggle the associated values if present; however, if the codes corresponding to these system variables are not present, the program would also need to check whether the dimension style is already suppressing either extension line in order to determine the appropriate value to be added as a dimension style override (e.g. the dimension style may already be suppressing the first extension line, therefore to achieve a true toggle, the program would need to override this suppression).

lamarn

  • Swamp Rat
  • Posts: 636
Re: How do I override a dimension?
« Reply #8 on: March 13, 2017, 04:13:58 PM »
This 'ON' options works fine for me ..   :whistling:

Code: [Select]
(defun c:dimextsuppress ( / a i s x )
    (initget "First Second Both ON")
    (setq a (cond ((getkword "\nExtension line to suppress [First/Second/Both or ON] <Both>: ")) ("Both")))
    (if (setq s (ssget "_:L" '((0 . "*DIMENSION"))))
        (progn
            (regapp "ACAD")
            (setq x
                (list
                    (list -3
                        (append
                           '("ACAD" (1000 . "DSTYLE") (1002 . "{"))
                            (if (member a '("First"  "Both")) '((1070 . 75) (1070 . 1)))
                            (if (member a '("Second" "Both")) '((1070 . 76) (1070 . 1)))
                            (if (member a '("ON")) '((1070 . 76) (1070 . 0)))
                            (if (member a '("ON")) '((1070 . 76) (1070 . 0)))
                           '((1002 . "}"))
                        )
                    )
                )
            )   
            (repeat (setq i (sslength s))
                (entmod (append (entget (ssname s (setq i (1- i)))) x))
            )
        )
    )
    (princ)
)



Design is something you should do with both hands. My 2d hand , my 3d hand ..

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: How do I override a dimension?
« Reply #9 on: March 13, 2017, 06:35:32 PM »
I thought you wanted to toggle the current state?  :?

lamarn

  • Swamp Rat
  • Posts: 636
Re: How do I override a dimension?
« Reply #10 on: March 14, 2017, 02:06:49 AM »
Sorry, i didn't explain myself good nough. Just a option to turn ON/OFF is what i meant with toggle..
« Last Edit: March 14, 2017, 02:42:24 AM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

dubb

  • Swamp Rat
  • Posts: 1105
Re: How do I override a dimension?
« Reply #11 on: March 15, 2017, 03:36:28 PM »
Quote
A toggle of this nature is possible but far more complex to implement, as the program would need to retrieve the dimension style override xdata, parse the xdata into pairs of system variable codes and associated values, test for the presence of 75 & 76 and toggle the associated values if present; however, if the codes corresponding to these system variables are not present, the program would also need to check whether the dimension style is already suppressing either extension line in order to determine the appropriate value to be added as a dimension style override (e.g. the dimension style may already be suppressing the first extension line, therefore to achieve a true toggle, the program would need to override this suppression).

Thanks for this explanation. Apparently I am clueless when it comes to xdata. Will need to add that to my "To Learn" list.