+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Full Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Nov 2017
    Posts
    72

    Default adding text to existing text

    Registered forum members do not see this ad.

    ok so i found this lisp routine to be able to add text at the prefix or suffix of an existing text. it is also adding in a space between the new text and the old text.

    (example of old text 3"GW - new text from this lisp (E) 3"GW)

    is there a way to be able to remove that space that it is adding there?

    Code:
    (defun c:PST (/ PreSuf Str ent Cstr)
      (vl-load-com)
      (initget "PS")
      (setq PreSuf (getkword "\nChoose [Prefix/Suffix]  <Prefix>: "))
      (if (not PreSuf)
        (setq PreSuf "S")
      )
      (while (not str)
        (setq str (getstring T "\nEnter String: "))
        (cond ((and (eq str "")
      (princ "Null Input Try again")
      (setq str nil)
        )
       )
        )
      )
      (while (and (setq ent (car (nentsel "\nSelect Text/Attribute: ")))
           (member (cdr (assoc 0 (entget ent)))
            '("TEXT" "MTEXT" "ATTRIB")
           )
      )
        (setq ent  (vlax-ename->vla-object ent)
       Cstr (vla-get-textstring ent)
        )
        (vla-put-textstring
          ent
          (if (eq PreSuf "S")
     (strcat Cstr " " str)
     (strcat str " " Cstr)
          )
        )
      )(princ)
    )

  2. #2
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    838

    Default

    Code:
    (if (eq presuf "S")
      (strcat cstr " " str)
      (strcat str " " cstr)
    )

  3. #3
    Full Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Nov 2017
    Posts
    72

    Default

    amazing! thank you for pointing this out!! this site is amazing

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,539

    Default

    You may also find this post helpful.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  5. #5
    Full Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Nov 2017
    Posts
    72

    Default

    Quote Originally Posted by Lee Mac View Post
    You may also find this post helpful.
    Mr. Mac! thank you for this. i have to admit that your website is always the first place that i look for something that might be useful.

    that is one of the first few that i read and in the beginning i was... well to be honest lost and overwhelmed. but going back thru this a few times this is for sure helping.

    on a different note: do you happen to have or know if there is something to load into Autocad that will have a time start when ever you open a drawing? if you have something on your site just say that and i will look for it. (i have found a lot of cool tools there) but all in all THANK YOU!

  6. #6
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,515

    Default

    This may be usefull opening and closing dwg's.
    Attached Files
    A man who never made mistakes never made anything

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,539

    Default

    Quote Originally Posted by dnovember99 View Post
    Mr. Mac! thank you for this. i have to admit that your website is always the first place that i look for something that might be useful.

    that is one of the first few that i read and in the beginning i was... well to be honest lost and overwhelmed. but going back thru this a few times this is for sure helping.
    You're most welcome - I hope it'll be of some help.

    Quote Originally Posted by dnovember99 View Post
    on a different note: do you happen to have or know if there is something to load into Autocad that will have a time start when ever you open a drawing? if you have something on your site just say that and i will look for it. (i have found a lot of cool tools there) but all in all THANK YOU!
    I'm not sure what you mean by:

    ...something to load into Autocad that will have a time start when ever you open a drawing?
    Do you mean something equivalent to a Scheduled Task for programs in AutoCAD?
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  8. #8
    Full Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Nov 2017
    Posts
    72

    Default

    Quote Originally Posted by Lee Mac View Post
    You're most welcome - I hope it'll be of some help.



    I'm not sure what you mean by:

    Do you mean something equivalent to a Scheduled Task for programs in AutoCAD?
    i am not sure what that really is to be honest. but i was thinking of something like a time counter. and the reason for this would be that my company harps on us so much over the time that is spent on each project.

    to have when you open up an autocad file if there is a job number in the name of the file it would log it to a file just for that job number or for any cad file from the source folder so you can log your time a little more closely.being that each of out projects has a different job number, have it log time autocad was spent open with a drawing name, I.E. job number that is on the file.

    this could be totally far fetched but i was thinking about this the other day. i have a logitec G13 keyboard. i attached a screen shot of the stopwatch that is on that. i can use it but it is hard to remember to hit stop and go each time. windows 10 also has one on there, just think it would be really cool to have one for autocad. that could log your time spent on a job.
    Attached Images

  9. #9
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,449

    Default

    As a generic pref/suff function I always liked this approach:
    Code:
    (defun pstxt ( p txt s )
      (strcat (cond (p)("")) txt (cond (s)("")))
    )

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,539

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Grrr View Post
    As a generic pref/suff function I always liked this approach:
    Code:
    (defun pstxt ( p txt s )
      (strcat (cond (p)("")) txt (cond (s)("")))
    )
    IMO, calling pstxt with an empty string is more useful than supplying nil - consider that getstring returns an empty string on null input.

    But a separate function definition for a single string concatenation seems unnecessary: (pstxt p txt s) is no different to (strcat p txt s)

    @dnovember99, your posts regarding a drawing time-logging system are off-topic for this thread and ideally belong in a new thread - a Moderator can move them for you.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

Similar Threads

  1. Add symbols to existing text lisp
    By structo in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 22nd Dec 2016, 07:06 am
  2. How to add attribute text an existing block
    By RRS1987 in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 14th Feb 2015, 04:01 pm
  3. Routine to add modified text below existing text (copy/replace?)...
    By lamensterms in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 17th Jun 2011, 08:44 am
  4. 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
  5. Change Existing Text to Number?
    By AQucsaiJr in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 14th Jul 2009, 12:30 pm

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