Jump to content

Recommended Posts

Posted (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 by NhonG
changed from format to pattern
Posted

Welcome on board,

 

Just type FIND in the command line and use dialog option settings

Posted

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.

Posted
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.

Posted
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.

Posted (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 :D

Edited by pBe
Posted
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

Posted
 
(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 :D

 

:) 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 disagreed

You 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.

Posted

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?

Posted
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.

Posted
Glad I could help NhonG

 

Cheers :beer:

 

 

 

Cheers :beer: 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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...