cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Truncate filename in repeat region - SUMMARY

cying
10-Marble

Truncate filename in repeat region - SUMMARY

Thanks to all who have responded 🙂



The simplest solution is:

T_Name = extract(asm_mbr_name,1,12) then in your repeat region add &rpt.rel.T_NAME



If you have a filename less than 12 characters, the ITEM column will be null. You will need to write additional relation to correct these conditions.




Operators and Functions for Strings
The following operators and functions are supported for strings:
==

Compares strings as equal.

!=, <>, ~=

Compares strings as unequal.

+

Concatenates strings.

itos(int)

Converts integers to strings. Here, int can be a number or an expression. Nonintegers are rounded off.

search(string, substring)

Searches for substrings. The resulting value is the position of the substring in the string (0 if not found).

extract(string, position, length)

Extracts pieces of strings.

For example:
If param = abcdef, then:



flag = param == abcdef—returns TRUE





flag = abcdef != ghi—returns TRUE





new = param + ghi—new is abcdefghi





new = itos(10 + 7)—new is 17





new = param + itos(1.5)—new is abcdef2





where = search(param, bcd)—where is 2





where = search(param, bcd)—where is 0





new = extract(param,2,3)—new is bcd

Note
If you use the itos function on a parameter whose value is zero (0), the return value is an empty string.
The following examples illustrate the itos function:
integer_param = 4
string_param = itos(integer_param)
/*string_param will return 4 */
integer_param = -7
string_param = itos(int_param)
/*string_param will return -7 */
For an integer with zero (0) value, the itos function returns a null (") value as shown below:
integer_param = 0
string_param = itos(int_param)
/*string_param will return an empty or null string (") */
To return a zero string value ("0"), use the following IF statement:
integer_param = 0
string_param = itos(integer_param)
IF string_param == "
string_param = "0"
ENDIF



ADDITIONAL FEEDBACK

Part Number Shows Descriptive Extension – CAUTION – This works when dealing with piece part assemblies! (The assembly has the same name as a part and the part has been assembled into it.)



• A component name is not the standard name. It contains an extension from a family table or a descriptive extension, such as a cable.

• Retrieve the Generic assembly or assembly. Assure that the following parameters exist PART_TYPE and DESCRIPTION. IF they don’t Create them. Set-Up-Parameters-Create-String PART_TYPE, ASSEMBLY, and DESCRIPTION. If it is an assembly with a descriptive extension PART_TYPE needs to be INST.

• Add a relation to generic assembly Relations-Assem Rel-Add, type:

o generic=extract(rel_model_name,1,14) (or last number is length of characters.)

• For Family Tables:

• Add parameters PART_TYPE and DESCRIPTION to family table. Family Tab-Add Item-Parameter-check PART_TYPE and DESCRIPTION.

• Family Tab-Edit change PART_TYPE to INST for each instance, but not the generic. Modify Description to match its same description for that instance.

• Save file and go back to your drawing.

• The Auto table may have to be deleted and placed again for the correction to appear. Try Table-Repeat Region-Update Tables, first. If it has also effected the Format, it will need placed again.



ADDITIONAL FEEDBACK
Basically what you do is write a relation in the repeat region that extracts the first 12 characters of a file name and set’s that value to a parameter (let’s name the parameter shortname). Then you change the column in your repeat region to call that parameter instead of the file name.

The relation could look like this:
shortname = extract(mbr_name, 1, 12)

The repeat region column should be set like this:
&rpt.rel.shortname (instead of &asm.mbr_name)


Just be aware that if you will have file names that are shorter than 12 characters you would have to play some games with the relation or it will error out.

1 REPLY 1

If the length of the string might be shorter, use:


string_length(parameter name) returns the length in characters of the string contained by parameter name.


As in:



T_Name = asm_mbr_name


IF string_length(asm_mbr_name) >= 12


T_Name = extract(asm_mbr_name,1,12)


ENDIF

Top Tags