Editing multiple single-line text entities.... again!

Editing multiple single-line text entities.... again!

Anonymous
Not applicable
2,401 Views
17 Replies
Message 1 of 18

Editing multiple single-line text entities.... again!

Anonymous
Not applicable

Deja vu!

 

I had this same list file not work after updating to 2015 and now after updating to 2017, it is not working again.

 

So, to state again:

 

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, here 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 '((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

 

I cannot seem to figure out what is causing the problem.  Any help would be greatly appreciated!

0 Likes
Accepted solutions (2)
2,402 Views
17 Replies
Replies (17)
Message 2 of 18

hmsilva
Mentor
Mentor

Just a guess, I don't have AC2017 in this old laptop...

Try to change

DDATTE

to

ATTEDIT

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 18

Anonymous
Not applicable
Nope, sorry. Still get the same problem.

Robyn Henke
Senior CADD/Revit Technician
JDR Engineering, Inc.
www.jdrengineering.com

5525 Nobel Drive | Suite 110 | Madison, WI 53711
T: 608-277-1728| F: 608-271-7046 | Direct: 608-819-0174 | henke@jdreng.com
0 Likes
Message 4 of 18

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

I had this same list file not work after updating to 2015 and now after updating to 2017, it is not working again.

.... 

(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

 

I cannot seem to figure out what is causing the problem.  Any help would be greatly appreciated!


You don't say what "not working" means.  Does it fail to load?  Does it load but not run?  Does it run but give different results than you expect?  What does it not do that you expect it to?  What does it do that you don't expect?  Any error messages?  Etc., etc.

 

If I may say so, that's a very peculiar way to get an entity type.  I don't have 2017 here, but it could be that it lists entity data in a slightly different way.  That code requires the entity-type entry to be exactly the second one in the entity data list, but maybe it's not in 2017.  If that's the cause of the problem, you can get the entity type directly, whatever position its entry is in the list, and shorten the code considerably by doing so [there are also several unused variables], something like [untested]:

 

(defun C:ME (/ A B C D J)
  (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)
      J (CDR (assoc 0 (entget D)))

    )
    (IF (= J "TEXT") (COMMAND ".TEXTEDIT" D) (COMMAND ".DDATTE" D ))
    (TERPRI)
    (SETQ C (1+ C))
  )
  (PRINC)
); END ME.LSP

 

or even without the J variable:

....

  (WHILE (< C B)
    (SETQ D (SSNAME A C))
    (IF (= (CDR (assoc 0 (entget D))) "TEXT") (COMMAND ".TEXTEDIT" D) (COMMAND ".DDATTE" D ))

....

 

Kent Cooper, AIA
0 Likes
Message 5 of 18

Anonymous
Not applicable

I know the code is odd. This lisp has been with "us" since before I started in 1999.

Have not had the ambition to fix it or make it better, have just kept using as is.

Your suggestion did not work.

This is the error I have gotten after trying all suggestions:

Command: ME2

MULTI-EDIT IS LOADED ...
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:

Current settings: Edit mode = Multiple



*Invalid selection*
Expects a point or Last/Undo
ERROR: Function cancelledAutoCAD variable setting rejected: "MENUECHO" nil

 

The above error, minus the line is red, is the error I was originally getting.

0 Likes
Message 6 of 18

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....
    (IF (= J K) (COMMAND ".TEXTEDIT" D)(COMMAND ".DDATTE" D ))
    (TERPRI)
    (SETQ C (1+ C))
  )
  (PRINC)
); END ME.LSP

....


I would think if this were the issue, it would have not worked in any version, but here goes....

 

