Skip to main content
21-Topaz II
March 26, 2018
Solved

Replace Underscores with Spaces in Relations

  • March 26, 2018
  • 1 reply
  • 2823 views

We use the format <vendor name>_<vendor p/n> for some of our purchased components.  In order to show the info in a more readable format on drawings, that same info gets added to our "Description" parameter with spaces instead of the underscores.  I'd like to avoid typos by driving the parameter from the filename via relations while replacing the underscores with spaces. Of course, not every vendor name is the same number of characters, so using the string length isn't an option.  I need to be able to find the underscores and replace them.

 

Possible?

1 reply

24-Ruby III
March 26, 2018
21-Topaz II
March 26, 2018

That should do it, I just now need to sort out the full syntax since there might be spaces in the vendor name as well.  I think I can sort that out.

 

Thanks.

HamsterNL
18-Opal
March 28, 2018

You could try this:

 

The trick here is that COMP_NAME_NICE will be "out-of-date" after the FIRST and SECOND parameters have changed, thus another regeneration is required.

 

Problem is that you first need to run this once, then uncomment the line.

 

COMP_NAME = "MY_COMPANY_NAME_WITH_UNDERSCORES"
COMP_NAME_NICE = COMP_NAME /* COMP_NAME_NICE = FIRST + " " + SECOND IF search(COMP_NAME_NICE,"_") > 0 FIRST = extract(COMP_NAME_NICE,1,search(COMP_NAME_NICE,"_")-1) SECOND = extract(COMP_NAME_NICE,search(COMP_NAME_NICE,"_")+1,string_length(COMP_NAME_NICE)-search(COMP_NAME_NICE,"_")) ENDIF