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

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

[复制链接]

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

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

admin 楼主

2013-11-4 12:06:33

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

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

x
NX二次开发源码分享:NXOpen C++创建圆柱体特征
* K( P; E& A; n; f

  1. " b; U( _" T% p7 @* ^; h
  2. <P> </P>
复制代码

  1. " b! m2 h: ^6 X; i: K: m4 j
  2. <P>void CreateCylinder_UsingUDB::CreateCylinder()
    ( Y7 s! q/ o- u9 H% C8 e
  3. {# p! X2 ]) {) i0 Q$ I
  4. Part* workPart(theSession->Parts()->Work());</P>; i: Y: H  ^: e) M2 O+ H8 I+ r- c# {
  5. <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;! p% ~; T, K  J$ b
  6. cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
    ' O5 V/ F1 T0 l4 D6 q
  7. <P>//Get the point- Q( E7 S6 y' f
  8. PropertyList* pointPropertyList = point0->GetProperties();
    # j- I9 Z" g; z. f. W
  9. Point3d originPoint = pointPropertyList->GetPoint("Point");
    ! L2 I: Y) k* u9 s1 J# s; C
  10. delete pointPropertyList;1 T' Q& h2 M* C. ]
  11. pointPropertyList = NULL;</P>
    3 @- Z" A4 L$ N$ s5 e4 T( Y
  12. <P>//Get the direction
    # R* E: B# V: K7 l) q$ ^
  13. PropertyList* vectorPropertyList = vector0->GetProperties();5 J* D, n+ z9 Y$ E9 C4 n9 b: B
  14. Vector3d direction = vectorPropertyList->GetVector("Vector");1 G% f! {6 p" X4 \# F
  15. delete vectorPropertyList;. e/ E% T; o( ^0 p% I
  16. vectorPropertyList = NULL;</P>! O4 k; J. l( w6 t7 {4 j' O# y
  17. <P>Direction* direction1 = NULL;
    ! t& `, d' a1 r: q7 n, U6 z3 ?* W# d
  18. direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
    + g) E5 R$ ^) R1 \$ M
  19. <P>//Set diameter and height
    ( H4 i7 P) p* M( j
  20. std::stringstream diameterValue;7 X5 a: I" C6 z- |. S
  21. diameterValue << diameter->GetValue();9 K# _! `& l7 O0 R
  22. std::stringstream heightValue;3 r3 Y! {# i- V/ R) s
  23. heightValue << height->GetValue();</P>5 W1 l* H. v( n. Z& j% q" J0 U
  24. <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
    " ^( a, S$ D' M% p4 {
  25. cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
    8 I% v% K& X8 W; C4 p) ~
  26. <P>//Set the axis% r0 c& i& }: `- y3 _( T5 X+ f0 q
  27. Axis* axis1 = NULL;+ f/ Z/ T2 L# D6 a( C
  28. axis1 = cylinderBuilder1->Axis();
    ; x% ~& I% S  w7 b6 _, H
  29. axis1->Point()->SeTCoordinates(originPoint);  m0 r4 J3 K( l9 m3 H# m* F6 N- b
  30. axis1->SetDirection(direction1);</P>
    6 Z/ A/ ^$ x  }
  31. <P>//Commit6 U% J* o0 d7 b# c$ g
  32. cylinderBuilder1->Commit();
    ( _+ h. S  F; D$ A% V
  33. cylinderBuilder1->Destroy();5 W4 W: Q3 D1 y: h% y0 w
  34. cylinderBuilder1 = NULL;8 Q' ~- r6 ?. ?+ @) u. E- ]* K
  35. }
    2 F) D* x; A! ?3 E
  36. </P>
复制代码

. l8 e- Z/ b, k  [
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了