That looks like it doesn't allow for any User input to actually do the editing, but calls up one of the commands, and while that's presumably waiting for editing input, goes on to look at the next object.  Without setting up the situation and trying it, you may need something like a check on whether the command is still active and pause to wait for User input until it's done, before moving on, such as:
....

    (IF (= J K) (COMMAND ".TEXTEDIT" D)(COMMAND ".DDATTE" D ))

    (while (> (getvar 'cmdactive) 0) (command pause)))

    (setq C (1+ C))

....

 

which works in certain kinds of commands, but I'm not sure how that relates to in-view text editing as that works in recent versions.  Or if the in-view editing box is considered a "dialog box" condition, you may need to force it to bring that up, since the default in (command) functions is to operate without the dialog box unless you do call for it:

....

    (initdia)

    (if (= J ....

Kent Cooper, AIA
0 Likes
Message 7 of 18

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....
*Invalid selection*
Expects a point or Last/Undo

....


As for that, does it work right if every object selected is Text and none are Attributes?  In the case of Attributes, the "object" it gets when it steps through the selection set will be the Block, which you may have selected somewhere other than on an Attribute, or as part of a Window selection.  It may need a location in order to find which Attribute to edit, since Blocks can have more than one [and it may need that even in the case of a Block that has only one].  But if you pick only Text, that presumably would not be an issue, since the entity name alone should be enough for it to know what to work with.

Kent Cooper, AIA
0 Likes
Message 8 of 18

Anonymous
Not applicable

It worked with only text and any text that had attributes.  It was an awesome lisp for our purposes.

 

I am thinking of passing this one on to a person in our office who is a little more versed in lisp language.

 

I am no expert, not even a novice really.  I learned all this on my own by "reverse engineering" all the lisps we use.

 

I have not understood the language in most of the replies to this thread!

 

I do like learning and don't just want to say "Please write me this lisp" and thank you very much, but it seems very complicated to me.

0 Likes
Message 9 of 18

Anonymous
Not applicable

I just opened up 2016 and tried the ME lisp and is works great!

 

Command: me

MULTI-EDIT IS LOADED ...
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:

 

I did notice there was no "Current settings:  Edit mode = Multiple" line.  Is that significant?

0 Likes
Message 10 of 18

ВeekeeCZ
Consultant
Consultant
I would try change the settings...
Current settings: Edit mode = Multiple -> to Single?

Then maybe
(COMMAND ".TEXTEDIT" D PAUSE "")

0 Likes
Message 11 of 18

Anonymous
Not applicable
Accepted solution

TEXTEDITMODE was the problem.... or so I believe.

 

It was initially set to 0 (Sets the TEXTEDIT command to repeat automatically).

 

I set it to 1 (Sets the TEXTEDIT command to edit a single text object) and now the lsp works as it was originally.

 

Is that a new variable?

0 Likes
Message 12 of 18

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

TEXTEDITMODE ....

 

Is that a new variable?


Must be -- it's not recognized here in AutoCAD 2016.

Kent Cooper, AIA
0 Likes
Message 13 of 18

Anonymous
Not applicable

Ok, I know what was causing my problem, but I assume when I install 2017, that variable will be set to 0 and I know some users will like it kept that way.

 

But, using ME will not work for them, so, can someone please help me with how to add to the lsp to set that variable to 1 before running it and then setting it back to 0 after the user is done?

 

Again, here is the original lisp:

 

(defun C:ME (/ A B C D E F G H J K L M )
  (graphscr)

  (setvar "TEXTEDITMODE" 1)
  (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

 

Is the line in red all I need to do?  Is this set up to already set variables back to what they were before running the lisp?

0 Likes
Message 14 of 18

hmsilva
Mentor
Mentor

@Anonymous wrote:

TEXTEDITMODE was the problem.... or so I believe.

... 

Is that a new variable?


Yes, it is...

 

2017 New Commands and System Variables

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 15 of 18

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... can someone please help me with how to add to the lsp to set that variable to 1 before running it and then setting it back to 0 after the user is done?

....

Is the line in red all I need to do?  Is this set up to already set variables back to what they were before running the lisp?


The usual way would be something like this:

 

(defun C:ME (/ tem A B C D E F G H J K L M )
  (graphscr)

  (setq tem (getvar 'texteditmode))

  (setvar "TEXTEDITMODE" 1)
  (setvar "BLIPMODE" 0)
....  ....
    (SETQ C (1+ C))
  )

  (setvar 'texteditmode tem)
  (PRINC)
); END ME.LSP

 

Call the variable anything you like.  A good error handler can also ensure that it will be reset even if there is some error.

 

BUT it occurs to me -- will the routine be used on some 2017 stations and some with earlier versions?  That would be a problem if you do only the above, because there will be an error trying to reset it in older versions.  You could do something that checks the AutoCAD version first, but since, in a version that does not have that System Variable, "getting" it will just return nil, you could simply make it depend on that:

 

(defun C:ME (/ tem A B C D E F G H J K L M )
  (graphscr)

  (if (setq tem (getvar 'texteditmode))

  (setvar "TEXTEDITMODE" 1))
  (setvar "BLIPMODE" 0)
....  ....
    (SETQ C (1+ C))
  )

  (if tem (setvar 'texteditmode tem))
  (PRINC)
); END ME.LSP

Kent Cooper, AIA
0 Likes
Message 16 of 18

Anonymous
Not applicable

Right now, I am testing out 2017 with our highly customized AutoCAD, so, yes, 2016 would be using it for at least the next couple of weeks.

 

Thank you so much!!

0 Likes
Message 17 of 18

Anonymous
Not applicable

So after all the changes, do we have a working lisp file that I can just load up? 

0 Likes
Message 18 of 18

Anonymous
Not applicable

This was the error for me. Changing this variable worked a treat. Thanks so much

 


@Anonymouswrote:

TEXTEDITMODE was the problem.... or so I believe.

 

It was initially set to 0 (Sets the TEXTEDIT command to repeat automatically).

 

I set it to 1 (Sets the TEXTEDIT command to edit a single text object) and now the lsp works as it was originally.

 

Is that a new variable?




0 Likes