NhonG Posted November 12, 2011 Share Posted November 12, 2011 (edited) I have a lot of Text and MText in differences pattern and I'm looking for the command that can help me to work easier, Ex. XX01-000-XX000, XX00-000-XXX00 need to change to XX01_000-XX000, It's just "_" and "-" only but it's have too many for used "ED" and "shift + _". Please someone help me. Thank you so much. Edited November 12, 2011 by NhonG changed from format to pattern Quote Link to comment Share on other sites More sharing options...
fixo Posted November 12, 2011 Share Posted November 12, 2011 Welcome on board, Just type FIND in the command line and use dialog option settings Quote Link to comment Share on other sites More sharing options...
Jack_O'neill Posted November 12, 2011 Share Posted November 12, 2011 Just be careful when using FIND that you type in exactly what you want replaced, and exactly how you want it replaced. If you tell it to replace replace all "-" with "_" it will do that no matter where they are in the drawing. Quote Link to comment Share on other sites More sharing options...
NhonG Posted November 13, 2011 Author Share Posted November 13, 2011 I have a lot of Text and MText in differences pattern and I'm looking for the command that can help me to work easier, Ex. XX01-000-XX000, XX00-000-XXX00 need to change to XX01_000-XX000, It's just "_" and "-" only but it's have too many for used "ED" and "shift + _". Please someone help me. Thank you so much. Ohhh, I'm so sorry for my information about the example is not enough, XX01_000-XX000 = XX can be any alphabet such as MT01_001-DS120, BP06_023-CS000, BP06_023-B109 etc. or in any alphabet and also difference drawing but it's same pattern that need to change. Thank you. Quote Link to comment Share on other sites More sharing options...
NhonG Posted November 13, 2011 Author Share Posted November 13, 2011 Welcome on board, Just type FIND in the command line and use dialog option settings this solution can't useful for me cause when I had change from - (minus) to _ (underscore) it will be like this EB01_002_DS012 and when I need to change the only 2nd underscore to be minus , right now I have two underscore in the same word. Quote Link to comment Share on other sites More sharing options...
pBe Posted November 13, 2011 Share Posted November 13, 2011 (edited) (defun 2nd (str) (vl-string-subst "_" "-" (vl-string-translate "_" "-" str) ) ) (2nd "BP06_023_CS000"); "BP06_023-CS000" (2nd "BP06-023-CS000") "BP06_023-CS000" (defun c:test (/ aDoc) (vl-load-com) (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (ssget ":L" '((0 . "*TEXT"))) (progn (vlax-for itm (setq ss (vla-get-ActiveSelectionSet aDoc ) ) (vla-put-textstring itm (vl-string-subst "_" "-" (vl-string-translate "_" "-" (vla-get-textstring itm) ) ) ) ) ) ) ) I'm confused now Edited November 13, 2011 by pBe Quote Link to comment Share on other sites More sharing options...
fixo Posted November 13, 2011 Share Posted November 13, 2011 this solution can't useful for me cause when I had change from - (minus) to _ (underscore) it will be like this EB01_002_DS012 and when I need to change the only 2nd underscore to be minus , right now I have two underscore in the same word. I have disagreed You did it wrong Type in the find text box: EB01- Then in Replace textbox: EB01_ Hope it make a sence Quote Link to comment Share on other sites More sharing options...
NhonG Posted November 14, 2011 Author Share Posted November 14, 2011 (defun 2nd (str) (vl-string-subst "_" "-" (vl-string-translate "_" "-" str) ) ) (2nd "BP06_023_CS000"); "BP06_023-CS000" (2nd "BP06-023-CS000") "BP06_023-CS000" (defun c:test (/ aDoc) (vl-load-com) (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (ssget ":L" '((0 . "*TEXT"))) (progn (vlax-for itm (setq ss (vla-get-ActiveSelectionSet aDoc ) ) (vla-put-textstring itm (vl-string-subst "_" "-" (vl-string-translate "_" "-" (vla-get-textstring itm) ) ) ) ) ) ) ) I'm confused now I,m so sorry if my example took you confused, some naming have EB01-001-CS012 some naming have EB05_002_CS161 some naming have EB07-009_CS191E in the same drawing. but only one pattern that I need to change to the real pattern is "EB07_007-CS012" just start with "_' and end with "-" AND THANK YOU SO MUCH, YOUR CODE IS WHAT I AM LOOKING FOR IT'S USEFUL FOR " EB07-009_CS191E". FOR ANOTHER PATTERN I WILL TRY TO APPLY YOUR CODE. Thank you so much. I have disagreedYou did it wrong Type in the find text box: EB01- Then in Replace textbox: EB01_ Hope it make a sence Thank you so much for your kindly help me to find out the shortest path, but as I had show you example, it's just for only example, in fact the naming have a lot of deference word but only pattern have same issue, if I used your solution I will be do like this one by one, otherwise two or four by four word. Quote Link to comment Share on other sites More sharing options...
pBe Posted November 14, 2011 Share Posted November 14, 2011 No worries NhonG, but did you try the test code? It will give you the same result for all three of your samples. "EB01-001-CS012" "EB05_002_CS161" "EB07-009_CS191E" "EB01_001-CS012" "EB05_002-CS161" "EB07_009-CS191E" Is that the final result you need? Quote Link to comment Share on other sites More sharing options...
NhonG Posted November 14, 2011 Author Share Posted November 14, 2011 No worries NhonG, but did you try the test code? It will give you the same result for all three of your samples. "EB01-001-CS012" "EB05_002_CS161" "EB07-009_CS191E" "EB01_001-CS012" "EB05_002-CS161" "EB07_009-CS191E" Is that the final result you need? Yeah, I just test in only one example. It's great and help me to save a lot of time. Thank you so much. Quote Link to comment Share on other sites More sharing options...
pBe Posted November 14, 2011 Share Posted November 14, 2011 Glad I could help NhonG Cheers Quote Link to comment Share on other sites More sharing options...
NhonG Posted November 14, 2011 Author Share Posted November 14, 2011 Glad I could help NhonG Cheers Cheers and I would like to add your information into the lisp file, because, if I have pass it to anybody then they will know that is not my, but it's your and I got it from cadtutor.net. 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.