Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
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
Solved! Go to Solution.
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
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
Thanks a lot for that. Will have a good look