ajs Posted February 14, 2009 Share Posted February 14, 2009 I have a string that is printed in the upper right hand corner of my drawing.The string holds two variables. The position that the text is printed depends on the type of drawing that is loaded up. I was wondering if it was possible (with a reasonable amount of effort) to have the color switch on just the variable portion of the string. Here's the string: (setq PRINT_AREA (strcat "B Area: " B_AREA " s.f. T Area: " T_AREA " s.f." )) I would like B_AREA and T_AREA to have different colors than the rest of the string which is set to color ByLayer Here's the code that prints the string: (Command "layer" "SET" "VARTEXT_1" "") (If (OR(= LBN_TR "1")(= ALLN_TR "1")(= RBN_TR "1"))(Command "TEXT" "79.5842,96.8110" "2.25" "0" (princ PRINT_AREA))) (If (= BN_TR "1")(Command "TEXT" "91.2543,96.8110" "2.25" "0" (princ PRINT_AREA))) (If (= IS_TR "1")(Command "TEXT" "124.0738,101.7847" "2.25" "0" (princ PRINT_AREA))) Thanks in advance for any advice on this ---AJS Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 This may help you work it out : (defun c:test (/ B_AREA T_AREA BN_TR col1 col2 PRINT_AREA) (setq B_AREA "TEST1" T_AREA "TEST2" BN_TR "1") (setq col1 (itoa (acad_colordlg 0 T)) col2 (itoa (acad_colordlg 0 T))) (setq PRINT_AREA (strcat "B Area: \{\\C" col1 ";" B_AREA "\} s.f. T Area: \{\\C" col2 ";" T_AREA "\} s.f.")) (command "layer" "SET" "VARTEXT_1" "") (if (or (= LBN_TR "1") (= ALLN_TR "1") (= RBN_TR "1")) (command "-MTEXT" "79.5842,96.8110" "H" "2.25" "R" "0" "@50,-50" PRINT_AREA "")) (if (= BN_TR "1") (command "-MTEXT" "91.2543,96.8110" "H" "2.25" "R" "0" "@50,-50" PRINT_AREA "")) (if (= IS_TR "1") (command "-MTEXT" "124.0738,101.7847" "H" "2.25" "R" "0" "@50,-50" PRINT_AREA "")) (princ)) Quote Link to comment Share on other sites More sharing options...
ajs Posted February 14, 2009 Author Share Posted February 14, 2009 Thanks for posting the code so thoroughly. I'm going to study it so that I can understand what the principles are. Greatly appreciated. ---AJS Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 14, 2009 Share Posted February 14, 2009 No Worries AJS, You will only be able to use MTEXT to accomplish this goal - as single-line text (DTEXT) does not allow this feature. You have to mess around with the input string to change the text colour, using bracketed terms using curly braces "{" to enclose coloured text. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.