查看: 4241|回复: 0

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

[复制链接]

2477

主题

1280

回帖

8万

积分

管理员

PLM之家站长

积分
82265
QQ
发表于 2013-11-4 12:06:33 | 显示全部楼层 |阅读模式

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

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

×
NX二次开发源码分享:NXOpen C++创建圆柱体特征4 v) ^  g9 B: O
  1. " h# L& X1 z" I( }
  2. <P> </P>
复制代码
  1. 4 ]' I5 b8 U3 q) j  C( R* o$ P8 o
  2. <P>void CreateCylinder_UsingUDB::CreateCylinder()
    & o. T0 n: {% |: M8 ]- Q) j
  3. {
    ; x. e" K0 j: Z6 r4 t$ q) d9 V
  4. Part* workPart(theSession->Parts()->Work());</P>
    & I4 c. A6 S2 c& U
  5. <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
    ) d% i: Q$ i2 D$ P- [7 p/ @/ [
  6. cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
    $ j0 H3 q4 F2 Y" R! ]! y
  7. <P>//Get the point0 t3 w" @6 I6 e7 M* p
  8. PropertyList* pointPropertyList = point0->GetProperties();
    4 a. l, z# W8 G# a1 p' W# q4 z
  9. Point3d originPoint = pointPropertyList->GetPoint("Point");% x# W, R2 J! @& ~3 z
  10. delete pointPropertyList;5 n4 f. F& c; b( X  N( d0 y' i
  11. pointPropertyList = NULL;</P>
    : }$ ]1 O7 a( `3 `
  12. <P>//Get the direction
    ) G- m, t* z4 |7 W
  13. PropertyList* vectorPropertyList = vector0->GetProperties();1 M+ I+ Q( R! ~
  14. Vector3d direction = vectorPropertyList->GetVector("Vector");
    / ^8 X2 J/ M3 @7 [5 s4 R9 Z1 E
  15. delete vectorPropertyList;3 s0 w0 b# i6 R% d) h
  16. vectorPropertyList = NULL;</P>3 W$ C1 |7 D* A+ F; b
  17. <P>Direction* direction1 = NULL;
    & l  D/ g# x9 m, R
  18. direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P># d2 Q1 S4 A( T8 E! ]" z5 o# @
  19. <P>//Set diameter and height
    ) {0 V$ Q0 K' A7 k5 ~5 G  _  T. r
  20. std::stringstream diameterValue;+ J' P3 A* Y( E' d2 P5 U
  21. diameterValue << diameter->GetValue();
    + }' P) |& N# I' H' P
  22. std::stringstream heightValue;, g. E9 U# [3 z- h8 ]
  23. heightValue << height->GetValue();</P>
    $ h. k9 P# p$ _  {+ ~
  24. <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
    7 |$ G9 ^: k; t# x
  25. cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>$ m6 X0 e  \0 g# J$ `8 O
  26. <P>//Set the axis+ K& s0 V* N1 J! @; j
  27. Axis* axis1 = NULL;
    2 D$ ]) Y; H7 R
  28. axis1 = cylinderBuilder1->Axis();
    7 f0 l+ F/ ]0 m( U# u9 n/ ?
  29. axis1->Point()->SeTCoordinates(originPoint);8 S' C, |' \  e
  30. axis1->SetDirection(direction1);</P>3 Q! ~9 f. _# {% i, w  e0 ]
  31. <P>//Commit
    ; T" M0 y6 s# J* t- \
  32. cylinderBuilder1->Commit();
    ) B% O" u6 N+ p6 x9 l
  33. cylinderBuilder1->Destroy();
    : @- {; U& ~1 n' t, f9 E0 `
  34. cylinderBuilder1 = NULL;
    3 q5 g) j5 i$ u! K6 l, ?" t
  35. }
    8 |! T% L0 _! u3 K4 N$ _  P# U' V
  36. </P>
复制代码
' k- n' T5 ~, {4 A: Q9 d9 |( h
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

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

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部