Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

VB API: replace part in assembly


VB API: replace part in assembly

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.

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.

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 can't find mated component.


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.

woo...thank u ,the model "bolt.prt" can be used correctly "in replaceinstance.asm", but pattern is still incorrect, and i still can not figure it out ...

about the code , in my app, i just used the example code. just changed three arguments:Component Name, Old Instance, New Instance.

could u please send me a repaired model of "replaceinstance.asm"?

and as a fresh bird, may be i expressed my trouble by unclear words, that makes u hard to understand,

thank u for all.

I rebuild the .asm

But I think, that this file will not help to resolve your problem.

Share the row of code, how you passing arguments:Component Name, Old Instance, New Instance.

thank you!

and sorry that replying so late, got some busy days.

i have downloaded the assembly,but it can not be retrieved...

may i have your e-mail? it is hard describe my code here...

Top Tags