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
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