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

"Macro" to hide part in a .asm based on its name

SOLVED
JXB
Alexandrite

"Macro" to hide part in a .asm based on its name

To all

I am trying to understand the effort required to write a “macro” to automate a task in CREO 5.0. I have code countless simple macros in vba for excel and for the  CAD system I am using – So I ma not a total beginner
What I have in mind

Given the active assembly (.asm)
Loop through each part in the tree
Get the name of the part
 If the name of the part exists in a given list then hide the part
Else do nothing



 

 

Can this be done? Is anyone willing to provide the few lines of code for such task (I am guessing that there are specific Classes, properties , etc ). The list I have in mind will be a

Dim ListofName As New List(of String)

 

 which will contains specific/fixed name

 

Thanks

Regards

1 ACCEPTED SOLUTION

Accepted Solutions

Re: "Macro" to hide part in a .asm based on its name

Check the sample code from Creo installation directory:

Common Files\vbapi\vbapi_examples\pfcAssembliesExamples.vb

 

            '======================================================================
            'Loop through all the components and create replace operations for any
            'instance of the model found
            '======================================================================
            components = assembly.ListFeaturesByType(False, EpfcFeatureType.EpfcFEATTYPE_COMPONENT)
            For i = 0 To components.Count - 1
                component = components.Item(i)
                modelDesc = component.ModelDescr
                If modelDesc.InstanceName = oldInstance Then
                    replace = component.CreateReplaceOp(newModel)                   
                    replaceOperations.Insert(0, replace)
                End If
            Next

View solution in original post

2 REPLIES 2

Re: "Macro" to hide part in a .asm based on its name

Check the sample code from Creo installation directory:

Common Files\vbapi\vbapi_examples\pfcAssembliesExamples.vb

 

            '======================================================================
            'Loop through all the components and create replace operations for any
            'instance of the model found
            '======================================================================
            components = assembly.ListFeaturesByType(False, EpfcFeatureType.EpfcFEATTYPE_COMPONENT)
            For i = 0 To components.Count - 1
                component = components.Item(i)
                modelDesc = component.ModelDescr
                If modelDesc.InstanceName = oldInstance Then
                    replace = component.CreateReplaceOp(newModel)                   
                    replaceOperations.Insert(0, replace)
                End If
            Next

View solution in original post

Re: "Macro" to hide part in a .asm based on its name

Thanks a lot for that. Will have a good look

Announcements