+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: Counter texts

  1. #1
    Junior Member RMateus's Avatar
    Using
    Map 3D 2011
    Join Date
    May 2012
    Posts
    15

    Default Counter texts

    Registered forum members do not see this ad.

    Dear friends,
    I would like to learn how can I count the number of texts (strings) in a drawing using autolisp?
    Best regards.

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,725

    Default

    Do you want to also filter them by a criteria? I mean: color, layer, content...
    To count all text entities:
    Code:
    (if (setq ssText (ssget "_X" '((0 . "TEXT"))))
     (alert (strcat "This drawing contains " (itoa (sslength ssText)) " text entities."))
    )
    This will include mtext in selection:
    Code:
    (if (setq ssText (ssget "_X" '((0 . "*TEXT"))))
     (alert (strcat "This drawing contains " (itoa (sslength ssText)) " text/mtext entities."))
    )
    Last edited by MSasu; 4th May 2012 at 06:31 pm. Reason: Fixed code example
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    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,605
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  4. #4
    Junior Member RMateus's Avatar
    Using
    Map 3D 2011
    Join Date
    May 2012
    Posts
    15

    Default

    Thanks for the quick response.
    I must have done something stupid.
    The AutoCAD gives an error "error: bad SSGET list"
    What is wrong with this code?
    Code:
    (defun c:ntxt ()
          (if (setq ssText (ssget "_X" '((0 . "*TEXT"))))   (alert "This drawing contains " (strcat (itoa (sslength ssText)) " text/mtext entities."))
      )
      )

  5. #5
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and Electrical.
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    3,458

    Default

    Code:
    (alert (strcat "This drawing contains " (itoa (sslength ssText)) " text/mtext entities.")
    Besides that , localize variables ..

    Code:
    (defun c:ntxt (/ ssText)
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  6. #6
    Junior Member RMateus's Avatar
    Using
    Map 3D 2011
    Join Date
    May 2012
    Posts
    15

    Default

    Thanks Lee.
    It's really good, but what I wanted to learn, is how build code as you and these are small steps that help me understand how this works.

    I hope don't bother you with same stupid questions in future.
    Best regards.

  7. #7
    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,605

    Default

    Quote Originally Posted by RMateus View Post
    Thanks Lee.
    It's really good, but what I wanted to learn, is how build code as you and these are small steps that help me understand how this works.
    Not a problem, I admire your willingness to learn.

    Quote Originally Posted by RMateus View Post
    I hope don't bother you with same stupid questions in future.
    Ask as many questions as you need for your understanding!
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  8. #8
    Junior Member RMateus's Avatar
    Using
    Map 3D 2011
    Join Date
    May 2012
    Posts
    15

    Default

    Ok.
    Thank you.

  9. #9
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,725

    Default

    @RMateus: I edited the counting report after pasted the code and thus the error. I have fixed my example now. Sorry for inconvenience!
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  10. #10
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Feb 2014
    Posts
    2

    Default

    Registered forum members do not see this ad.

    Dear Friends, I will like to download a lisp routine of a command that provides me the same functions of tcount instead of counting number counts in alphabetical order

Similar Threads

  1. Block Counter ?
    By TimZilla in forum AutoCAD General
    Replies: 3
    Last Post: 27th Apr 2010, 02:59 pm
  2. Created Counter
    By MMS in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 19th May 2008, 08:52 am
  3. circular counter
    By explorer in forum AutoCAD Beginners' Area
    Replies: 12
    Last Post: 31st Jul 2007, 04:25 pm
  4. Text Counter?
    By CADken in forum AutoCAD Drawing Management & Output
    Replies: 18
    Last Post: 25th Jul 2007, 09:30 pm
  5. Counter box
    By BIGAL in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 26th Apr 2006, 06:51 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