PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

小新 楼主

2014-5-8 15:55:39

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

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

x
本帖最后由 小新 于 2014-5-8 16:10 编辑 4 m) R0 w' Y, [) n% L5 z  M

+ l' \$ {1 V7 ^" G5 ]9 A2 i录制装配过程的JA,经过对录制的代码进行简化删减后,如下,经编译后能够实现自动化装配。
  1. Session *theSession = Session::GetSession();
    2 p1 k6 e, H' S/ B# h$ P
  2.     Part *workPart(theSession->Parts()->Work());
    , a  V7 i- B' d" Y5 u9 r
  3.     Part *displayPart(theSession->Parts()->Display());0 s9 ~! j; [1 n, U( y( }( r% J
  4.             # c6 \) S: k8 ?/ r9 x
  5.     BasePart *basePart1;/ p8 m# X/ o& o% M1 N% S
  6.     PartLoadStatus *partLoadStatus1;
    * D) z. X6 O( P+ g* w4 q5 L
  7.     basePart1 = theSession->Parts()->OpenBase("D:\\sy\\model4.prt", &partLoadStatus1);
    2 l6 w5 w2 j* s8 G. j. `$ w! m
  8.     delete partLoadStatus1;: c' o" L: }$ t" j- a
  9.    
    ' m  l1 {. y# k
  10.     Point3d basePoint1(0.0, 0.0, 0.0);
    0 u0 p7 s4 P' T1 ?: F
  11.     Matrix3x3 orientation1;
    2 j5 @/ u# A8 u8 h% z
  12.     orientation1.Xx = 1.0;    orientation1.Xy = 0.0;    orientation1.Xz = 0.0;
    # }7 n9 H8 N# a$ @
  13.     orientation1.Yx = 0.0;    orientation1.Yy = 1.0;    orientation1.Yz = 0.0;9 j( C. O' u8 J- K( Y& Z* G
  14.     orientation1.Zx = 0.0;    orientation1.Zy = 0.0;    orientation1.Zz = 1.0;
    3 W: y/ e0 z* b4 J
  15.     PartLoadStatus *partLoadStatus2;
    . Z* e) p, I! s8 v& c
  16.     Assemblies::Component *component1;' L6 N8 H, H- i9 A
  17.     component1 = workPart->ComponentAssembly()->AddComponent("D:\\sy\\model4.prt", "MODEL", "MODEL4", basePoint1, orientation1, -1, &partLoadStatus2, true);//添加组件- h$ |7 j. z$ a3 c/ d& {
  18.    delete partLoadStatus2;  4 F$ ^, D6 H: }# U3 p+ l
  19.     * o5 O- y) v+ F& A; V
  20.     BasePart *basePart2;
    $ G0 p1 u, c2 Q2 I: \" G) W$ e) y
  21.     PartLoadStatus *partLoadStatus3;+ R# ]8 ^# ^0 E8 f
  22.     basePart2 = theSession->Parts()->OpenBase("D:\\sy\\model5.prt", &partLoadStatus3);    / O- q* q& ?, m' U  d$ r: D
  23.     delete partLoadStatus3;    5 a3 b! P. {; k0 v( W
  24.     , d2 \' I. Z: V& V
  25.     Point3d basePoint2(0.0, 0.0, 0.0);7 h1 {: ]1 J# G3 i
  26.     Matrix3x3 orientation2;: S" h0 l7 w- C4 ?6 \2 g% b
  27.     orientation2.Xx = 1.0;    orientation2.Xy = 0.0;    orientation2.Xz = 0.0;& R2 n2 z3 J) n/ ?; H
  28.     orientation2.Yx = 0.0;    orientation2.Yy = 1.0;    orientation2.Yz = 0.0;
    7 k# k2 I/ w/ b3 d  R" M* Y8 d
  29.     orientation2.Zx = 0.0;    orientation2.Zy = 0.0;    orientation2.Zz = 1.0;; K3 E7 \- }# U0 ^
  30.     PartLoadStatus *partLoadStatus4;
    6 l; Q: V& e7 {5 f# f6 T$ Z7 F
  31.     Assemblies::Component *component2;# T9 Q9 s7 V1 N  @. a3 {
  32.     component2 = workPart->ComponentAssembly()->AddComponent("D:\\sy\\model5.prt", "MODEL", "MODEL5", basePoint2, orientation2, -1, &partLoadStatus4, true);//添加组件
    2 Z$ v" N0 i  v
  33.    delete partLoadStatus4;  $ z6 S$ ^9 ~' B* a3 B) n
  34.     " n# }: m, P7 ]. H) J2 e
  35.     Positioning::ComponentPositioner *componentPositioner1;  @. Z% }" M- c8 E
  36.     componentPositioner1 = workPart->ComponentAssembly()->Positioner();     
    " |+ C9 s8 ]0 w6 \- l3 z
  37.     componentPositioner1->BeginAssemblyConstraints();        y9 p: A- e  S+ v- T# y' L* M
  38.       L7 V" s8 {, w! B  J
  39.     Positioning::Network *network1;
    7 r& S8 P8 r) C' z8 p: Z8 G
  40.     network1 = componentPositioner1->EstablishNetwork();   
    7 y8 z" h. a6 P
  41.     Positioning::ComponentNetwork *componentNetwork1(dynamic_cast<Positioning::ComponentNetwork *>(network1));
    + v0 {! A  F# q( O" N
  42.     componentNetwork1->SetMoveObjectsState(true);              ( v' N  l0 c, ~; b
  43.    
    * K: z- x  O* x' v3 Z% U
  44.     Positioning::Constraint *constraint1;" |. J7 ?5 P: Y/ ?
  45.     constraint1 = componentPositioner1->CreateConstraint(true);
    7 G( P4 P3 ~* h- ?
  46.     * {1 d+ [3 B* K% n4 w  B
  47.     Positioning::ComponenTConstraint *componentConstraint1(dynamic_cast<Positioning::ComponentConstraint *>(constraint1));
    ! r* x. a( k; A. e' c  J. f& t  w7 l
  48.     componentConstraint1->SetConstraintAlignment(Positioning::Constraint::AlignmentContraAlign);    8 C1 S& L6 Z; \% ~4 l
  49.     componentConstraint1->SetConstraintType(Positioning::Constraint::TypeTouch);3 E% E7 s& \" v
  50.     1 y: V4 Y- U1 c" y2 Z
  51.     Face *face1(dynamic_cast<Face *>(component2->FindObject("PROTO#.Features|BLOCK(1)|FACE 6 {(500,25,25) BLOCK(1)}")));          `# P* l$ b- {* ?6 `8 K, l- z
  52.     Positioning::ConstraintReference *constraintReference1;
复制代码
但是出现了一个问题,在上述代码中,进行装配的面是通过FindObject来找到的,不是我想要的那个面,而且FindObject函数参数是一个JA标识符,我无法给某个面定义JA标示符。如果我在建立模型时,我给某个面命名为FACE1。那么我如何找到我想要的面FACE1,然后用于代码5 H/ m! M& G' O& Q4 ^: r
  1. constraintReference1 = componentConstraint1->CreateConstraintReference(component2, face1, false, false, false);
复制代码
其中上述代码中第二参数类型是NXObject *,也无法通过Ufun函数的UF_OBJ_cycle_by_name找到,因为该函数找到是FACE1面的tag,返回的类型不是NXObject *。
! a2 P, E9 c9 j, c6 M问题:/ |* K+ ]! _/ M  @2 g5 L
1)C++中是否有某个方法通过某个对象的tag返回其NXObject *类型
5 [9 o+ ~: A5 g2)C++是否有某个类中的方法可以找到occurrence中的面(CreateConstraintReference需要的是occurrence的对象),而且返回的是NXObject *类型对象,可以直接用于CreateConstraintReference()方法。
1 h4 e% B; v0 `* \
$ p% F$ X. @) m- y
上海点团信息科技有限公司,承接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& p0 N) T/ x1 {: {8 K) U0 I
1 H- z3 M! t% e: X: G! k0 |4 N
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了