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

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

[复制链接]

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

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

admin 楼主

2013-11-4 12:06:33

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

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

x
NX二次开发源码分享:NXOpen C++创建圆柱体特征! b4 `& r% ?- [9 w9 O- c

  1. ) ?6 D7 E% w7 P1 V0 y9 O2 e
  2. <P> </P>
复制代码

  1. ' A9 P' a( D- q2 A
  2. <P>void CreateCylinder_UsingUDB::CreateCylinder()
    4 r, v: m; i8 H' r  u3 F
  3. {8 H- M  A  `% ]
  4. Part* workPart(theSession->Parts()->Work());</P>6 U; v7 N7 Z8 Q- V
  5. <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
    % Z5 W- z% R# f
  6. cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
    * f* Z4 E! C# u0 u- {! g+ l8 i' N$ i' M
  7. <P>//Get the point
    $ P0 u2 u7 g, ]5 k! r- S( l7 a
  8. PropertyList* pointPropertyList = point0->GetProperties();" T. A2 v( l3 V$ c  @+ Z
  9. Point3d originPoint = pointPropertyList->GetPoint("Point");3 p1 M0 @  G6 g+ e2 \+ D* `9 s
  10. delete pointPropertyList;( t0 e$ C+ @9 ]
  11. pointPropertyList = NULL;</P>
    ' {' o: T5 W0 D  C# D8 A+ e
  12. <P>//Get the direction
    4 [) g  O2 p# z+ \
  13. PropertyList* vectorPropertyList = vector0->GetProperties();5 S( p2 i, ~$ W1 f. M" n
  14. Vector3d direction = vectorPropertyList->GetVector("Vector");! M" }, q- G( t
  15. delete vectorPropertyList;! [3 f& P7 l) }5 B5 ~
  16. vectorPropertyList = NULL;</P>/ o% }. L: k3 H1 B+ [
  17. <P>Direction* direction1 = NULL;9 g; K- t2 b9 A& M- ^% @! A
  18. direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
    % a& u) @+ Y: z9 l- L# T; {! y
  19. <P>//Set diameter and height
    5 \; p. Y# v5 \6 g  g
  20. std::stringstream diameterValue;5 Z. j/ q1 c  A) z
  21. diameterValue << diameter->GetValue();5 \  {% I# B& R7 m* l
  22. std::stringstream heightValue;
    * w; W) Q$ b; _) H* O
  23. heightValue << height->GetValue();</P>7 E7 ^6 }  K2 ]- U9 b
  24. <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());! r4 S: b" x9 C
  25. cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>( k* C' Q) R3 u
  26. <P>//Set the axis* P, Q, H9 P# o
  27. Axis* axis1 = NULL;
    # w1 }  X. M9 i) T; i
  28. axis1 = cylinderBuilder1->Axis();: P2 o, v. m$ y+ [, r
  29. axis1->Point()->SeTCoordinates(originPoint);
    0 t& x: c9 Z" J
  30. axis1->SetDirection(direction1);</P>/ T' C/ o* z5 [) z$ K* m
  31. <P>//Commit
    + t% [: a$ h6 W" {
  32. cylinderBuilder1->Commit();
    8 q) g2 P7 Z. o9 I. o% t
  33. cylinderBuilder1->Destroy();
    1 t, J0 h! w0 s$ b. F6 Y8 m& w; c; k* o
  34. cylinderBuilder1 = NULL;7 J# V# j/ [# u- w) G
  35. }
    $ t9 O. J; r8 F! v' H+ ]
  36. </P>
复制代码
5 G3 J8 A! z7 N9 B9 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二次开发专题模块培训报名开始啦

    我知道了