+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    1,051

    Default Dimension Text Override

    Registered forum members do not see this ad.

    My project tonight includes the following:

    Take an existing drawing with some dimensions. Have a LISP program do a text override on several of the dimensions.

    The challenge, I can't use an ssget or anything that involves the user selecting the dimensions to be edited. I know which dimensions I want to edit but have to avoid any user input.

    I have done a few searches, including here and found only limited information and that is only if you have the user select the dimensions they want to change. Is this impossible or is there a way to possibly identify the dimension's identification and then have the code add the text overrides accordingly?
    It's deja vu, all over again.

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,780

    Default

    Code:
    (ssget "_X" '((0 . "*DIMENSION")))
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    1,051

    Default

    Lee,

    I was looking at something like this earlier today in the Help screens. Is the _X the wildcard which grabs everything in the drawing, and then you create a list with just the dimensions. I am not sure I follow how to display the list. And I need to narrow it down to just two or three of the dozen or so dimensions that are in this drawing. Can you elaborate a little more on how this works?

    I just found another source on this which gave the syntax like this:

    Code:
    (ssget "_X" '((0 . "DIMENSION")))
    I'm not sure how this assigns a variable which I can use though. The only display I get back when I run this is:

    <Selection set: 218>

    I'm thinking that in order to narrow this down to just the dims I need I may have to manually select them and identify which part of the database they are. I'm still green on this but each object has a unique number in the database which shouldn't change from one day to the next. If I can narrow these down then I could run something like entmake on the dimension objects and do the text override or would command dimedit be even simpler?

    I guess also I could add a couple of new layers and place each dimension I want to change in it's own layer. That would filter things down. The trouble is that there will eventually be scores of drawings to do this for and I was hoping for a routine which would be a one size fit all....!

    So how's that "Cancer Cure" coming along....? Gotta be easier than this you'd think.
    Last edited by Bill Tillman; 11th Jan 2012 at 12:54 am.
    It's deja vu, all over again.

  4. #4
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    1,051

    Default

    I think I have a little something started here:

    Code:
    (defun c:testme ()
      (setq scs (ssget "_X" '((0 . "DIMENSION"))))
      (setq ct 0)
      (while (< a (sslength scs))
        (setq en (ssname scs ct))
        (setq ed (entget en))
        (setq dt (cdr (assoc 1 ed)))
        (setq ct (1+ ct))
      );while
    );defun
    But I'm not really sure what will come next.....because I'm thinking and it makes my head hurt! With this I've found there are 17 dimensions in the file and I only want to do a text override on 5 of them.

    With this I've been able to identify the <Entity name:> 7ffffb0a970

    So my question is does this number always remain the same or does it change each time the drawing is accessed. There may be additions made to this drawing from time to time but that will be rare. So if this number remains the same on any given day, no matter who runs it on what machine, I could theoritically identify these numbers and use them in my attempt to change the text override on only the 5 dimensions I'm interested in. Correct???

    It looks like if I do an entmake on DXF code 1 for the dimensions I can identify... I will have it.

    CORRECTION: Is it the Handle field #5 which is the unique identifier which will never change about this entity that I can target on?
    Last edited by Bill Tillman; 11th Jan 2012 at 02:30 am.
    It's deja vu, all over again.

  5. #5
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    1,051

    Default

    OK, if it's the Handle field that I can target in on, and that looks like it, how could I go about injecting a text override into DXF code #1 into the existing Entity? I don't want to create a new dimension, I would like to just use this one. And then the question becomes, will changing this Entity's properties like this change something like it's unique identifier. If this unique identifier doesn't remain static for the life of the drawing, this will not be the ticket I'm looking for.
    It's deja vu, all over again.

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,780

    Default

    Bill,

    I recommend you add more filters to the ssget filter list to filter the set of Dimensions that is retrieved by the ssget function.

    To answer your other questions, the entity handle is persistent between drawing sessions, the entity name is not.

    For example, if you wanted to filter only Rotated Dimensions:

    Code:
    (ssget "_X" '((0 . "DIMENSION") (-4 . "<OR") (70 . 32) (70 . 64) (70 . 128) (-4 . "OR>")))
    Or perhaps filter Dimensions based on an existing Text Override:

    Code:
    (ssget "_X" '((0 . "DIMENSION") (1 . "*?*")))
    Will collect all Dimensions with a Text Override.

    I strongly suggest you read the Visual LISP Developer Guide on Selection Set handling, section:

    Code:
    +- AutoLISP Developer's Guide
    |
    +--+- Using the AutoLISP Language
       |
       +--+- Using AutoLISP to Manipulate AutoCAD Objects
          |
          +--+- Selection Set Handling
    As for adding a Text Override, consider this example:

    Code:
    (defun c:test ( / e i s )
        (if (setq s (ssget "_:L" '((0 . "*DIMENSION"))))
            (repeat (setq i (sslength s))
                (setq e (entget (ssname s (setq i (1- i)))))
                (entmod (subst (cons 1 "Lee <> Mac") (assoc 1 e) e))
            )
        )
        (princ)
    )
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #7
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    1,051

    Default

    Thanks. I have been reading all night and most of this morning that very book. And again the process just takes time. I am understanding more about this but when I tried some of the things I came up with there appears to still be something I'm missing.

    I have identified the 5 dimensions I need to add the test override to and would like to come up with a short code which would allow me to select one of them and then it print the handle next to it. Once I have the handle I think I have the information needed so I can prepare the larger program to do the text override using these handles. But the examples I'm reading about all show how to use ssget or entlast which gives me entities I don't need in the list. I tried this:

    Code:
    (defun C:PRINTDXF ()
      (setq ent (entlast))   ; Set ent to last entity.
      (setq entl (entget ent))  ; Set entl to association list of last entity.
      (setq ct 0)    ; Set ct (a counter) to 0.
      (textpage)    ; Switch to the text screen.
      (princ "\nentget of last entity:")
      (repeat (length entl)   ; Repeat for number of members in list:
        (print (nth ct entl))  ; Print a newline, then each list member.
        (setq ct (1+ ct))   ; Increments the counter by one.
      )
      (princ)    ; Exit quietly.
    )
    and it worked well for the last entity. But when I tried to substitute (ssget) for entlast, it got into the loop and then crashed with and error about the wrong lintp of somekind. I'm really stuck right now as the location I'm at has no internet access unless I drag my whole setup down to the local Starbucks or McDonalds. This is supposed to be fixed for me but the IT guys are too busy to mess with the new guy right now. BTW - the eventual text override will be different for each of the 5 dimensions which is why I need to have the Handle for each of them separately.

    Many thanks. I know I'm a real pest and I do appreciate your advice.
    It's deja vu, all over again.

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,780

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Bill Tillman View Post
    Thanks. I have been reading all night and most of this morning that very book.
    Book? To clarify, by 'Visual LISP Developer Guide' I am referring to that section in the VLIDE Help Files.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. Fraction Format With Dimension Text Override
    By Bill Tillman in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 10
    Last Post: 4th Jan 2012, 05:47 pm
  2. Adding additional text to Dimension Text Override
    By RoguePiper in forum AutoLISP, Visual LISP & DCL
    Replies: 25
    Last Post: 4th Aug 2010, 07:17 pm
  3. Dimension Lisp that promts a text override.
    By MikeP in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 28th Jan 2009, 05:11 pm
  4. Copy dimension to text override
    By MikeT in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 26th Jan 2009, 10:27 am
  5. Override dimension
    By mdbdesign in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 13th Mar 2007, 03:14 am

Bookmarks

Posting Permissions

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