PLM之家PLMHome-国产软件践行者

[已解决] 如何查找一个部件对应的occurrence的面

[复制链接]

2014-5-9 10:26:29 3512 1

小新 发表于 2014-5-8 15:55:39 |阅读模式

小新 楼主

2014-5-8 15:55:39

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

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

x
本帖最后由 小新 于 2014-5-8 16:10 编辑 ) }; k8 z% S8 j; t7 W8 P5 |8 M

: c. V9 W7 c7 v  f录制装配过程的JA,经过对录制的代码进行简化删减后,如下,经编译后能够实现自动化装配。
  1. Session *theSession = Session::GetSession();1 P  N. V- e! l5 d: T6 h
  2.     Part *workPart(theSession->Parts()->Work());) R* w7 X, W& a" D! g
  3.     Part *displayPart(theSession->Parts()->Display());
    % t5 c4 H, S6 B
  4.             ; Q; B; k5 Z2 f7 ^
  5.     BasePart *basePart1;# I7 |  y: v' |4 A; l
  6.     PartLoadStatus *partLoadStatus1;( p! |- n& I* P5 c* J
  7.     basePart1 = theSession->Parts()->OpenBase("D:\\sy\\model4.prt", &partLoadStatus1);
    * o1 V! O1 J0 |8 p$ B2 x- H
  8.     delete partLoadStatus1;( Z: _) I) g! \6 O5 A5 k! q- I( R
  9.    
    - j& `2 x% k0 }$ A
  10.     Point3d basePoint1(0.0, 0.0, 0.0);
    $ R: V& a; G; v6 o
  11.     Matrix3x3 orientation1;+ Y+ ?. ^* m/ Q2 l% ]: g# |
  12.     orientation1.Xx = 1.0;    orientation1.Xy = 0.0;    orientation1.Xz = 0.0;
    . `. V" D3 ?2 e/ T6 t( c+ r3 g
  13.     orientation1.Yx = 0.0;    orientation1.Yy = 1.0;    orientation1.Yz = 0.0;
    % [( S4 m# _0 b- X% \* d, c5 Z
  14.     orientation1.Zx = 0.0;    orientation1.Zy = 0.0;    orientation1.Zz = 1.0;3 t4 G  A5 z, z( C  U' B& Z% N, G$ \
  15.     PartLoadStatus *partLoadStatus2;( u2 S/ B- ?- Y7 c
  16.     Assemblies::Component *component1;
    : T% [7 C! O8 q4 v0 a. M
  17.     component1 = workPart->ComponentAssembly()->AddComponent("D:\\sy\\model4.prt", "MODEL", "MODEL4", basePoint1, orientation1, -1, &partLoadStatus2, true);//添加组件
    0 C1 G2 H3 ^5 [* e' X3 C! k
  18.    delete partLoadStatus2;  4 [% `+ y2 _7 x$ {1 R$ x
  19.    
    " }% f6 H' M% {! u# k8 I0 _2 y+ C: Y5 b* A
  20.     BasePart *basePart2;& x7 S0 t  {' M! y( a$ L; B3 @& c
  21.     PartLoadStatus *partLoadStatus3;
    ! q/ P* z0 b8 n6 ]. ~) w# `
  22.     basePart2 = theSession->Parts()->OpenBase("D:\\sy\\model5.prt", &partLoadStatus3);   
    & g" e: }" V6 N4 N
  23.     delete partLoadStatus3;    " ^# k& f; x7 c
  24.    
    2 j/ l9 w! _$ H8 m( ^: S3 K
  25.     Point3d basePoint2(0.0, 0.0, 0.0);* Z" R# \  a/ u3 C; W8 K
  26.     Matrix3x3 orientation2;' _; H) g- w9 \) [  Y
  27.     orientation2.Xx = 1.0;    orientation2.Xy = 0.0;    orientation2.Xz = 0.0;
    . q7 M- t' I/ R+ K4 D3 F& d  V
  28.     orientation2.Yx = 0.0;    orientation2.Yy = 1.0;    orientation2.Yz = 0.0;) R+ w/ A* ~- Q3 N# n: q
  29.     orientation2.Zx = 0.0;    orientation2.Zy = 0.0;    orientation2.Zz = 1.0;
    7 Y/ G- J3 t1 H+ B8 T) S0 o
  30.     PartLoadStatus *partLoadStatus4;" _8 b. s4 R& I" l
  31.     Assemblies::Component *component2;
    3 V8 G' S- O* Z# ^% ]' R
  32.     component2 = workPart->ComponentAssembly()->AddComponent("D:\\sy\\model5.prt", "MODEL", "MODEL5", basePoint2, orientation2, -1, &partLoadStatus4, true);//添加组件) @+ Q+ v2 G6 A3 s7 B
  33.    delete partLoadStatus4;  
    0 F! j! Y2 d. {* G' m# X7 s+ A( |
  34.    
    7 H/ t6 J( `, q/ @( G
  35.     Positioning::ComponentPositioner *componentPositioner1;' h; B& ~. h8 y3 w! a
  36.     componentPositioner1 = workPart->ComponentAssembly()->Positioner();     ( N* c. A* [7 F& P( C6 w
  37.     componentPositioner1->BeginAssemblyConstraints();      
    - \4 Q4 Q6 }% b9 T1 }2 m0 W
  38.    
    & M0 R; `, @$ h4 |6 F
  39.     Positioning::Network *network1;* |7 J2 ^) l# [8 _% K
  40.     network1 = componentPositioner1->EstablishNetwork();   
    ) |/ X. @; P8 j" I  \
  41.     Positioning::ComponentNetwork *componentNetwork1(dynamic_cast<Positioning::ComponentNetwork *>(network1));
    $ v8 w3 h  a* [, g
  42.     componentNetwork1->SetMoveObjectsState(true);              9 y1 w8 i) ?# A% J8 h0 w# a3 N0 L
  43.    
    # U# @: V! J1 K2 u4 q5 p* |9 T
  44.     Positioning::Constraint *constraint1;
      G. _+ t# n1 Y0 f
  45.     constraint1 = componentPositioner1->CreateConstraint(true);
    % ~7 {4 `$ p0 F' a2 T: |
  46.     # o; G4 M+ `; x! j& k! Q. k1 E! g
  47.     Positioning::ComponenTConstraint *componentConstraint1(dynamic_cast<Positioning::ComponentConstraint *>(constraint1));" ~9 A. E. R2 N/ M3 k+ `5 x
  48.     componentConstraint1->SetConstraintAlignment(Positioning::Constraint::AlignmentContraAlign);    ! U/ H9 G6 E7 z) D0 w' N
  49.     componentConstraint1->SetConstraintType(Positioning::Constraint::TypeTouch);* Q2 t- S2 o6 t  t8 [
  50.    
    & b9 U! E, W0 Z. W4 H3 N8 M. Q& z
  51.     Face *face1(dynamic_cast<Face *>(component2->FindObject("PROTO#.Features|BLOCK(1)|FACE 6 {(500,25,25) BLOCK(1)}")));        
    $ h7 T5 _, k* G2 i( Q/ |
  52.     Positioning::ConstraintReference *constraintReference1;
复制代码
但是出现了一个问题,在上述代码中,进行装配的面是通过FindObject来找到的,不是我想要的那个面,而且FindObject函数参数是一个JA标识符,我无法给某个面定义JA标示符。如果我在建立模型时,我给某个面命名为FACE1。那么我如何找到我想要的面FACE1,然后用于代码7 f, e% p7 t* D7 b6 z
  1. constraintReference1 = componentConstraint1->CreateConstraintReference(component2, face1, false, false, false);
复制代码
其中上述代码中第二参数类型是NXObject *,也无法通过Ufun函数的UF_OBJ_cycle_by_name找到,因为该函数找到是FACE1面的tag,返回的类型不是NXObject *。, z' z2 _: e/ s7 V/ ~" E! m
问题:
( N' A6 `' r/ s1)C++中是否有某个方法通过某个对象的tag返回其NXObject *类型
& g& w1 s0 b3 F) c, W: z! }2)C++是否有某个类中的方法可以找到occurrence中的面(CreateConstraintReference需要的是occurrence的对象),而且返回的是NXObject *类型对象,可以直接用于CreateConstraintReference()方法。
. \$ K2 W0 b" ]8 W: D+ `5 P
: P. t0 b, o6 Y) d6 d. I& }
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

全部回复1

admin 发表于 2014-5-9 10:26:29

admin 沙发

2014-5-9 10:26:29

tag 可以通过 NXObjectManager 返回 NXobject- r0 b0 s6 b( ~# s9 Z% O5 ^# Z
; W) m/ Z% F3 _" H4 |" _) p
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复 支持 反对

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了