Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Editing multiple single-line text entities

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
robyn.henke
1463 Views, 7 Replies

Editing multiple single-line text entities

First off:  My company has used single-line text for schedules forever.  No one is interested in using AutoCAD's tables or using Excel to create those schedules.  I rather, I could say, the bosses are not interested in paying me to update those schedules.  Which is fine, most of the people here have been using these schedules for at least 10 years.  We know it works, we know it's limitations, we feel comfortable using it.  So, please don't suggest we do anything different than what we do.

 

That being said, my problem has started just since we upgraded to 2015.  We have a lisp file that edits multiple single-line text entities and it worked great.  I don't know where this lisp came from, it was in place when I started at the beginning of 1999.

 

You could zip through a schedule pretty fast by selecting all the lines of text you wanted to edit and just type and hit enter.  It was awesome!  Recently I noticed that there was a "delay" and the first keystroke after hitting enter was not being incorporated.  Upon further investigation, I noticed this happening after selecting the lines to be edited:

 

Command: ME

Select objects: 1 found

Select objects: 1 found, 2 total

Select objects: 1 found, 3 total

Select objects: 1 found, 4 total

Select objects: 1 found, 5 total

Select objects: 1 found, 6 total

Select objects: 1 found, 7 total

Select objects: 1 found, 8 total

Select objects: 1 found, 9 total

Select objects:
Unknown command "ME".  Press F1 for help.
Unknown command "ME".  Press F1 for help.
Unknown command "ME".  Press F1 for help.
Unknown command "ME".  Press F1 for help.
Unknown command "ME".  Press F1 for help.
Unknown command "ME".  Press F1 for help.
Unknown command "ME".  Press F1 for help.
Unknown command "ME".  Press F1 for help.
Unknown command "ME".  Press F1 for help.

Command:

 

This is the lisp file:

 

(defun C:ME (/ A B C D E F G H J K L M )
(graphscr)
(setvar "BLIPMODE" 0)
(SETVAR "CMDECHO" 0)
(SETVAR "HIGHLIGHT" 1)
(PROMPT "\nMULTI-EDIT IS LOADED ...  ")
(SETQ A (SSGET) B (SSLENGTH A) C 0)
(WHILE (< C B) (SETQ D (SSNAME A C) E (ENTGET D))
(SETQ F (CAR E))
(SETQ G (CDR E))
(SETQ H (CAR G))
(SETQ J (CDR H))
(SETQ K "TEXT")
(SETQ L "INSERT")
(SETQ M "DIMENSION")
(IF (= J K) (COMMAND ".TEXTEDIT" D ""))
(IF (= J L) (COMMAND ".DDATTE" D ))
(IF (= J M) (PROMPT
"\n YOU PICKED A DIMENSION, I ONLY DO TEXT OR ATTRIBUTES ..."
))(TERPRI)
(SETQ C (1+ C)))
(PRINC)
); END ME.LSP

 

I have noticed this with the two other multi-line text editing lisps I have found in the forums.

 

Is this a problem with the lisp file itself or an app loading problem with AutoCAD? 

7 REPLIES 7
Message 2 of 8
doni49
in reply to: robyn.henke

Try this version on for size.

 

I made a few minor modifications in the course of tracking down the cause.  The old version allowed you to pick just anything and then as part of the while loop, it checked to be sure the selected item was a text or block insert.  This version only allows you to select those items (this part is in Green).

 

But the part that actually fixed your issue was removing the quotes form the TEXTEDIT command (that section is marked in red).

 

