Skip to main content
21-Topaz II
Mar 26, 2018 3:26 PM UTC
Solved

Replace Underscores with Spaces in Relations

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?

4 replies

24-Ruby III
Mar 26, 2018 3:39 PM UTC
21-Topaz II
Mar 26, 2018 3:59 PM UTC

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.

Translate
HamsterNL
18-Opal
Mar 28, 2018 11:59 AM UTC

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

 

Translate