+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
  1. #1
    Full Member
    Discipline
    Electrical
    Using
    AutoCAD 2018
    Join Date
    Jan 2018
    Posts
    34

    Default Lisp for copy text...variations on the theme

    Registered forum members do not see this ad.

    Hello, in my work (unfortunately) I spend a lot (too much) of time copying texts between blocks...Fortunately, however, I found some lisps that speed up this operation!
    But I could not find alternatives that I would need in two particular situations:

    Situation 1 (very important for me): cumulative copy in one destination.
    For example A,B,C, D1, 23, Z = ABCD123Z in the destination

    Situation 2 (not very important but reccurent); single paste and return to copy.
    The lisp I use allows, once copied the text, to paste it many times, but usually I have to paste it once, and once done it would be much more practical have already ready the copy phase...

    have you ever seen something similar?

    Thank you in advance

  2. #2
    Full Member
    Discipline
    Electrical
    Using
    AutoCAD 2018
    Join Date
    Jan 2018
    Posts
    34

    Default

    Hi, I add to the topic a further feature that I could not find: starting from the fact that in the windows clipboard I put text I want to transcribe in autocad (in a single line text, multiline text or attribute), have you ever create a lisp to paste directly from the clipboard to the autocad's text object by click over?
    Greetings

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

    Default

    Double click the text Ctrl+a Ctrl+v
    A man who never made mistakes never made anything

  4. #4
    Full Member
    Discipline
    Electrical
    Using
    AutoCAD 2018
    Join Date
    Jan 2018
    Posts
    34

    Default

    he he...think that I use a gaming mouse and "ctrl+a" and "ctrl+v" are stored on special buttons so the operation is already very fast (I do not even have to take my hands off the mouse)...but not comparable with the speed obtained with a specific lisp...
    I would not look like a lazy man, but I am very happy when I can shorten a single operation that I do repeatedly!
    Hi!

  5. #5
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,013

    Default

    ok , just some lunch copy & paste :


    Code:
    (defun c:tst ( / p1 p2 ents)
      (while (and (setq p1 (getpoint "\n1st corner : ")) (setq p2 (getcorner p1 "\n2nd corner : "))
           (setq ents (sfs p1 p2))(setq ents (el_sort ents p1 p2)))
        (alert (apply 'strcat (vl-remove-if 'void (mapcar '(lambda (x / s)(cdr (assoc 1 (entget x)))) ents)))))
      (princ)
    )
    (defun inside_amy (ent p1 p2 / ip )
      (if (and (>= (car (setq ip (getip ent)))  (min (car p1)(car p2)))   (<= (car ip)  (max (car p1)(car p2)))
        (>= (cadr ip) (min (cadr p1)(cadr p2))) (<= (cadr ip) (max (cadr p1)(cadr p2)))) t nil))
    ; get insertionpoint
    (defun getip (e) (list (cadr (assoc 10 (entget e)))(caddr (assoc 10 (entget e)))))
    ; black hole with hawking radiation
    (defun void (x) (if (member x (list "" " " "  " "   " "    " "     " nil '())) t nil))
    ; scan for string
    (defun sfs ( %p1 %p2 / i ss el e et)
     (if (setq i 0 ss (ssget "c" %p1 %p2))
       (while (setq e (ssname ss i))
        (setq et (cdr (assoc 0 (entget e))) i (1+ i))
        (cond ((member et '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))(setq el (cons e el)))
       ((= et "INSERT") (mapcar '(lambda (x) (if (inside_amy x %p1 %p2)(setq el (cons x el))))(get-bents e)))))) el)
    ; get block entities
    (defun get-bents ( b / obj e lst)
      ;attrib
      (setq obj (vlax-ename->vla-object b))
      (if (eq :vlax-true (vla-get-HasAttributes obj)) (setq lst (mapcar 'vlax-vla-object->ename (vlax-invoke obj 'GetAttributes))))
      ;text , disable if only attributes are needed
      (setq e (tblobjname "block" (vla-Get-EffectiveName obj)))
      (while (setq e (entnext e)) (if (member (cdr (assoc 0 (entget e))) (list "TEXT" "ATTDEF")) (setq lst (cons e lst)))) lst)
    ; mode = nil : sort list with entities from y-max to y-min , mode = t : sort from y-min to y-max
    (defun sort_ents_y ( %ents mode)
      (vl-sort %ents '(lambda (e1 e2) ((if mode > <) (caddr (assoc 10 (entget e1))) (caddr (assoc 10 (entget e2)))))))
    ; mode = nil : sort list with entities from x-max to x-min , mode = t : sort from x-min to x-max
    (defun sort_ents_x ( %ents mode)
      (vl-sort %ents '(lambda (e1 e2) ((if mode > <) (cadr (assoc 10 (entget e1))) (cadr (assoc 10 (entget e2)))))))
    (defun el_sort ( %el %p1 %p2 / dX dY)
      (setq dX (- (car %p2) (car %p1)) dY (- (cadr %p2) (cadr %p1)))
      (if (> (abs dX) (abs dY))(if (> dX 0)(sort_ents_x %el nil)(sort_ents_x %el t)) (if (> dY 0)(sort_ents_y %el nil)(sort_ents_y %el t)))
    )

    ps direction of selection matters...


    gr. Rlx

  6. #6
    Full Member
    Discipline
    Electrical
    Using
    AutoCAD 2018
    Join Date
    Jan 2018
    Posts
    34

    Default

    Thank you rlx, try your lisp but I don't understand how it works...
    In the meantime I found this topic in your huge forum
    http://www.cadtutor.net/forum/showth...pboard-by-lisp

    "Demopaste" does exactly what I need, but it works only with single line text...what a pity

  7. #7
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,013

    Default

    Quote Originally Posted by itacad View Post
    Thank you rlx, try your lisp but I don't understand how it works...
    In the meantime I found this topic in your huge forum
    http://www.cadtutor.net/forum/showth...pboard-by-lisp

    "Demopaste" does exactly what I need, but it works only with single line text...what a pity
    Routine was just a demo to combine some texts. In place for the alert function you would place an entsel to select entity to place the combined strings in. Most of the functions you seek can be done with my VT routine , like row(s) to row(s) etc.




    Gr. Rlx
    Attached Images
    Last edited by rlx; 16th Mar 2018 at 09:31 am.

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

    Default

    Sounds like a 1 size fits all, using a ssget you could pick 1 or multiple objects, repeating as required. For the 1 at a time just look at it is it text or mtext and make new string, for a multiple again look at it but take into account say Y co-ord and sort before adding together.

    Very much like the RLX code a number of defuns needed the multi would be done by the fact that the ssget has only 1 item so its a single go to next pick object.

    Not a 5 minute job.
    A man who never made mistakes never made anything

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

    Default

    If you pay peanuts then you get monkeys coding.

    Code:
    (defun c:addtxt ( / obj ans)
    (while (setq obj (vlax-ename->vla-object (car (entsel "\nPick text object"))))
    (setq ans (strcat ans (vla-get-textstring obj)))
    )
    
    (princ ans)
    
    )
    A man who never made mistakes never made anything

  10. #10
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,013

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by BIGAL View Post
    If you pay peanuts then you get monkeys coding.

    hahaha


    The way I see it , and this has been described in many different ways, if you want to help somebody with their homework , you don't help them by doing their homework for them.


    gr. Rlx

Similar Threads

  1. Replies: 7
    Last Post: 13th Jan 2016, 06:23 am
  2. LISP to copy Polylines with certain points fixed (kind of strech-copy)
    By heschr in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 29th Jan 2014, 03:51 pm
  3. Dynamic Block Variations!!!!!?
    By KnoJa31 in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 30th Sep 2008, 05:02 pm
  4. Variations of AutoCAD
    By kezflake in forum AutoCAD General
    Replies: 10
    Last Post: 28th Jun 2008, 12:36 pm
  5. Lisp to copy/change text
    By Absntmind in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 5th Oct 2007, 12:29 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