' h2 y- v. r9 X& j0 O凱元肯定有 麥迪應(yīng)該也有吧 ( {; V0 O, L4 N0 ~" R' S' E9 K5 T
1 d* n% G+ q. c# d 作者: 學(xué)者11 時(shí)間: 2025-1-10 12:00
安裝第三方插件:0 g; E# E5 o) ]4 w* P
例如,,使用SolidKits BOMs高級(jí)BOM工具或SWTDO插件。( v4 }. L! s' S* _1 Q- W
下載并安裝插件,,按照插件的安裝指南進(jìn)行操作。- h! u; J0 F- M# ]* K: [
使用插件功能: " d& P0 | f+ |0 x9 @打開(kāi)插件,,選擇“批量寫(xiě)入屬性”功能,。! c! C) y( h6 F" l
選擇需要處理的零件文件或文件夾,設(shè)置需要添加的屬性名稱(chēng)和值,。 9 S' M* x4 ?) N; {0 T) k" Q + P7 H7 c5 ~9 ^2 P% x還有這個(gè)宏命令是AI生成的,,不保證有用。0 u$ k3 d/ `) ~5 O
Dim swApp As SldWorks.SldWorks5 {7 T( W1 {2 ^9 Y" @$ V" Z, [
Dim swModel As SldWorks.ModelDoc2( ]; [) o. B/ b& K7 f
Dim swPart As SldWorks.Part 0 z* F; J. [0 M4 Q- ^Dim massprops As Variant 1 i+ x; G7 s! n* K; dDim status As Long # b; R$ P' y$ FDim length As Double9 E- }+ ?+ g1 M7 W
Dim width As Double' P8 S9 N' s/ w2 e# X6 P
Dim height As Double : P; Y& [8 p/ b6 _: n" V1 A- [+ Y2 G( P8 F' h0 g7 g1 c0 h
Sub main()3 h e5 M' U2 v6 {* x: E3 l1 r
Set swApp = Application.SldWorks/ ]) D: n( ^+ o% s W4 }& m
Set swModel = swApp.ActiveDoc 1 t. K+ j0 i+ d0 i Set swPart = swModel.Part& ^3 a. h# Z6 C
8 r" D& r4 J. p ' 獲取零件的外形尺寸 , `) b0 t& e% S2 d. @) ]2 H$ _ massprops = swPart.GetMassProperties(1, status, True)/ M- U$ T2 e' Q1 }# b! e( t
length = massprops(0); Z" {( }6 c3 e3 f' w+ [) @2 M6 i" G
width = massprops(1) # p' W V, V2 n7 J7 n height = massprops(2)( q* Q: F6 V* \4 f; _: ?& I8 m
4 P1 Z! ]$ T. r8 ~3 s0 F. O3 U ' 添加自定義屬性 2 i1 o; ~# \4 o" n+ h7 S) `2 K swModel.Extension.AddCustomProperty3("長(zhǎng)度", swCustomInfoText, CStr(length), swCustomPropertyReplaceValue)% X+ `. b. L. h9 I5 x5 a1 X
swModel.Extension.AddCustomProperty3("寬度", swCustomInfoText, CStr(width), swCustomPropertyReplaceValue)) G+ l( k3 k9 e; L$ x4 W
swModel.Extension.AddCustomProperty3("高度", swCustomInfoText, CStr(height), swCustomPropertyReplaceValue)/ h1 {6 w' }7 s
@+ g5 n+ h A$ t1 S
' 保存文件+ u' F5 K" [( _6 ~3 Y
swModel.Save * |4 n; G9 ~8 ~" o0 P7 f! hEnd Sub( h( h# B3 F; H; e
點(diǎn)擊“執(zhí)行”按鈕,,開(kāi)始批量處理文件,。作者: tsdt001 時(shí)間: 2025-1-10 12:12
平板類(lèi)的還是鈑金類(lèi)的?作者: 讓心放任去流浪 時(shí)間: 2025-1-10 12:34
用工具箱,?工具箱都有屬性填寫(xiě)等功能作者: 逐夢(mèng)2020 時(shí)間: 2025-1-10 14:35