Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31

Thread: Text Override in Dimension

  1. #21
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Text Override in Dimension

    What about something like this ...
    Dialog box idea by Mr gile ..

    Code:
    (defun c:Test (/ tmp file dcl_id name ss i vl)
      (vl-load-com)
      ;; create and open a temporay file
      ;; by gile  Modified by Tharwat to suit the needs of this routine
      (setq tmp  (vl-filename-mktemp "tmp.dcl")
            file (open tmp "w")
      )
      ;; write the DCL file
      (write-line
        "testDialog:dialog{
          label = \"Dimensiontext Test\";
          initial_focus = \"name\";
          :text{
            label = \"Enter Override Text:\";
          }
          :edit_box{
            key = \"name\";
            width = 32;
            allow_accept = true;
          }
          ok_cancel;
        }"
        file
      )
      ;; close the file
      (close file)
      ;; load and show the dialog
      (setq dcl_id (load_dialog tmp))
      (if (not (new_dialog "testDialog" dcl_id))
        (exit)
      )
      (action_tile
        "accept"
        "(setq name (get_tile \"name\")) (setq case (get_tile \"case\"))(done_dialog)"
      )
      (start_dialog)
      (unload_dialog dcl_id)
      ;; delete the file
      (vl-file-delete tmp)
      ;; show the result
      (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
        (repeat
          (setq i (sslength ss))
           (setq vl (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
           (vla-put-textoverride vl name)
        )
        (princ "\n No Dimensions found !! ...")
      )
      (princ)
    )
    Tharwat

  2. #22
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Text Override in Dimension

    Try pressing 'Cancel' on the dialog

  3. #23
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Text Override in Dimension

    Quote Originally Posted by Lee Mac View Post
    Try pressing 'Cancel' on the dialog
    Waww That would throw an active X server error , and even if I used your error sub-routine it won't interfere to stop that disaster .

    I tried to to include the dialog within the *and* function , but it's been giving me an error also .

    What's your suggestion ?

    Thanks

  4. #24
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Text Override in Dimension

    Quote Originally Posted by tharwat View Post
    I tried to to include the dialog within the *and* function , but it's been giving me an error also .

    What's your suggestion ?
    In my opinion, you need to have an understanding of the function of every part of the code before you can begin to modify it. Guessing without a proper understanding of what the code is doing is certain to tie you in knots.

    I will post an example in a bit.

  5. #25
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Text Override in Dimension

    A quick example:

    Code:
    (defun c:test ( / *error* e file i id over ss tmp )
    
      (defun *error* ( msg )
        (if (< 0 id) (setq id (unload_dialog id)))
        (if (and tmp (findfile tmp)) (vl-file-delete tmp))
        (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
            (princ (strcat "\n** Error: " msg " **")))
        (princ)
      )
      
      (cond
        ( (not (setq ss (ssget "_:L" '((0 . "*DIMENSION")))))
          (princ "\n*Cancel*")
        )
        (
          (not
            (and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w"))
              (progn
                (foreach x
                 '(
                    "test : dialog { label = \"Dimension Override\"; spacer;"
                    "  initial_focus = \"text\";"
                    "  :text { label = \"Enter Override Text:\"; }"
                    "  :edit_box { key = \"text\"; width = 32; allow_accept = true; }"
                    "  spacer; ok_cancel;"
                    "}"
                  )
                  (write-line x file)
                )
                (setq file (close file)) (< 0 (setq id (load_dialog tmp)))
              )
              (new_dialog "test" id)
            )
          )
          (princ "\n--> Error Loading Dialog.")
        )
        (t
          (setq over "")
          (action_tile "text" "(setq over $value)")
          (if (= 1 (start_dialog))
            (repeat (setq i (sslength ss))
              (setq e (entget (ssname ss (setq i (1- i)))))
              (entmod (subst (cons 1 over) (assoc 1 e) e))
            )
            (princ "\n*Cancel*")
          )
        )
      )
      (if (< 0 id) (setq id (unload_dialog id)))
      (if (and tmp (findfile tmp)) (vl-file-delete tmp))
      (princ)
    )

  6. #26
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Text Override in Dimension

    A very nice work in sequence Lee , thanks for your notes .
    What is the difference between these codes in your opinion ? Because I see you always prefer using *and* function which I sometimes have doubts about it .

    you used the following in the error trap sub-routine.

    Code:
        (if (and tmp (findfile tmp)) (vl-file-delete tmp))
    Is it wrong to make it this way .
    Code:
     (if tmp 
    (progn
    (findfile tmp)(vl-file-delete tmp)))
    Appreciated lot .

    Tharwat

  7. #27
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Text Override in Dimension

    I think you need to spend some time reading the help documentation on the 'AND' function to have a better understanding of its functionality.

    In my code:

    Code:
    (if ; If the following test expression returns a non-nil value
      (and 
        tmp            ; 'tmp' variable has a non-nil value 
        (findfile tmp) ; The file with filename tmp can be found
      )
      (vl-file-delete tmp) ; Then delete the file
    )
    In your modification, you now have a redundant expression, and the extra check for the existence of the file is no longer present:

    Code:
    (if tmp ; If 'tmp' variable has a non-nil value 
      (progn
        (findfile tmp) ; This is redundant since its result isn't used in any way
        (vl-file-delete tmp) ; delete the file
      )
    )

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

    Default Re: Text Override in Dimension

    'and' tests every item in order if it recieves a nil responce it stops and returns nil, otherwise returns T.

    'or' tests every item in order if it recieves a T responce it stops and returns T, otherwise returns nil. As an example I use it as an autoloader for lisp files, if the function name exists it stops and doesn't reload the routine: (or C:ContourAnnotate (load "ContourAnnotate.lsp"))

    Two of my favorite functions like 'progn' on steroids.

  9. #29
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Text Override in Dimension

    Fantastic observation, Tom...

    Notice that if you use (or) in combination with (if), syntax should be just opposite :
    (if (or c:test) () (load "test.lsp")), for when (or) check if c:test is T it stops returns T and continues to first condition witch is here () nothing, otherwise if c:test is nil it stops returns nil and because of that nil it processes else condition witch is here (load "test.lsp")

    (if (and c:test) () (load "test.lsp")) does the same as (or) variariant
    but it would be the different if you used :
    (and c:test (load "test.lsp")), then after first T (and) function wouldn't stop, it would continue and error would occur - twice loading, and if first is nil it stops returns nil and nothing would be continued with processing...

    but (not) is just opposite than (or) and (and) in combination with (if)... It checks single item and if it is T it stops and returns nil, otherwise if nil it stops and returns T...

    (if (not c:test) (load "test.lsp")) would work - here is else condition sufficient
    but
    (not c:test (load "test.lsp")) also wouldn't work - this would lead to error of too many arguments

    M.R.
    Last edited by marko_ribar; 2011-07-01 at 01:01 PM.

  10. #30
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Text Override in Dimension

    Rubik's Cube for LISP

    Legend: IF, AND (white), OR, REAL, STRING, INTEGER (yellow)



    LoL
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Add Pre-Filled Text Dropdowns to the Dimension Text Override Dialogue
    By Wish List System in forum Revit Structure - Wish List
    Replies: 1
    Last Post: 2016-10-12, 01:38 PM
  2. Dimension text override to wrap
    By jgratton in forum AutoCAD General
    Replies: 13
    Last Post: 2012-03-10, 11:50 AM
  3. Dimension Text override issues
    By irchrismm in forum AutoCAD General
    Replies: 7
    Last Post: 2008-06-03, 12:48 PM
  4. Dimension text override
    By Julesagain in forum Design Review - Wish List
    Replies: 0
    Last Post: 2007-10-03, 02:41 PM
  5. Dimension Text Override with Autolisp
    By CADdancer in forum AutoLISP
    Replies: 3
    Last Post: 2005-07-12, 05:33 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
  •