查看: 4262|回复: 0

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

[复制链接]

2477

主题

1280

回帖

8万

积分

管理员

PLM之家站长

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

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

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

×
NX二次开发源码分享:NXOpen C++创建圆柱体特征
+ \( h. l7 I& F5 R/ [  ?2 t3 U$ I4 z! J
  1. $ H1 J9 C# [  |& J7 E7 `5 z( g
  2. <P> </P>
复制代码

  1. ' ]( \: f8 }/ w9 h0 _' }
  2. <P>void CreateCylinder_UsingUDB::CreateCylinder()# C# J. t3 m& B- {. d
  3. {7 I& y6 B2 S! m' K* f
  4. Part* workPart(theSession->Parts()->Work());</P>
    5 B0 h$ [+ `' m. ]+ l3 V3 T0 e: C
  5. <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;2 ^% L6 n* K9 i8 C1 r+ g
  6. cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
    3 j2 m  Q$ y# a. l$ O; e- g" ]
  7. <P>//Get the point# p) l- k: T7 M1 U* N  f; m. |7 T
  8. PropertyList* pointPropertyList = point0->GetProperties();
    5 O+ ?- e4 f3 A8 l3 w( L7 n
  9. Point3d originPoint = pointPropertyList->GetPoint("Point");3 r$ t" U! ^( i: ]7 v
  10. delete pointPropertyList;
    / z  U1 ?/ n6 ~' B. h
  11. pointPropertyList = NULL;</P>: k& h8 r6 c6 G
  12. <P>//Get the direction
    7 r7 M  B5 Y4 K$ G* p  j2 l
  13. PropertyList* vectorPropertyList = vector0->GetProperties();& |- B- e& H& l7 v* S
  14. Vector3d direction = vectorPropertyList->GetVector("Vector");
    / I6 p, O; C8 Z: E0 j9 p6 X: Y
  15. delete vectorPropertyList;
    - I, V3 {7 o7 a+ u1 @6 A
  16. vectorPropertyList = NULL;</P>- O1 T; F% w* k6 Y0 y
  17. <P>Direction* direction1 = NULL;  Q! W1 @% P2 U+ K, u- R4 g) z& l# G
  18. direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
    & R* d+ x+ J/ [+ d" m$ N9 f
  19. <P>//Set diameter and height
    3 i$ k, I, g4 _. h
  20. std::stringstream diameterValue;
    / ]: ]7 \# z( o9 Q# t$ z
  21. diameterValue << diameter->GetValue();
    1 R3 y: J3 w. L! _7 F( x! h8 G+ D
  22. std::stringstream heightValue;
    2 q% D( M: s9 V2 O/ R$ M2 |
  23. heightValue << height->GetValue();</P>) M5 B1 j% x6 n1 r6 i; B
  24. <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());
      Z6 x/ ]& _4 m+ x
  25. cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>
    ; N+ Q- Y# ]. L# T5 r! s/ K9 n
  26. <P>//Set the axis
    $ m% Z" x, L1 u9 _6 |
  27. Axis* axis1 = NULL;
    6 Y; h% L  w  H1 |; z
  28. axis1 = cylinderBuilder1->Axis();) I# w6 q6 f: s- v$ s; b- I5 @
  29. axis1->Point()->SeTCoordinates(originPoint);8 M$ U8 q5 u, k( }; A3 n
  30. axis1->SetDirection(direction1);</P>. |3 h7 [* z/ Y+ y+ c- v  k
  31. <P>//Commit" c4 K  M' p% c
  32. cylinderBuilder1->Commit();1 b. Y: G+ V" N
  33. cylinderBuilder1->Destroy();
    9 B# {& J: E+ E% N% u7 Y
  34. cylinderBuilder1 = NULL;
    ; g7 W7 m0 c' Z9 x1 Q" n
  35. }
    ) \& `  B0 R1 g) |" r" [4 y0 X0 ]
  36. </P>
复制代码
' u  y. ]% E0 \# O
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

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

本版积分规则

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