TEXT IS TEXT (ddt.lsp)You hit Ddedit, pick the text and nothing happens. It was an Attribute. So you cancel the Ddedit command and start the Ddatte command. Ddedit handles Text, Mtext and Attribute definitions but for some reason ignores inserted Attributes, even though they are text. DDT.LSP is an AutoLISP program that will run either Ddedit or Ddatte according to the object selected.The ListingAfter the program description, the program's name is defined and the variables it uses are localized. The current value of the Cmdecho setvar is then stored in variable CMD2 for restoration later. The next line sets the Cmdecho setvar to zero to turn off command echoing.A variable called IT2, which will be used as a counter is then initialized to zero. This counter will be used to count the number of text objects changed to allow an accurate reproduction of the Ddedit's U option. The next line initializes a keyword option for the following ENTSEL function. Although ENTSEL usually requests only an object, the INITGET function also allows it to accept a keyword response. By using uppercase for the first character, the user only needs to respond with that character to enter the keyword but may type more characters, up to the entire keyword. The following line is the ENTSEL function using an exact duplicate of Ddedit's prompt. The user's response is stored in variable ENT2. A WHILE loop is then started which will run as long as ENT2 has a value, either an object or the keyword. An IF just inside the loop will run if the value in ENT2 is "Undo". This IF's then-expression is grouped by a PROGN which starts with another IF whose then-expression, again grouped with a PROGN, will run if the value of IT2 is greater than zero, meaning that one or more text objects had been edited. This starts by decrementing IT2 and the running AutoCAD's U command to undo the last text edit. The latest PROGN and IF are then closed off and another IF, continuing the then-expression of the "Undo" IF, checks to see if the value of IT2 is now 0 (zero). If so, it will display a prompt informing the user that the command has been completely undone. We now move into the else-expression of the If that checked if the value in ENT2 was "Undo". This runs if an object was selected and starts by storing the selected object's name in ENT3 and the object's type in ENTT2. A COND function is then started which is a bit like a multiple If. This starts with a test to see of the value in ENTT2 is "TEXT". If so then the remaining expressions in the list are executed. These run the Ddedit command on the selected object and increments the IT2 counter. The COND function will then exit without running any of the later tests. If, however, the first test returned nil (was false), the second test would be run and so on. This would continue until something returned T (true). The last test is customarily T in case all the earlier tests returned nil. In this case we test for ENTT2 being "TEXT", "MTEXT", "ATTDEF" and "INSERT". The first three run the Ddedit command and increment IT2 by one, whilst the fourth runs a further test to see if the block insertion has any attributes. If so, the Ddatte command is run on the selected object and IT2 is incremented by one. After the COND is finished, the PROGN grouping this else-expression is closed as is the IF which had checked to see if ENT2 was "Undo". The INITGET and object selection routines from earlier in the program is duplicated to prompt the user to select another object (or hit "U"). If the user did either of these, the WHILE loop would repeat, whereas hitting [RETURN] or picking an empty point in the drawing will quit out of the loop. Once the loop has been exited, the Cmdecho Setvar is restored to its
previous value and the Princ function is called to prevent the value of
Cmdecho being printed on the screen as the program exits.
|
©1996-2001 ZOTO Technologies