Skip to main content
1-Visitor
March 22, 2014
Question

VB API: replace part in assembly

  • March 22, 2014
  • 1 reply
  • 4532 views

hi pro

 

i'm trying to replace part A with part B in an assembly model, via VB API.

 

if any body know how to access this task, could you show me the code? i'll very appreciate you


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

1 reply

1-Visitor
March 23, 2014

Example Code: Replacing Instances

The sample code in the file pfcAssembliesExamples.vb located at <creo_vbapi_loadpoint>/vbapi_examples

contains a single static utility method. This method takes an assembly for an argument. It searches through

the assembly for all components that are instances of the model "bolt". It then replaces all such occurrences

with a different instance of bolt.

1-Visitor
March 24, 2014

thanks a lot!

fact is

i have been play with 'vbapi_examples' for days...but i still can't make it works...

i think this example code is used to replace instance of specified part with its another instance.

so i created an assembly model includes a part with instances A and B,but it still doesn't work, throw an exception when app creating instance of new model.

and unfortunately, the model 'replaceinstance.sam' , use for vbapi_examples, is failed.it can't find mated component.

1-Visitor
March 24, 2014

Hello!

About problem 'replaceinstance.sam'.

The way to resolve this: just create new instance at Family table in bolt.prt

The name of new instance must be: PHILLIPS7_8

It is difficult to find the problem, not seeing the code.

Can you share your code, where you call the method from the example? And the model of part with the family table.