Sandervp wrote:
...Sadly, your solution didn't work.
....
The intention was to move every mtext object containing the 0, to the layer 0.
....
Layer to move to: 0
_.chprop
Select objects:
Command: TEST
Unknown command "TEST". Press F1 for help.
Command: _layer ....
|
The routine is written to find [if you give it "0" for the initial letter] any Mtext not merely containing "0", but specifically beginning with "0" followed by two underscore characters, in keeping with your original description [' These letter combination starts with "A__". ']. It works for me.
The fact that it returns to the Command: prompt after after only one Select objects: prompt suggests to me that there are no Mtext objects in the drawing that begin with "0__", that is, the (ssget) function returns nil. The "" [Enter] that is there to complete the selection [which should be fed in at a second Select objects: prompt] then instead recalls the last command entered at the Command: prompt ["TEST"], but inside a (command) function it won't recognize a (defun)'d command name, only native AutoCAD command names, which is why it gives the Unknown command message. Then the _layer that is there to be an option within the CHPROP command coincidentally happens to also be a command name that it recognizes, so it inappropriately begins that command.
Ensure that there is at least one Mtext object whose text content begins with "0__", and see whether it works. It could easily be made to check whether it finds any Mtext that starts with the right sub-string before proceeding, if you like. It could also be made to find any Mtext that begins with the initial character without necessarily having "__" following it, if that's appropriate, or with the initial character + "__" but not necessarily at the beginning. [It could also be made to find all Mtext that merely contains the initial character anywhere in it, if that's what you really want, but that seems likely to change more Mtext than you want to a different Layer, especially if the initial character is a letter].
|