Collect certain attributes from component and apply to new element

We have moved PLUGs from the CLOS heading in the specs to the PCOM heading so the PL skey will work.

We have several UDAs populated at the component level.

I've created this macro to swap out the components, but the users are required to repopulate the UDAs after the swap.

Is there a slick way to collect several defined UDAs rather than VAR3 MTOC VAR4 MTOT VAR5 :SOMETHING VAR6 :SOMETHING_2 VAR7 :SOMETHING_3...?

UDA's are strings so I believe that's why this syntax isn't working  -  :SOMETHING $V5

When at a CLOS or collection of CLOS:

VAR1 SPREF VAR2 LSTUB
DELETE CLOS LAST MEM NEW PCOM spref $V1 lstube $V2 CONN

  • If you just moved it from one heading to another, then reference from design didn't changed. And you don't need to delete it in design, just tap standing on clos "changetype to pcom"

  • if you still need to COPY attributes, you can use this function (just save it in text document with .pmlfnc extension, paste it in pmllib location and tap "pml rehash all")

    define function !!ehrCopyAttributes(!aAttributes is ARRAY, !dFrom is DBREF, !dTo is DBREF)
    --!aAttributes need to be array of strings
    --!aAttributes[1] = 'Ddname'
    --!aAttributes[2] = 'Pkdistance'
    --!aAttributes[3] = 'Justification'
    
    	do !attribute values !aAttributes
    		!dTo.$!attribute = !dFrom.$!attribute
    		handle any
    			$p can not copy $!attribute from $!dFrom.Name to $!dTo.Name
    		endhandle
    	enddo
    endfunction

  • CHANGETYPE TO PCOM returns with this error:

  • The thread title could have been better.

    After moving SPCOs from the CLOSure heading to the PCOM heading I need to change CLOSures in the model to PCOMs.  The only way I have found to do this is by deleting the CLOS and inserting a PCOM using the same SPRE of the CLOS.

    The issue with this is the UDAs that were populated for the CLOS need to be repopulated after inserting the PCOM.  This need to be done on thousands of plugs across a dozen or more projects.

  • Then you need to write macro which will do this algorithm:

    1) create array with strings: "pos", "ori", ":udas" and etc. 

    2) collect all CLOS components, which you need to replace (you can use expression for collecting clos where catr contains special naming standard, or create uda for spco ex. :NeedToBeReplace, and then use it in expression)

    3) in the loop create new pcom (You already know which spref need to be used), standing on selected clos, and call function I sent previously  !!ehrCopyAttributes(!aAttributes, !clos, !pcom)

    4) if success stand on clos and delete it

    5) stand on branch and use "conn pt to last mem"

    6) OPTIONAL: I'd write log file for know which closes I deleted and which pcoms I created, and also which branches were modified.

  • I think you can do, assuming CE is the CLOS. Maybe the spref setting is not even needed, depends on how the system check validity of the spref to copy when copying attributes

    !spref = !!ce.spref
    NEW PCOM
    spref $!spref
    COPY ATT OF PRE
    PRE
    DELETE PCOM

  • COPY ATT OF PRE does the trick.  Thanks