See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Adding toggle to Dim mask routine

  1. #1
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    1

    Default Adding toggle to Dim mask routine

    Hi All
    I have the following routine to toggle the dim mask on and off. Unfortunately, the routine is written in such a way that it doesn't check to see if the dimension string is already masked and do the opposite. If the dimension already has a mask I have to select it twice to turn off the mask. Any help in modifying this routine is greatly appreciated. Thanks.
    Manuel

    Code:
    (vl-load-com)
    (defun c:dm (/ ent entdata hnd i newentdata ss xdata)
      (if (setq ss (ssget "_:S+." '((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))
    	      )
    	  )
    	(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)
          (command ".draworder" ss "" "front")
        )
      )
      (princ)
    )

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    1

    Default Re: Adding toggle to Dim mask routine

    Are you sure?

    It works for me, exactly as you say it doesn't work.

    R.K. McSwain | CAD Panacea |

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Adding toggle to Dim mask routine

    Worked great for me as well, added to my CUI → Shortcut Menus → Dimension Objects Menu
    Put it under "Toggle Line Space Factor".
    Renamed the command DimMask and saved as DimMask.lsp
    Macro:
    Code:
    ^C^C^P(or C:DimMask (load "DimMask.lsp"));DimMask
    Thanks,
    Last edited by Tom Beauford; 2018-06-14 at 06:53 PM.

  4. #4
    Member
    Join Date
    2010-10
    Location
    Việt Nam
    Posts
    45
    Login to Give a bone
    0

    Default Re: Adding toggle to Dim mask routine

    No, it did not working if Dimension' Dimstyle already set Text Fill by Background

  5. #5
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Adding toggle to Dim mask routine

    Ketxu is correct. If the textfill is set to background it will not toggle it On and Off. It will turn it off on the second select. If the dimension starts with no fill, it works beautifully.Thanks.
    Manuel

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,103
    Login to Give a bone
    0

    Default Re: Adding toggle to Dim mask routine

    Quote Originally Posted by cadconcepts View Post
    Ketxu is correct. If the textfill is set to background it will not toggle it On and Off. It will turn it off on the second select. If the dimension starts with no fill, it works beautifully.Thanks.
    Manuel
    So you need to check the dimstyle to see if this is set within the style. If so, then toggle the background twice.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Adding toggle to Dim mask routine

    Opie
    The way the routine is currently written, assumes that no mask has been set for the selected dimension. However, if the dimension does have a text mask it will not toggle it off when selected using this routine. It apparently doesn't check to see if the dim text is already masked. It will work if you select the dimension twice. It is odd that once the dimension has been modified by this routine it works fine all of the time. Thanks.
    Manuel

  8. #8
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,103
    Login to Give a bone
    1

    Default Re: Adding toggle to Dim mask routine

    Would this work better? This checks the property of the object, which is assigned per object upon creation, instead of depending on the style definition.
    Code:
    (defun c:dm (/ ss hnd obj i)
      (vl-load-com)
      (if (setq ss (ssget "_:S+." '((0 . "Dimension"))))
        (repeat (setq i (sslength ss))
          (setq hnd	(ssname ss (setq i (1- i)))
    	    obj	(vlax-ename->vla-object hnd)
          )
          (if (= :vlax-true (vla-get-textfill obj))
    	(vla-put-textfill obj :vlax-false)
    	(vla-put-textfill obj :vlax-true)
          )
        )
      )
    )
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  9. #9
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    1

    Default Re: Adding toggle to Dim mask routine

    The reason is..... when you create a dimension using a style that includes the masking, it's done withOUT using Xdata (not sure how, have not investigated that yet).

    When you manually add masking to an existing dimension, the Xdata making this happen gets created.

    This lisp routine looks for the existence of the Xdata before taking any action.
    On a dimension created using a style that includes masking, the Xdata does not exist, so the routine simply adds the Xdata but sets the flag ON, instead of OFF.

    Need to find out how the masking is done via the style (and not via Xdata), and have the routine test for that also.


    EDIT: Looks like Opie went another route and solved it!
    R.K. McSwain | CAD Panacea |

  10. #10
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Adding toggle to Dim mask routine

    Hi Opie
    I tried your routine and it has the same problem as the one I previously posted. I think rkmcswain is correct that there is no Xdata created when a dimension is initially created. By default, my dimension style has a mask set to background color. The routine I posted does toggle between ON and Off while keeping the dimension mask color defined in the dimension style. Your routine does the same but it adds the dimension mask the same color as the layer the dimension is on which is inconsistent with the dimension style. It also has the same problem as the one posted, in that it assumes that the dimension has no mask from the onset and adds one, instead of turning it Off. I often find that small dimension will often fit well between the extension lines but the mask overlaps them making them look unfinished. In those cases, I turn the dim mask Off through the property settings. I was trying to speed up this process with a lisp routine. Thanks.
    Manuel
    Attached Images Attached Images

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 6
    Last Post: 2018-05-15, 11:18 AM
  2. toggle a view port during a lisp routine
    By cjharley1450642179 in forum AutoLISP
    Replies: 11
    Last Post: 2014-04-23, 05:49 PM
  3. Layer Freeze/Thaw toggle routine
    By jgardner.79905 in forum AutoLISP
    Replies: 5
    Last Post: 2010-02-01, 09:39 PM
  4. Toggle-Make-Background Mask and multi-selection
    By doggarn.70892 in forum AutoCAD Civil 3D - General
    Replies: 0
    Last Post: 2009-03-18, 02:29 PM
  5. Help with a Layer toggle routine
    By thomasf in forum AutoLISP
    Replies: 4
    Last Post: 2007-01-22, 02:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •