See the top rated post in this thread. Click here

Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Adding toggle to Dim mask routine

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

    Default Re: Adding toggle to Dim mask routine

    How about this ... could you post a sample drawing exhibiting this behavior? Trying to match my drawings to your settings is a task I do not have the time to recreate. This problem is not even something I deal with since I have rarely set a background mask on my dimensions. I and others can then attempt to find a solution to your problem.

    The code I posted toggled the ActiveX property of the dimension. It did not change colors of the background mask. AutoCAD may have made those changes as a result of the toggle, but the code I posted does not handle that.
    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

  2. #12
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    1

    Default Re: Adding toggle to Dim mask routine

    Quote Originally Posted by Opie View Post
    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)
          )
        )
      )
    )
    With Fill color set to Background toggling it sets the Fill color to Byblock.
    This seems to work for any Fill color:
    Code:
    (defun c:DimMask (/ ss i ent elist pnt txtlist txtent ob1)
      (vl-load-com)
      (if (setq ss (ssget '((0 . "Dimension"))))
        (repeat (setq i (sslength ss))
          (setq ent (ssname ss (setq i (1- i)))
    	        elist (entget ent '("ACAD" ))
    	        pnt	(cdr (assoc 11 elist))
    	        txtlist	(entget (car (nentselp "\ntrySelect Entity: " pnt))(list "*"))
    	        txtent (cdr(assoc -1 txtlist))
    	        ob1 (vlax-ename->vla-object txtent)
          )
    	  (vlax-put ob1 'backgroundfill (~ (vlax-get ob1 'backgroundfill)))
    	  (vl-cmdf ".draworder" ss "" "front")
    	); repeat
      ); if
      (princ)
    );defun
    It modifies the MTEXT object inside the dimension.
    Last edited by Tom Beauford; 2018-06-28 at 03:59 PM. Reason: Replaced command with vl-cmdf & added (vl-load-com) for those who don't have it in their acaddoc.lsp file.

  3. #13
    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 Tom
    I tried your code and got an error message. On the second try, I added the (vl-load-com) code to the routine but I got the same error message. The error message was:

    Command: DIMMASK

    Select objects: Specify opposite corner: 1 found

    Select objects:
    ** Error: bad argument type: lentityp nil **
    Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
    Converting (command) calls to (command-s) is recommended.

    Thanks.

    Manuel

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

    Default Re: Adding toggle to Dim mask routine

    Try zooming out a bit and try the command again. It seems to be dependent on the aperture of your cursor's pick box. The code allows the user to pick any element of the dimension, then it retrieves the insertion point of the text. From that insertion point, it selects the nested entity (the text) of the dimension. Zooming out should help.
    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

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

    Default Re: Adding toggle to Dim mask routine

    Quote Originally Posted by cadconcepts View Post
    Hi Tom
    I tried your code and got an error message. On the second try, I added the (vl-load-com) code to the routine but I got the same error message. The error message was:

    ** Error: bad argument type: lentityp nil **
    Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
    Converting (command) calls to (command-s) is recommended.

    Thanks.

    Manuel
    Try changing line
    Code:
    (command ".draworder" ss "" "front")
    to
    Code:
    (command-s ".draworder" ss "" "front")
    or
    Code:
    (vl-cmdf ".draworder" ss "" "front")
    The lisp function command-s is newer, but all three of these work for me on Civil 3D 2018. I'll modify the code to use vl-cmdf since it should work for most everyone.

    What version are you using?

  6. #16
    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 Tom
    I was testing the routine in AutoCAD 2019 and it was not working properly even with the code changes you recommended. I tried the routine in 2018 and it works just fine. Clearly this a bug or they have changed something since then. I am uploading a sample drawing in 2019 for your review. Thanks for the help.

    Manuel
    Attached Files Attached Files

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

    Default Re: Adding toggle to Dim mask routine

    Quote Originally Posted by cadconcepts View Post
    Hi Tom
    I was testing the routine in AutoCAD 2019 and it was not working properly even with the code changes you recommended. I tried the routine in 2018 and it works just fine. Clearly this a bug or they have changed something since then. I am uploading a sample drawing in 2019 for your review. Thanks for the help.

    Manuel
    Haven't installed 2019 yet, maybe someone else will test it for us. 2019 files open in 2018 and in my 2018 version the routine works fine. Now I'm a little worried about upgrading to 2019, I use a lot of lisp routines.

  8. #18
    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 Tom
    Opie brought up a good point which I had not picked up on before. I did a quick test and I found that your routine will bomb out if you are zoomed up to close to the dimension string. I found a few instance even if the whole dimension string is fully in the screen it will not work. I have to zoom out further to get it to work. Any thoughts? Thanks.
    Manuel

Page 2 of 2 FirstFirst 12

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
  •