(defun C:ME (/ A B C D E F G H J K L M )
  (graphscr)
  (setvar "BLIPMODE" 0)
  (SETVAR "CMDECHO" 0)
  (SETVAR "HIGHLIGHT" 1)
  (PROMPT "\nMULTI-EDIT IS LOADED ...  ")
  (SETQ A (SSGET '((0 . "TEXT,INSERT"))) B (SSLENGTH A) C 0)
  (WHILE (< C B) 
    (SETQ D (SSNAME A C) 
          E (ENTGET D)
    )
    (SETQ F (CAR E))
    (SETQ G (CDR E))
    (SETQ H (CAR G))
    (SETQ J (CDR H))
    (SETQ K "TEXT")
    (SETQ L "INSERT")
    (SETQ M "DIMENSION")
    (IF (= J K) (COMMAND ".TEXTEDIT" D)(COMMAND ".DDATTE" D ))
    (TERPRI)
    (SETQ C (1+ C))
  )
  (PRINC)
); END ME.LSP

 



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 3 of 8
doni49
in reply to: robyn.henke

I also have another comment for you.  At the beginning of this code, you turn off cmdecho.  Whenever you turn a setting of like this, it's good practice to store that value and then restore it later (and use an error handler to do it so you can be sure it actually happens).

 

I don't have time right now to write up an explanation of how to do this but if you do a search, I'm sure you'll find lots of discussions about this.

 

A good place to start is at the link below (that's the actual place for discussing autlisp which is what this code is).

 

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130

 

EDIT:  For some odd reason, I thought I was in one of the basic Acad boards not the lisp board.  Duh!



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 4 of 8
hmsilva
in reply to: robyn.henke

Hi henke,
as Don has already stated, removing the quotes form the TEXTEDIT command did fixed your code, and add a filter to the ssget function, ensures that only those objects are selected.
I did add also a selection mode "_:L" to exclude objects in locked layers.
Did add an error handler to ensure that all modified system variables are restore.

 

My adaptation from your code:

 

(defun c:me (/ *error* blip cmde ent high hnd i ss)
  (defun *error* (msg)
    (setvar 'BLIPMODE blip)
    (setvar 'CMDECHO cmde)
    (setvar 'HIGHLIGHT high)
    (cond ((not msg))
          ((member msg '("Function cancelled" "quit / exit abort")))
          ((princ (strcat "\n** Error: " msg " ** ")))
    )
    (princ)
  )
  (setq blip (getvar 'BLIPMODE)
        cmde (getvar 'CMDECHO)
        high (getvar 'HIGHLIGHT)
  )
  (setvar 'BLIPMODE 0)
  (setvar 'CMDECHO 0)
  (setvar 'HIGHLIGHT 1)
  (if (and (princ "\nMULTI-EDIT IS LOADED ...  ")
           (setq ss (ssget "_:L" '((0 . "TEXT,INSERT"))))
      )
    (repeat (setq i (sslength ss))
      (setq hnd (ssname ss (setq i (1- i)))
            ent (entget hnd)
      )
      (if (= (cdr (assoc 0 ent)) "TEXT")
        (command "_.textedit" hnd)
        (command "_.ddatte" hnd)
      )
    )
  )
  (*error* nil)
  (princ)
)

 

Hope that helps
Henrique

EESignature

Message 5 of 8
robyn.henke
in reply to: doni49

Thank you very much.  I will do some research to see what you mean.

Message 6 of 8
robyn.henke
in reply to: hmsilva

Thank you very much!  I am sure there are lots of little problems with all of the lisp routines my company uses.  Having been self-taught, I still have quite a bit to learn in order to fix them!

Message 7 of 8
hmsilva
in reply to: robyn.henke


@Henke wrote:

Thank you very much! 


You're welcome, henke.

 


@Henke wrote:

 I am sure there are lots of little problems with all of the lisp routines my company uses.  Having been self-taught, I still have quite a bit to learn in order to fix them!


Any doubt, just ask.

 

Henrique

EESignature

Message 8 of 8
john.rizzato
in reply to: doni49

Don, thank you so, so, so, so much for your multi-text editing lisp!!!! I have been searching to no avail for 3 solid days trying to solve my dilemma. I am new to this forum, actually the reason I joined was to try and find a routine that I could use to edit multiple texts. I wanted to hit the "solved" button, but I think that someone has already done that, if there is another way to give you a thumbs up please tell me.

you, sir, have just made my day!!!!

thanks so much

John

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost