TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jlogan02 on September 30, 2022, 05:43:07 PM
-
The attached image represents a progression of new projects within one drawing. Each new project is always red. Each project after that is assigned a color. Each revision block you see from left to right is how the revision would appear in a separate drawing version of the same drawing, new project.
So there is a green revision (drawing start). Brand new drawing, the project doesn't get a color, it stays bylayer.
Rev#1 is red
New project starts, Rev#1 becomes color 56, Rev#2 becomes red.
New Project starts, Rev#2 becomes color 107, Rev#3 becomes red.
New Project starts, Rev#3 becomes 136, Rev#4 becomes red.
Most times you might see two colors, but can have as many as 5 projects running within the same drawing at one time. Think of them as chronological revisions.
Using color routines I hunt for RED mtext entities and change them to the next revision color.
Sadly, some of our users insist on overwriting Mtext color. Hence the code below. You might note that I'm exacerbating the mtext color overwrite issue buy using this piece of code as C1 becomed C136, not 1 and 136 per the properties color palette.
I need to find a way to either strip the overwritten Mtext of just one of the colors while leaving the other colors alone during the change from RED (above code) to that new revision color, or better still strip out the overwritten C1 color and then change it to the next color. The overwritten color issue always starts with RED.
For now I'm just adding this to the end of each "return to bylayer" routines.
(Alert "Some MText may have not be returned to it's bylayer color. Select them now") (StripMtext
(ssget) "c") ;;select all red text not changed by routine.
-
Just a thought maybe check backwards start with does highest color exist and change. Then can make lower color go up.
-
That's is exactly were I'm stuck. I can't seem or don't know how to check for the overwritten value.
(vl-string-search "\\C1;") ???
-
This gets the selection set for mtext entities that are red... but I get this error.
Error: bad argument type: (or stringp symbolp): <Selection set: 70>
It's the as C1 is not a string ??
(defun c:foo
( / str obj txt
) (stripmtext obj '("C"))
(command "chprop" obj
"" "C" "56" "") )
)
)
)
)
Once this runs and I get the error, I can drop the last two lines into the command line and they do what is expected. I can't seem to get any farther.
-
You need to look at the mtext string closer your not removing enough control code.
: (vla-get-textstring obj)
"ABCD\\C1;EFG"
remove color from mtext manually
: (vla-get-textstring obj )
"ABCDEFG"
-
(defun c:foo
( / str obj txt
) (stripmtext obj '("C"))
(command "chprop" obj
"" "C" "56" "") )
)
)
)
)
added wildcard both side of color code
Returns nil
At this point that feels like a win, even though it's not.
-
While laying here in an emergency room I thought I'd see if I could go off memory, no ACAD, and no code.
I believe I left off with an attempt to changing
to
There was 1 piece of red mtext in the drawing and another piece of text on color 136. Both with the letters asdadf.
From memory I got a...
bad arguement type lselsetp {\\c1;asadf}
I looked at the lselsetp error definition. Am I changing ssname or sslength maybe ?
I'm pretty sure none of that is right while going purely from memory.
Anyway, I'm just killing time waiting for test results. How long does it take to spin a vile of blood round and round?