My SPCO elements have a custom function file that was created a while back with help from AVEVA representative. It works for every GTYPE however not as intended. You see, if I am adding Unions for example - I can go to CATE for unions and add the entire CATE - the Autonaming will work for each SPCO giving me something like this: /A331/UNIO-AA
Then I try to add VALV the same way - using the whole CATE - and the results are not the same. However, if I add one SCOM at a time - then I get a different result like /A331/ALB-AAVBBBGAA. Here it takes the name of the CATE. Can you help?
[HTML]
define function !!mtxautonamespco(!prefix is string) is string
-- SPCO is Part Name if the Part Name is Set
if (not (unset (!!ce.Prtreference))) then
!Prtreference = !!ce.Prtreference.namn
!Prtreference = !Prtreference.replace('-', ':')
!newname = !prefix & '/' & !Prtreference
name /$!newname
return !newname
endif
-- Component Names can vary based on Component Type
!gtype = !!ce.catref.gtype
if !gtype eq 'TUBE' or !gtype eq 'ELBO' or !gtype eq 'CAP' then
!material = 'AAA'
!own = !!ce.catref.own.namn
var !bore p1bore of catref
!bore = !bore.replace('mm','')
!sch = !!ce.detref.namn
!sch = !sch.after('-')
!newname = !prefix & '/' & !material & !sch & !own & ':' & !bore
name /$!newname
return !newname
endif
if !gtype eq 'VALV' or !gtype eq 'PCOM' or !gtype eq 'FILT' or !gtype eq 'TRAP' or !gtype eq 'OLET' or !gtype eq 'REDU' or !gtype eq 'FLAN' then
!midd = !!ce.catref.gtype
!suff = !!ce.catref.name.substring(-1,-2)
!newname = !prefix & '/' & !midd & '-' & !suff
name /$!newname
return !newname
endif
if !gtype eq 'UNIO' or !gtype eq 'INST'then
!midd = !!ce.catref.gtype
!suff = !!ce.catref.name.substring(-1,-2)
!newname = !prefix & '/' & !midd & '-' & !suff
name /$!newname
return !newname
endif
if !gtype eq 'TEE' then
!midd = !!ce.catref.gtype
!suff = !!ce.catref.name.substring(-1,-2)
!newname = !prefix & '/' & !midd & '-' & !suff
name /$!newname
return !newname
endif
if !gtype eq 'GASK' then
!material = !!ce.Matx.namn
!own = !!ce.catref.own.namn
var !bore p1bore of catref
!bore = !bore.replace('mm','')
!newname = !prefix & '/' & !material & !own & ':' & !bore
name /$!newname
return !newname
endif
I think, need to investigate why your function !!mtxautonamespco() is not running
or if it is running, then find out why your conditions are not triggered.
You may try to debug this function using outputing comments into command line by operator $p
firstly, the error returned in the screenshot 1 is the result of the lines in your pmlobj file returning error when finished. So if it does not find the GTYP listed then it will return 'error' as the string for your autoname substring. It will also return this at the end of the program as its outside of the If statements.
original code
if !gtype eq 'INSU' then
return
endif
return 'error'
endfunction
corrected code to comment out the returned error with --
if !gtype eq 'INSU' then
return
endif
-- return 'error'
endfunction
The second issue is you cannot edit this file. so you will need some PML to run after the items have been created. I can post this in another reply.