Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to replace the component in assembly

  • Thread starter Thread starter prasad290
  • Start date Start date
P

prasad290

Guest
Hi all,
I am very new to ProE VBAPI customization, Can You
please share me some information regards replace.

I want to replace the unrelated components through
VBAPI,and I tried like this..


<center>model = session.CurrentModel If model Is Nothing
Then Throw New Exception("Model not present") End If If
(Not model.Type = EpfcModelType.EpfcMDL_ASSEMBLY) Then
Throw New Exception("Model is not an assembly") End If
assembly = CType(model, IpfcAssembly)
'========================================================
============== 'Get the model to be replaced
'========================================================
============== oldModel = session.GetModel(modelName,
EpfcModelType.EpfcMDL_PART)
'========================================================
'========================================================

replaceOperations = New CpfcFeatureOperations
'========================================================
============== '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
'========================================================
============== 'Replace the model
'========================================================
==============
assembly.ExecuteFeatureOps(replaceOperations, Nothing)
</center>


While executing the last line I am getting the error in
ProE message window like "fail to replace xx.prt in
xy.asm".

Please suggest me how to avoid this and explain me the
proper steps to replace the unrelated components.

Regards
Prasad
Edited by: prasad290
 
Only Family Table members can be replaced using this option.
You will need to play a trick to do what you want to do.
1. Read references of existing one(assembly refs),
2. delete existing member and to
3. assemble new member use the references u read in first step.
 

Part and Inventory Search

Sponsor

Back
Top