Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

how to replace the component in assembly

prasad290

New member
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.
 

Sponsor

Articles From 3DCAD World

Back
Top