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


依規格取代更換零件
請問有範例, 取代零件語法達到
1.使用者執行巨集
2.在巨集視窗中輸入規格,
3.巨集程式到指定目錄中, 依規格取代更換零件

舉例:
1. 組件AA.sldasm中固定為A_100.sldprt、B_100.sldprt、C_100.sldprt
2. 已知零件
A零件,依其規格有A_100.sldprt、A_200.sldprt、A_300.sldprt。
B零件,依其規格有B_50、B_150、B_150。
C零件,依其規格有C_20、C_40、C_60、C_80。

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
謝謝大家

Outcomes