机械社区

 找回密码
 注册会员

QQ登录

只需一步,快速开始

搜索
查看: 2326|回复: 4

依據配置特定屬性之"件號"及"名稱"存檔

[复制链接]
发表于 2018-11-15 13:32:28 | 显示全部楼层 |阅读模式

+ z3 Z  R9 E0 X$ J6 h4 @" a& Y分享在他網的回覆
: y/ d* y. R9 v6 X0 M( m& {, ?
9 c' X6 T; [) V+ G0 @) |7 @/ k1 D5 E  |; t. I9 h4 D; M3 C7 ?
$ `0 r4 _: a( V$ n' J# X" y4 R) Y

/ l6 S) c% n6 O! {4 h! T4 r) J7 l% g5 B8 S9 F& F
  1. ' ************************************************************************************' j" @. }# x, @; r
  2. ' 依據配置特定屬性之"件號"及"名稱"存檔 - macro recorded on 10/30/18 by scliang! l, W* G* u! R4 S9 H4 k# y
  3. ' ************************************************************************************
    . \- @& F; ]; x6 h4 C2 L
  4. 6 F  r6 P+ p5 x- l5 ^/ d
  5.     Dim swApp               As SldWorks.SldWorks' a3 r0 N; K$ h* A; d& C
  6.     Dim swModel             As SldWorks.ModelDoc2
    / D5 h( N* U8 d* x; _$ z# |
  7.     Dim swConfigMgr         As SldWorks.ConfigurationManager
    : k" |; w% j/ }0 i  |# r- n: c
  8.     Dim swConfig            As SldWorks.Configuration: ~$ P3 x. \' p2 y0 p- r; |
  9.     Dim swCustPropMgr       As SldWorks.CustomPropertyManager
    6 A7 G' L& }& ^' ~  g! n7 m/ y
  10.     Dim nNbrProps           As Long
    . j$ t# X- r5 V# ~5 ]4 A
  11.     Dim Part                As Object
    8 U, l. r$ k$ _, y; N* l1 O. g2 Y
  12.     Dim Code_Name(2)        As String, q1 V6 j' a5 w+ l$ r% V/ ?
  13.     Dim valOut              As String' q% K6 P: h: Y: W
  14.     Dim resolvedValOut      As String
    & E& B0 W7 d$ E- K5 R* S: r- \
  15.     Dim longstatus          As Long
    ; t. O  E- y; q
  16. - V% L$ f1 _1 W1 \8 f) S4 M

  17. : q9 {( d9 k& F$ ?/ a) n: [9 f
  18. Sub main()
      j* ~: V* y) q8 N7 S# |

  19. 0 p  |! P: f5 Z+ _4 h
  20.     Set swApp = Application.SldWorks, `7 n$ W- Y; a9 |# f* U
  21.     Set swModel = swApp.ActiveDoc- D) x, y, ~! p% W6 P; T
  22.     Set swConfigMgr = swModel.ConfigurationManager# P, r2 m+ S6 ~$ `( q0 o% _
  23.     Set swConfig = swConfigMgr.ActiveConfiguration% F! {) h- ]' c
  24.     Set swCustPropMgr = swConfig.CustomPropertyManager
    ) n8 R) i; J, R6 c) _- X: G' K
  25.     ' Get the number of custom properties for this configuration1 m/ ^( ]8 t# _" f7 {8 ]
  26.     nNbrProps = swCustPropMgr.Count6 i# G5 _* K1 r* R8 U& P  b: v3 G
  27.     vPropNames = swCustPropMgr.GetNames
    . \5 p* _7 O: ~1 s0 o0 J" p
  28.     For j = 0 To nNbrProps - 1
    ; l# a% K& w, s7 j* N
  29.         swCustPropMgr.Get2 vPropNames(j), valOut, resolvedValOut
    5 v9 o; K  l; d! o5 c
  30.         If vPropNames(j) = "代號" Then Code_Name(0) = valOut4 v& c6 |* K" N4 S8 c
  31.         If vPropNames(j) = "名稱" Then Code_Name(1) = valOut
    1 O2 n7 U/ E2 d/ S
  32.     Next j! g- V2 M: G) V9 s" B6 a
  33.     'Debug.Print "    Name, type, and resolved value of custom property:  " & "代號: " & Code_Name(0) & " ----- " & "名稱:" & Code_Name(1)% X) M9 n: p& c; p+ v3 }0 M3 l3 {
  34.     Path_Name = swApp.ActiveDoc.GetPathName '取得"路徑名稱及擴展名",不管擴展名是否隱藏
    ' k& D' k& l( m( ^3 T
  35.     Path_ = Left(Path_Name, InStrRev(Path_Name, "")) '提出路徑: P; Q" g! z/ g& z0 @
  36.     Set Part = swApp.ActiveDoc
    1 G) v0 j' r2 b% _2 W3 w! `8 j! o; t
  37.     longstatus = Part.SaveAs3(Path_ & Code_Name(0) & " " & Code_Name(1) & ".SLDPRT", 0, 2) '依據配置屬性"件號"及"名稱"存檔
    ( ]/ q& J0 H' Q4 z( i

  38. - D# l: v3 M( A
  39. End Sub$ j4 |/ d  d9 K& |5 ]
复制代码
! ]. a0 p& {1 S( W
1 e( T+ J! z5 _* W: t

本帖子中包含更多资源

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

x

评分

参与人数 1威望 +1 收起 理由
arter_2006 + 1 热心助人,专业精湛!

查看全部评分

回复

使用道具 举报

发表于 2018-11-15 16:15:01 | 显示全部楼层
图号分离?
回复

使用道具 举报

 楼主| 发表于 2018-11-15 20:19:10 | 显示全部楼层
zx65606 发表于 2018-11-15 16:15& b7 U" Q; T! Q+ H
图号分离?

: D0 g7 l: m- N0 q8 v, V非也!如主題名稱.4 I" @( k. M% D8 m; Y

, M# W5 c* K# ?' b" T+ s2 q/ u: W
回复 支持 反对

使用道具 举报

发表于 2018-11-16 22:06:09 | 显示全部楼层
这个动态图楼主用什么软件截取的,求教一下!!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-11-16 23:23:41 | 显示全部楼层
远祥 发表于 2018-11-16 22:06; @7 |; B) Q3 I) D
这个动态图楼主用什么软件截取的,求教一下!!

4 ~7 k: U; t7 KCamtasia Studio 8.0 软件截取的
6 d) M$ ]4 z% ^# r  T* a% l
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

小黑屋|手机版|Archiver|机械社区 ( 京ICP备10217105号-1,京ICP证050210号,浙公网安备33038202004372号 )

GMT+8, 2024-5-29 04:01 , Processed in 0.059884 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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