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

[二次开发源码] NX二次开发源码分享:NXOpen C++创建圆柱体特征

[复制链接]

2013-11-4 12:06:33 3946 0

admin 发表于 2013-11-4 12:06:33 |阅读模式

admin 楼主

2013-11-4 12:06:33

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

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

x
NX二次开发源码分享:NXOpen C++创建圆柱体特征6 e. a% ~1 G6 L# F$ W0 F- f' a' \

  1. 5 w% U9 X6 _0 e/ K) }! \) M" x
  2. <P> </P>
复制代码

  1. + r5 `3 g/ Z7 c+ ]) [, e
  2. <P>void CreateCylinder_UsingUDB::CreateCylinder()
    1 c/ d; b2 \+ E4 j' ~( P
  3. {* O" l1 A, [' [- E# ^. ]
  4. Part* workPart(theSession->Parts()->Work());</P>
    8 G* N: A* {  V: M
  5. <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
    ' }0 ^7 L3 A; m9 F# }0 `4 [7 \
  6. cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>  t. u* J' x- ?5 w8 z2 s* G) U5 f
  7. <P>//Get the point! U! `: F# }2 b* d4 d- J4 |# ?- d
  8. PropertyList* pointPropertyList = point0->GetProperties();
    + ~; q6 |* F, `5 Z! u& \7 K! C; L
  9. Point3d originPoint = pointPropertyList->GetPoint("Point");
    ) R9 S3 T9 v& u3 u4 q9 [0 y
  10. delete pointPropertyList;
    ; `7 ~- ~! U/ @! j; k5 t
  11. pointPropertyList = NULL;</P>
    ; H. C8 _7 L% o+ W* z2 I) ~4 Q8 S+ w
  12. <P>//Get the direction
    1 r( [& K+ p1 V/ G! H1 m( ]3 m
  13. PropertyList* vectorPropertyList = vector0->GetProperties();8 m9 ]; `8 Y" _$ |
  14. Vector3d direction = vectorPropertyList->GetVector("Vector");
    $ j- ?1 Z$ t& w4 F
  15. delete vectorPropertyList;
    ' i( V' W! b: r9 |
  16. vectorPropertyList = NULL;</P>) ?+ e7 x: s3 X+ @, i
  17. <P>Direction* direction1 = NULL;
    ' }4 L3 B1 ?( Z* r5 R# n! \  w- o
  18. direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
    , P  @- E; p7 \( B3 }# i
  19. <P>//Set diameter and height
    ; ]/ n1 R2 c# X6 B/ W6 }
  20. std::stringstream diameterValue;
    6 c% f2 Y9 X6 Z  G, ]
  21. diameterValue << diameter->GetValue();9 O- L& I8 K6 K2 D1 Y8 t! g8 d
  22. std::stringstream heightValue;/ T+ U" z) N8 @* Y- o
  23. heightValue << height->GetValue();</P>
    : O2 Q1 z$ j. R
  24. <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());% D) q, D0 t" x/ z
  25. cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
    2 O+ k+ B4 S+ a; j! U( x
  26. <P>//Set the axis
    % }" p6 h0 v/ T" X! P; [) d: L
  27. Axis* axis1 = NULL;* _1 [2 m& @, D# n2 V: M
  28. axis1 = cylinderBuilder1->Axis();
    ( W: p5 ?8 g& i' L6 Y
  29. axis1->Point()->SeTCoordinates(originPoint);
    1 X" V& V4 X! H; s& j! _1 J
  30. axis1->SetDirection(direction1);</P>& f3 D5 g6 L6 a/ k& y$ P0 S
  31. <P>//Commit
    " a: X. d, D5 q* a# U; W
  32. cylinderBuilder1->Commit();
    # ~. v4 V+ S, C
  33. cylinderBuilder1->Destroy();
    " U( d! }5 g2 p# L
  34. cylinderBuilder1 = NULL;' G! |! K& D8 J3 g
  35. }
    : t8 `1 b2 n3 U* k. s
  36. </P>
复制代码

( g- B  G' H: x& M2 G
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了