查看: 4263|回复: 0

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

[复制链接]

2477

主题

1280

回帖

8万

积分

管理员

PLM之家站长

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

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

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

×
NX二次开发源码分享:NXOpen C++创建圆柱体特征
7 E2 D5 M2 ^' ?0 {3 B

  1. % k  q! J( ?7 r3 T4 f
  2. <P> </P>
复制代码

  1. 3 L& r! ]$ c' S! _
  2. <P>void CreateCylinder_UsingUDB::CreateCylinder()
    : A3 V( k% N; B' r! k+ U7 f
  3. {
    & d! D- m4 b; r; P* J' w8 N5 i2 s
  4. Part* workPart(theSession->Parts()->Work());</P>
    0 [: t" s! n/ K% L! N9 Q
  5. <P>Features::CylinderBuilder* cylinderBuilder1 = NULL;
    9 F! |8 F6 a) W8 n. b. v7 v4 D7 \
  6. cylinderBuilder1 = workPart->Features()->CreateCylinderBuilder(NULL);</P>
    & B  U/ y& p6 @0 v4 h, |- q; J* E% q
  7. <P>//Get the point
    : M* M7 X+ r8 @8 F! [
  8. PropertyList* pointPropertyList = point0->GetProperties();- O+ h  i) H1 H5 ~" s" a
  9. Point3d originPoint = pointPropertyList->GetPoint("Point");* u8 u) F4 c7 h& D. b/ b% g
  10. delete pointPropertyList;) ?' V4 Z3 X( c% J9 u! m
  11. pointPropertyList = NULL;</P>
    ' }1 x' [5 @. m4 a
  12. <P>//Get the direction) R3 h0 p2 F% \. u8 }( o2 p' l
  13. PropertyList* vectorPropertyList = vector0->GetProperties();; M$ v1 E% i$ o% J  m0 e: t& w
  14. Vector3d direction = vectorPropertyList->GetVector("Vector");! S! ?) w) d6 w' |& A
  15. delete vectorPropertyList;$ m9 k- b7 e0 Y2 T- X4 w
  16. vectorPropertyList = NULL;</P>
    # A. E" F0 }" n+ j1 B9 j: s5 ^" @$ Y1 M
  17. <P>Direction* direction1 = NULL;
    ( c" D& p4 t1 R3 S, H
  18. direction1 = workPart->Directions()->CreateDirection(originPoint, direction, SmartObject::UpdateOptionWithinModeling);</P>
    8 K  Q' M  Q$ w) X9 n) G
  19. <P>//Set diameter and height7 h$ }: n3 \1 ~4 R% u9 U
  20. std::stringstream diameterValue;( y- N" K( b, b5 R. W; z/ [
  21. diameterValue << diameter->GetValue();
    , m% D4 v' a1 Q! V+ x
  22. std::stringstream heightValue;
    9 J4 _" C" h8 V; K! x; {- E, `& g3 H( `
  23. heightValue << height->GetValue();</P>
    4 X( e  \4 i/ I; |( h
  24. <P>cylinderBuilder1->Diameter()->SetRightHandSide(diameterValue.str());( F) ?( a8 F" R* s& b
  25. cylinderBuilder1->Height()->SetRightHandSide(heightValue.str());</P>. a8 c+ K; q! a) K6 p" {3 u
  26. <P>//Set the axis
    # z- Z) d2 T0 e9 Q
  27. Axis* axis1 = NULL;# N2 K( |$ ^# x
  28. axis1 = cylinderBuilder1->Axis();
    ! B, m! [& t6 z8 d8 @0 w% v
  29. axis1->Point()->SeTCoordinates(originPoint);5 P: m% t6 x3 t. w
  30. axis1->SetDirection(direction1);</P>
    7 U- G5 v6 p# Y) j. c$ m" X
  31. <P>//Commit; D, Z  s. p7 }8 c
  32. cylinderBuilder1->Commit();
    * W% h0 C8 [- g0 c. s
  33. cylinderBuilder1->Destroy();. Q0 u( [, |' F
  34. cylinderBuilder1 = NULL;. V* o" V% L6 y
  35. }
    : x/ I+ Q& q* A  s3 P  \( o, f
  36. </P>
复制代码
, l3 t( s/ \4 R( i. M3 K
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

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

本版积分规则

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