|
|

楼主 |
发表于 2013-11-11 06:36:47
|
显示全部楼层
来自: 中国甘肃兰州
本帖最后由 ning84 于 2013-11-12 07:26 编辑 ' v L9 v) J( t8 ~
tangcarlos3d 发表于 2013-11-10 15:52 static/image/common/back.gif6 `& I L5 x$ n) f3 m, L D7 _
Pro/e可以实现多模型视图,但也不能在一个BOM里与多个模型相关,只能在不同的BOM与不同的模型相关。* w# H) c3 O* P8 y
也就 ... SolidWorks Forums: API: Automating and customizing BOM tables (VBA)3 R4 w. h8 r+ T) z, a6 a. F
https://forum.solidworks.com/docs/DOC-1452
0 `. P; Y" f& ?4 n找一段API,表述BOM表的表头内容。目前需要解决的是找到其链接内容与实体链接的API。
( z4 ^; O, {! L# w" V' J6 B# s$ ?6 A% j7 a4 w' a7 c$ t
1 g m7 ~6 l' `# {! C
) B& F2 C* L. {& b& S, l
& V& z0 e; K, Q8 D. K Column(0) =
# b4 |1 P( t& E8 v& ]" ]9 z+ R Column(1) = SW-File Name(File Name)' W! I B/ L) ]. d, S9 |
Column(2) = Description1 S1 R" S! m. f" y8 Y% ~
Column(3) = Weight
7 G3 c3 Q5 H* t Column(4) = $ b3 W1 e! T* J
Column(5) =
5 g! o# Z; b! @# E
. Y& {9 [0 T) n# [( K, P& B$ }% \2 G/ P* J" A4 Q3 Y
下面代码有个问题,不能表述清楚BOM表中的单元内容,是如何链接零件号。- Sub main()
% a% \ A! r) S. F3 U, x- \, F, R - Dim swApp As SldWorks.SldWorks
w3 L \ H7 q6 ?0 X( G& v - Dim swModel As SldWorks.ModelDoc2
5 ? D T/ A7 ^( e& h2 h8 q( ~, Y - Dim swSelMgr As SldWorks.SelectionMgr0 u% @7 d2 M6 ~- _ o
- Dim swBomTable As SldWorks.BomTableAnnotation* n& q) T) j3 t% ~) \
- Dim vCustPropArr As Variant& \3 w9 |) j$ a7 H4 |
- Dim vCustProp As Variant4 y( c* N' G/ N* _$ \* I
- ''
5 E$ F/ k, c- c - Set swApp = Application.SldWorks
: P1 l/ d K5 y# F" U - Set swModel = swApp.ActiveDoc7 F- |3 Y0 {3 @ a. s, p
- Set swSelMgr = swModel.SelectionManager' o1 R" p, c; A4 e7 V; }" d( D1 N
- Set swBomTable = swSelMgr.GetSelectedObject5(1)
% M. y3 O2 h; P3 M+ l( v( B- l - Debug.Print "File = " & swModel.GetPathName
+ c: C; _0 E/ i5 _# { - vCustPropArr = swBomTable.GetAllCustomProperties- [4 g0 L% {% u1 S
- For Each vCustProp In vCustPropArr
; q v7 z; |/ U8 }/ D2 l - Debug.Print " " & vCustProp
( p$ w1 m% z* ]9 w - Next vCustProp S# s W4 p3 P3 T' P Y
- End Sub
复制代码 |
|