James Liao

SOLIDWORKS vba Replace replacement parts according to specifications

Discussion created by James Liao on Oct 29, 2020

Is there an example to replace the part syntax to achieve
1. The user executes the macro
2. Enter the specifications in the macro window,
3. The macro program is placed in the designated catalog, and the replacement parts are replaced according to the specifications

for example:
1. The component AA.sldasm is fixed as A_100.sldprt, B_100.sldprt, C_100.sldprt

2. Known parts
A Parts, according to their specifications, are A_100.sldprt, A_200.sldprt, A_300.sldprt.
B parts, according to their specifications, are B_50, B_150, and B_150.
C parts, according to their specifications, are C_20, C_40, C_60, C_80.

3. Open AA.sldasm, execute the macro, enter the specifications, change A to 200, B to 150, and C to 80
4. Through the macro, replace the original parts of AA.sldasm with the following
A_100.sldprt-> A_200.sldprt
B_100.sldprt-> B_150.sldprt
C_100.sldprt-> C_80.sldprt
Is it possible? Are there examples for reference? Thank you all

請問有範例, 取代零件語法達到
3.巨集程式到指定目錄中, 依規格取代更換零件

1. 組件AA.sldasm中固定為A_100.sldprt、B_100.sldprt、C_100.sldprt
2. 已知零件

3.open AA.sldasm, 執行巨集, 輸入規格, A改成200,B改成150,C改成80
4.透過巨集, 將AA.sldasm原本的零件換成如下
A_100.sldprt -> A_200.sldprt
B_100.sldprt -> B_150.sldprt
C_100.sldprt -> C_80.sldprt