PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

小新 楼主

2014-5-8 15:55:39

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

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

x
本帖最后由 小新 于 2014-5-8 16:10 编辑
/ G. G/ e7 J1 t: o: u/ r/ a  ]4 a8 P/ ~6 t4 Q/ ?
录制装配过程的JA,经过对录制的代码进行简化删减后,如下,经编译后能够实现自动化装配。
  1. Session *theSession = Session::GetSession();
    2 Q5 u# A6 o) A  L. ^6 k5 N5 V# I
  2.     Part *workPart(theSession->Parts()->Work());
    # y# M' [; y3 j% m
  3.     Part *displayPart(theSession->Parts()->Display());
    - A0 i; m& G4 f- \6 E' e4 K0 ^0 O
  4.             
    / C* ~+ l; [4 Z9 \, H! I- a* B9 b
  5.     BasePart *basePart1;
    2 ~0 q: c' m) T2 s3 ~* r! Y
  6.     PartLoadStatus *partLoadStatus1;7 T5 p* i+ o* L; ]' F3 V* \
  7.     basePart1 = theSession->Parts()->OpenBase("D:\\sy\\model4.prt", &partLoadStatus1);( l0 O1 A8 D3 F7 k0 ?2 K
  8.     delete partLoadStatus1;
    4 s# f; @5 A+ E: |9 E& d
  9.     : {0 A5 N% Y3 v( y. |
  10.     Point3d basePoint1(0.0, 0.0, 0.0);
    1 o, b4 d- N5 U" u+ o: k% z
  11.     Matrix3x3 orientation1;! G% T  Z3 Y. b) C1 X
  12.     orientation1.Xx = 1.0;    orientation1.Xy = 0.0;    orientation1.Xz = 0.0;
    ; S' ]& F( }+ o% P
  13.     orientation1.Yx = 0.0;    orientation1.Yy = 1.0;    orientation1.Yz = 0.0;; b% g1 o9 S- S& ]
  14.     orientation1.Zx = 0.0;    orientation1.Zy = 0.0;    orientation1.Zz = 1.0;$ R2 Q: @2 Z$ H, S$ s! t
  15.     PartLoadStatus *partLoadStatus2;
    8 K# D$ Q8 n3 p1 F& p; b  f# p
  16.     Assemblies::Component *component1;0 a4 X, X6 B) A7 w9 W. R
  17.     component1 = workPart->ComponentAssembly()->AddComponent("D:\\sy\\model4.prt", "MODEL", "MODEL4", basePoint1, orientation1, -1, &partLoadStatus2, true);//添加组件7 @& w" y, o9 [* c6 R
  18.    delete partLoadStatus2;  0 P$ G. q8 Y1 s, L% f$ V0 A
  19.    
    ! j5 ~) S9 E. u2 ~, M
  20.     BasePart *basePart2;: w( f( \. {4 C, o8 L2 H& k) ^
  21.     PartLoadStatus *partLoadStatus3;
    0 @6 }; _1 U4 n* F! |
  22.     basePart2 = theSession->Parts()->OpenBase("D:\\sy\\model5.prt", &partLoadStatus3);   
    4 r% n1 e; z# c3 C
  23.     delete partLoadStatus3;    1 A! {4 z) H2 l: H' U* G
  24.    
    * i2 a1 ]# L% {% V7 \: r8 P
  25.     Point3d basePoint2(0.0, 0.0, 0.0);
    % s8 n1 r* i( [. e$ }
  26.     Matrix3x3 orientation2;
    6 _7 |& ~7 r! Q& V( O
  27.     orientation2.Xx = 1.0;    orientation2.Xy = 0.0;    orientation2.Xz = 0.0;7 C5 `$ D8 n- N8 I" I; z, S
  28.     orientation2.Yx = 0.0;    orientation2.Yy = 1.0;    orientation2.Yz = 0.0;8 G" I1 \: x8 w9 ?# x0 p" D4 J
  29.     orientation2.Zx = 0.0;    orientation2.Zy = 0.0;    orientation2.Zz = 1.0;6 [+ o. y: n8 w( ?% |# X
  30.     PartLoadStatus *partLoadStatus4;( o0 A" ^/ b) h; f0 s. n7 @6 d
  31.     Assemblies::Component *component2;
    * z7 B+ Q' _) m( V: V) S
  32.     component2 = workPart->ComponentAssembly()->AddComponent("D:\\sy\\model5.prt", "MODEL", "MODEL5", basePoint2, orientation2, -1, &partLoadStatus4, true);//添加组件) M: |3 G/ \' l! _
  33.    delete partLoadStatus4;  % c$ K5 ^3 {8 h2 t$ ~0 q  m4 @% {$ I1 _
  34.    
    8 o2 e+ ^3 ?2 e2 o+ E( X
  35.     Positioning::ComponentPositioner *componentPositioner1;
    . f( W5 e  i8 V) F6 v9 y/ I  x
  36.     componentPositioner1 = workPart->ComponentAssembly()->Positioner();     
    / w1 c* G( A: l
  37.     componentPositioner1->BeginAssemblyConstraints();      $ n: Q( r" J, @* D- M) G7 f: m
  38.     ; A7 i0 Y# O1 x* B/ [- R
  39.     Positioning::Network *network1;
    8 P7 u* v, _6 s! ?
  40.     network1 = componentPositioner1->EstablishNetwork();   
    ( B+ @9 j6 Z2 G/ a, E  J
  41.     Positioning::ComponentNetwork *componentNetwork1(dynamic_cast<Positioning::ComponentNetwork *>(network1));
    / B8 i4 G/ w2 z9 X  t1 {
  42.     componentNetwork1->SetMoveObjectsState(true);              % O) Z: l1 l- R4 C% w. q% q; R
  43.    
    ( y! G8 O. P2 ?' |' A$ \" i
  44.     Positioning::Constraint *constraint1;" O( P, J8 M9 ~1 O3 b! Y
  45.     constraint1 = componentPositioner1->CreateConstraint(true);
    2 t/ q9 O8 @5 {% T
  46.    
    - g0 m' U& ?1 i8 ]" W
  47.     Positioning::ComponenTConstraint *componentConstraint1(dynamic_cast<Positioning::ComponentConstraint *>(constraint1));& ^+ J7 P# D! d: h/ y4 n
  48.     componentConstraint1->SetConstraintAlignment(Positioning::Constraint::AlignmentContraAlign);    2 |$ Q  @8 E$ R+ Y4 _
  49.     componentConstraint1->SetConstraintType(Positioning::Constraint::TypeTouch);0 j, t: c# r1 M( x7 @2 L1 z/ t
  50.    
    & _. w, z4 o- I4 c
  51.     Face *face1(dynamic_cast<Face *>(component2->FindObject("PROTO#.Features|BLOCK(1)|FACE 6 {(500,25,25) BLOCK(1)}")));        
    8 S3 F1 M. Q/ D4 o$ ]1 F# |
  52.     Positioning::ConstraintReference *constraintReference1;
复制代码
但是出现了一个问题,在上述代码中,进行装配的面是通过FindObject来找到的,不是我想要的那个面,而且FindObject函数参数是一个JA标识符,我无法给某个面定义JA标示符。如果我在建立模型时,我给某个面命名为FACE1。那么我如何找到我想要的面FACE1,然后用于代码
9 s& l& Z9 L' `6 j- c8 ^( s. R& Z
  1. constraintReference1 = componentConstraint1->CreateConstraintReference(component2, face1, false, false, false);
复制代码
其中上述代码中第二参数类型是NXObject *,也无法通过Ufun函数的UF_OBJ_cycle_by_name找到,因为该函数找到是FACE1面的tag,返回的类型不是NXObject *。8 A" `; L  x! I" v: n1 A
问题:
- T# D8 B5 X# {2 z# M1)C++中是否有某个方法通过某个对象的tag返回其NXObject *类型
$ V: f0 @! Q' c( X2)C++是否有某个类中的方法可以找到occurrence中的面(CreateConstraintReference需要的是occurrence的对象),而且返回的是NXObject *类型对象,可以直接用于CreateConstraintReference()方法。% h) }" H' a# Q/ L
/ A6 D& ^+ w% Z2 N- P* 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- r7 y  N, `( a' J$ O$ x5 c2 |( a
* ?' K- V$ V; W0 ?; t
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了