AnsweredAssumed Answered

vb Script to apply Component Modifications to Funtions (Function Managed Variants)

Question asked by fuba on Jan 31, 2018
Latest reply on Feb 7, 2018 by fuba

Hello,

 

I am looking for a way to automate / apply Component Modifications to Functions.

What I am able to do with the code below, is apply Component Modifications to Variants.

 

How do i do that for Functions ??

 

I know that ".PutComponentModification" takes only a Variant Object for the first argument, but

shouldnt there be a ".PutComponentModification" which takes a Function Name/Object ??

 

Thanks

 

Public Shared Function VM_Set_ComponentModifications(ByVal VmDoc As MGCVARIANTGUI.VMDocument) As integer

 

        '#

        '# this works but only for Variants not for Functions!!!

        '#

 

        Dim refDes As String

        refDes = "R2"

 

        Dim vmFunc As MGCVARIANTGUI.VMFunction

        vmFunc = VmDoc.FindFunction("MyFkt") '# precondition, 'MyFkt' exists (.PutFunction)

 

        Dim oVmVariant As MGCVARIANTGUI.VMVariant

        oVmVariant = VmDoc.FindVariant("MyVar") '# precondition, 'MyVar' exists (.PutVariant)

    

        Dim oVMComponent As MGCVARIANTGUI.VMComponent

        oVMComponent = VmDoc.FindComponent(refDes)

 

        Dim oVMCompModification As MGCVARIANTGUI.VMComponentModification

        Dim eChangeOper As MGCVARIANTGUI.EVMOperation

 

        Dim newPn As String

        newPn = "Unplaced"

 

        If (newPn = "Unplaced") Then

            eChangeOper = MGCVARIANTGUI.EVMOperation.eVMOperUnplace

           

            '# Works for Variant

            oVMCompModification = VmDoc.PutComponentModification(oVmVariant, oVMComponent, eChangeOper)

            '# gives Error / returns no modified object

            'oVMCompModification = VmDoc.PutComponentModification(vmFunc, oVMComponent, eChangeOper)

        Else

            eChangeOper = MGCVARIANTGUI.EVMOperation.eVMOperReplace

 

            '# Works for Variant

            oVMCompModification = VmDoc.PutComponentModification(oVmVariant, oVMComponent, eChangeOper, newPn) ' 2 = replace

            '# gives Error / returns no modified object

           'oVMCompModification = VmDoc.PutComponentModification(vmFunc, oVMComponent, eChangeOper, newPn) ' 2 = replace

        End If

 

        If oVMCompModification Is Nothing Then

           MsgBox("No Modification applied")

        Else

 

        End If

              

               return 0

 

    End Function

Outcomes