QQ登录

只需一步,快速开始

登录 | 注册 | 找回密码

三维网

 找回密码
 注册

QQ登录

只需一步,快速开始

展开

通知     

查看: 1341|回复: 3
收起左侧

[讨论] 为什么材料明细表的数量会出现零值?

[复制链接]
发表于 2015-8-31 09:59:10 | 显示全部楼层 |阅读模式 来自: 中国甘肃兰州

马上注册,结识高手,享用更多资源,轻松玩转三维网社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x
在材料明细表中,产生零值的原因是什么?
% t$ u3 A! Z/ L+ O- {6 M7 g2 ]+ p
! ^# Z3 z$ @1 |4 c8 a3 Z 1.jpg 6 w! H2 V+ C3 d. s4 E% @
\
% [% i( n, v# r% ^9 \
; m. m  Y) c, D  L+ _2 R& ]5 i7 n1 P$ n2 Z' j
3 V& @9 x) j( d8 D2 U% l

* [1 q: S3 a) d; N* D5 G+ ?
 楼主| 发表于 2015-8-31 13:50:05 | 显示全部楼层 来自: 中国甘肃兰州
本帖最后由 ning84 于 2015-8-31 14:09 编辑
9 Q/ `* R0 L. x! i& N' t6 t" l8 r; I. u
与版本没有任何关系。Sw2013照样也出现同样问题。( Y5 L9 F. a! V# y1 P
出现这个问题的原因是运行了这段API程序9 M* x9 Z5 Z: R' M8 ^7 j$ l
, R/ d+ y6 d9 m6 l3 R( z

  1. " D3 C/ p3 R- A  H  n! T
  2. Private Sub proceBom()
    4 u! u$ _6 L5 g4 r6 N1 Q% f+ c
  3.    Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2" W8 O% c7 J3 h
  4.       Set SwApp = Application.SldWorks4 c5 ~' D$ V* E/ C4 j/ w
  5.       Set SwModel = SwApp.ActiveDoc
    . t7 K4 ~/ E- C" P/ Q( |' P; ?
  6.    Dim SwDraw As DrawingDoc, SwView As View
    5 j$ r! S. L0 y9 |' K
  7.       Set SwDraw = SwModel
    ' n2 c  x3 w- }3 _  }' X" a
  8.       Set SwView = SwDraw.GetFirstView
    5 G2 b* k- E; M7 f
  9.       Set SwView = SwView.GetNextView( a6 c% D* D7 Q% Q4 D
  10.    Dim ConfName& T" t# I/ Z9 l7 J" z$ `; e- H
  11.       ConfName = SwView.ReferencedConfiguration
      a' V- A+ l, C+ f
  12.       Set SwView = SwView.GetNextView! I2 ~5 e9 o% x0 Q; K9 ]) G* Z  F
  13.       SwView.ReferencedConfiguration = ConfName
    2 h2 [' Q' G/ n# I3 E
  14.       Debug.Print SwView.Name$ Y6 f6 L% ?* L4 Y; j
  15.       
    & q& W: ]2 W: q
  16.    Dim SwSelMgr As SelectionMgr, Names
    ! t2 w# h8 L3 F6 s: [' L
  17.       Set SwSelMgr = SwModel.SelectionManager1 B# D8 v  h# E0 P% S
  18.    Dim SwFeat As Feature, SwBomFeat As BomFeature, tmp3 O7 j! V- L% u& O! D3 I. I; m
  19.       tmp = SwModel.Extension.SelectByID2("VesselBOM", "BOMFEATURE", 0, 0, 0, False, 0, Nothing, 0)* O6 ~& ^! ?8 U' a5 c% F
  20.       'tmp = SwModel.Extension.SelectByID2("SaddleFBOM", "BOMFEATURE", 0, 0, 0, False, 0, Nothing, 0)
    , N! g- f. \5 n0 m& P
  21.       'tmp = SwModel.Extension.SelectByID2("SaddleSBOM", "BOMFEATURE", 0, 0, 0, False, 0, Nothing, 0)
    $ N# Y7 W8 S% D6 T% o
  22.       Set SwBomFeat = SwSelMgr.GetSelectedObject5(1)" N2 z# H' @4 R7 B4 L# z) P& G
  23.       Set SwFeat = SwBomFeat.GetFeature. ~5 P% u# m* M% `
  24.       ''
    0 f( V+ }3 v4 u1 w1 g8 J
  25.       Names = SwBomFeat.GetConfigurations(False, Visible)3 J" S7 l# K7 }
  26.       For jj = 0 To UBound(Names). V" {1 R5 f- p
  27.          If Names(jj) = ConfName Then 'SwView.ReferencedConfiguration Then* y9 L3 P2 N2 k8 g& s2 {
  28.             Visible(jj) = True* ~5 Z+ D. j& T6 e" i
  29.             Exit For6 `. q. u$ t4 w$ Q; G. H" s$ R
  30.          End If
    + ~! x1 D6 t2 U2 d; C5 Z0 N2 p
  31.       Next jj
    , n! K/ Z  e1 h( K5 `
  32.       ''
    7 K% [* \- c6 a2 F; i' k6 I
  33.       BoolStatus = SwBomFeat.SetConfigurations(False, Visible, Names)
    $ P/ [9 Y1 q+ L
  34.    Dim SwTabAnn As TableAnnotation
    1 c5 O$ q+ G, b
  35.       Set SwTabAnn = SwBomFeat.GetTableAnnotations(0)( ^+ f0 ], B; U8 t: s! [! X
  36.       BomTitle SwTabAnn
    7 H/ T1 I7 A* d) `+ L( p
  37.       
    % L& s9 R3 n- y8 ?2 E" k
  38. End Sub
    - |8 Z, w3 k5 f8 {* C) K- {

  39. * K( }# O- m& ^' n0 J$ w+ l
  40. ''3 u0 g$ ?/ s+ J: h( m1 e$ V
  41. Function BomTitle(SwTabAnn As TableAnnotation), o  I% Q$ C8 Q3 @+ H4 \2 I6 ^5 B4 H# N
  42.    Dim cArr, Arr
    2 \  z- _' T# x9 J$ O7 |
  43.        'cArr = Array("序号", "标 准 号", "名        称", "数量", "材  料", "模型质量", "小计①", "下 料 尺 寸", "下料质量", "小计②", "②-①")
    " m4 N0 d0 T# f$ s& V1 }
  44.        'cArr = Array("序号", "标 准 号", "名        称", "数量", "材  料", " ⑴", "①", "下 料 尺 寸", " ⑵", "②", "②-①")# E4 e5 q$ F$ @+ O  I# B2 O
  45.        cArr = Array("序号", "图号或标准号", "名        称", "数量", "材  料", " ⑴", "⑵", "下 料 尺 寸", " ①", "②", "②-⑵")
    , R5 [8 c) K- f8 y: G$ C
  46.        Arr = Array("序号", "图号", "名称", "数量", "材料", "质量", "", "下料尺寸", "下料质量", "", "")( H0 w7 P7 l( S, M: _9 \( p) G: R
  47.    Dim wArr$ @' y. l( c6 F' u( j8 O+ q
  48.        'wArr = Array(8, 20, 50, 8, 25, 12, 12, 40, 12, 12, 11)* N& ?: R% o. t0 B; e+ N, M/ g
  49.        wArr = Array(8, 17, 45, 8, 18, 10, 10, 35, 10, 10, 9); m( n5 i+ N- x. `
  50.   Dim TextFormat As TextFormat& e0 R* B0 r( d
  51.       With SwTabAnn
    7 d2 u5 q' P0 e- J- B
  52.          ''
    . V' F) O% h$ G2 y5 O8 n' r( e9 x/ E
  53.          For jj = 0 To .ColumnCount - 2! i  I, m3 O  N( g, e
  54.             .SetColumnTitle jj, cArr(jj)
    ) E# F% A$ ~6 {1 f0 y7 t
  55.             .SetColumnWidth jj, wArr(jj) / 1000, 0/ g- G) @* r/ R( h+ W
  56.             .SetColumnCustomProperty jj, Arr(jj)- T) G  `3 r8 d/ @
  57.          Next jj  u, p# c6 J7 a/ m- w5 t
  58.          ''
    & E) N1 ]. W# d5 z
  59.          For ii = 0 To .RowCount - 25 O1 v4 q& \9 A, d2 Q& p
  60.              For jj = 0 To .ColumnCount - 1$ m1 v5 H& J( r7 t* t; h; Z% e
  61.                Select Case jj
    7 P  q: o9 C5 t
  62.                   Case 2  _8 L0 q5 m; s
  63.                      .Text(ii, jj) = " " & Trim(.Text(ii, 2))/ t7 R/ F3 a3 \# g& l+ i9 H! Q  a
  64.                      .CellTextHorizontalJustification(ii, jj) = swTextJustificationLeft: H" X# ^0 Q# r7 w! p
  65.                   Case Else
    ; z; M" n+ U# m/ Z1 f+ V( ^: b3 j9 B
  66.                      .CellTextHorizontalJustification(ii, jj) = swTextJustificationCenter& `- t4 d2 S8 E5 J" p( K) S5 k
  67.                End Select4 u7 Z3 U8 I- n1 k" p* J) h
  68.                ''' J5 w/ x6 \/ M4 g
  69.                Set TextFormat = .GetCellTextFormat(ii, jj)8 b" r% H& m  E6 e& r% s& f, ~4 l  E
  70.                With TextFormat6 b7 L6 n9 W( X9 s( x2 ?: e7 g
  71.                   .CharHeight = 2.8 / 1000
    % G9 d, k: }$ a& T- H/ h7 u+ @
  72.                   .WidthFactor = 0.8
    ) n8 `# y/ I, ]$ @& }4 K. \5 o
  73.                   .TypeFaceName = "宋体"
    2 L. U! a6 J) q1 _" d' q
  74.                   If ii = SwTabAnn.RowCount - 1 Then
    ( s3 ]) `# z5 B& z! _; k0 Y% C/ K
  75.                      .Bold = True
    2 r+ h# M1 {) w+ |7 i
  76.                   Else
    , E: ]$ }7 i9 y0 H+ S1 z
  77.                      .Bold = False6 ?9 A8 k; r% i# t0 o
  78.                   End If% z; M4 P* w+ c
  79.                End With
    1 B( ~0 x8 L3 Z
  80.                .SetCellTextFormat .RowCount - 1, jj, False, TextFormat5 P; |  e2 b5 v0 U2 e0 a
  81.              Next jj/ ~1 A- k9 c% `1 L4 E
  82.              ''
    2 m( r7 s7 M" B9 L
  83.            If .Text(ii, 3) <> "-" Then
    4 R) R7 j: S7 \) w
  84.              If .Text(ii, 3) = 1 Then5 m) u& ?( K+ u8 L& N* d
  85.                   If Val(.Text(ii, 5)) > 0 Then' O/ ^3 k. y% k3 m5 x3 i
  86.                      .Text(ii, 6) = Format(.Text(ii, 5), "0.0#")
    7 M; E8 I0 x+ U4 Y  m5 E% r
  87.                      .Text(ii, 5) = " " 'Format(.Text(ii, 5), "0.0#")
    $ ~- E4 L# _4 @/ b' L2 k
  88.                   End If: @  [# ]/ C) ?3 W3 K
  89.                   ''
    % t: c7 S2 |" r, S4 y$ g6 W
  90.                   If Val(.Text(ii, 8)) > 0 Then
    , Z1 x$ ]5 [# y0 G' t3 j) P
  91.                      .Text(ii, 9) = Format(.Text(ii, 8), "0.0#")
    5 r. U" l/ P( F* m; Y+ {6 Q
  92.                      .Text(ii, 8) = " " 'Format(.Text(ii, 8), "0.0#")5 F+ f6 i( U- D; y  h. A* G) W
  93.                   End If8 U; Q6 O; a& `, U5 g- g/ H
  94.              Else4 B, X! {$ c4 |) A1 n
  95.                  .Text(ii, 5) = Format(.Text(ii, 5), "0.0#")
    , D) A# @0 ]# E: i" U: W  ~
  96.                  .Text(ii, 8) = Format(.Text(ii, 8), "0.0#")
      G1 I: n; J7 O8 |9 g: ~1 p
  97.                  .Text(ii, 6) = Format(.Text(ii, 5) * .Text(ii, 3), "0.0#")6 u1 ?: ]( ?& e7 \1 L8 X
  98.                  .Text(ii, 9) = Format(.Text(ii, 8) * .Text(ii, 3), "0.0#")
    / C- o- `3 w$ H& [9 H0 s
  99.              End If
    2 N$ E, J. f6 Y. N4 N9 b6 C1 t
  100.              If .Text(ii, 7) <> "" And Val(.Text(ii, 9)) > 0 Then2 n4 {9 ?4 R) i" H/ {2 K# Q
  101.                  .Text(ii, 10) = Format(Val(.Text(ii, 9)) - Val(.Text(ii, 6)), "0")8 d+ H8 Q7 m) P  F- Q. A
  102.              Else1 g' v6 ~' D' \1 [- v
  103.                  .Text(ii, 8) = " "8 b. S% t' {, l' [) Z
  104.                  .Text(ii, 9) = " "/ J. @/ L/ ~4 d
  105.              End If
    1 L) b* f. a$ i. w! K
  106.            End If
    / U, j6 _" i5 V2 J3 |$ T6 A3 U4 n' W
  107.          Next ii
    $ m' |0 @+ g7 Y- V2 [! f8 p
  108.          ''
    : [4 t1 S5 \* i+ F
  109.          For ii = 0 To .RowCount - 1
    5 N. f1 |3 G& \- _9 A+ i5 Q# _
  110.              .SetRowHeight ii, 5 / 1000, 0. u7 Y' b, D$ l! `5 y- Q* ^
  111.          Next ii, m" a, k4 i  T( g4 T0 o0 r
  112.          ''
    . S; X  s6 D# M4 H+ g1 X1 }
  113.       End With% K$ B" q: U* H2 \8 |- b
  114.       " X8 f1 Z' U9 S, s2 d; F4 A
  115. End Function' x6 |6 M/ l' u! Y8 h7 w

  116. 0 q+ {# c2 R8 T- t& r

  117. - d2 V& {" N3 b! R
复制代码
& w, p: \; i# z9 J& k- a9 S

8 X4 R) v( S) d0 @$ H) T0 H* _0 `; u( e
 楼主| 发表于 2015-8-31 14:21:23 | 显示全部楼层 来自: 中国甘肃兰州
原材料明细表没问题' S7 _  q3 R  K5 i
0.jpg 7 S. q7 s. w; p- g1 M! s8 F

* i) @- K5 ]' a" l% I+ B运行API后出现问题: h, F) V  u5 k( D' L) I2 w
1 [* z$ k7 ^$ R7 A. W7 D
1.jpg
+ n- [5 W8 Y, l) ?6 s1 q% `+ i+ Z. c. F  A1 C7 R
发表于 2015-8-31 16:16:07 | 显示全部楼层 来自: 中国北京
我们还出现过负值和小数,代理商已经把问题发SW美国总部,以后就再没消息了
发表回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则


Licensed Copyright © 2016-2020 http://www.3dportal.cn/ All Rights Reserved 京 ICP备13008828号

小黑屋|手机版|Archiver|三维网 ( 京ICP备2023026364号-1 )

快速回复 返回顶部 返回列表