青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

青华模具培训学院
查看: 1349|回复: 0

[分享] UG Secondary Program - Create and Edit Features

[复制链接]
发表于 2009-6-30 19:15 | 显示全部楼层 |阅读模式
Most features use a builder method to create new features and to edit existing features.  Features that do not use the builder method use constructor methods that are specific to the feature. The feature specific constructors are defined in the language reference guides.  This section discusses the general concepts of the builder method.3 q( Z/ H6 ]8 `+ Y, C2 N0 F
Builder Method
" G" w6 C2 e/ }8 ZThe builder method uses the following general steps.
/ r% |' T  n+ A! G: {! \/ g; o% FCreate a New Feature
4 u& n( e8 E' h" jCreate an instance of the builder object for the desired feature type providing a null object as input.
* g# m7 i4 i1 F! C3 m" o. s- OEdit the properties of the builder object to set the feature parameters and options. ( B6 |; u" V( h7 n8 A- g
Use the Commit method of the builder object to create an instance of the feature.  The Commit method will return the new feature object.
9 O8 A! O- D% A- f' L9 U& K9 fUse the Destroy method of the builder object to delete the builder object. / S+ k7 T2 B/ n* ?6 s# W
Edit an Existing Feature (same steps except provide an existing object)9 a3 {( ^) [! H& Y; ^
Create an instance of the builder object for the desired feature type providing the object of the feature to edit.
2 `9 `* d5 e: V9 w: L  QEdit the properties of the builder object to edit the feature parameters and options.   C  X9 G( \( R  [! O
Use the Commit method of the builder object to edit the existing feature.
9 c  {. A# e' _Use the Destroy method of the builder object to delete the builder object.
4 J& Q. a7 [7 a% R7 a6 T. uEach type of feature that uses the builder method will have a specific builder class.  All builder classes can be found in the Features name space. For instance the class for the Block Feature builder is found in: Features.BlockFeatureBuilder.
0 y) N, z, g. G" z9 VThe create a builder object, the Part Class contains a Features property that contains create methods for each builder class.  For instance, given "workPart" as an instance of a part object, the create method for a Block Feature builder is workPart.Features.CreateBlockFeatureBuilder(), and the create method for an Edge Blend Feature builder is workPart.Features.CreateEdgeBlendFeatureBuilder().
5 [! Y1 u3 \' h9 R/ O* R9 ICreate and Edit Features - Language Specific Details
; l' g) ~0 m" s9 T5 tNX Open for C++
; e9 }9 V7 q8 c: v" @. D6 p* `- ?NX Open for .NET1 o4 y0 Y8 {3 A6 }% D% {
NX Open for Java! X2 r7 d9 y, j1 Z2 E; H
NX Open for C++
( _% Z* _/ C" k4 f3 z. QThe following examples shows how to create a feature builder for a Block Feature and then use the feature builder to create a new Block Feature.  A feature builder is then created to edit the Block Feature.2 K/ p! [  N! g) n/ A9 j  |
Session *NXSession = Session::GetSession();
5 a2 D. q# e- {" a! KPart *workPart (NXSession->Parts()->Work());
! h2 c3 O3 s0 e0 q
. g; m  m% z6 q; oFeature *nullFeature (NULL);
9 v  K1 ]7 R7 E) ~9 J ) j) g7 h$ c3 n
Point3d origin = new Point3d(0.0, 0.0, 0.0); / C! X: q5 n3 h
- L& W" C' h+ d% C- ?2 F8 ^
//************************************************************************** ! c" T- V! P/ |  X% t
//CREATE BLOCK
7 V) d& h1 `* ^7 N6 a4 N # d$ h: o* s8 B% u+ M! I7 y
BlockFeatureBuilder *newBlock = NULL;: _1 C; i, z* j
newBlock = workPart->Features()->CreateBlockFeatureBuilder(nullFeature);
3 t2 i  K, ~/ U0 |; q  F * i- p, |6 X. t- |
newBlock->SetOriginAndLengths(origin, "50", "80", "100"); , |1 p( u/ Z0 z8 Q3 W! z1 T
# ~( f% r; J+ m" ~& e* [6 Y  t
Feature *blockFeature = newBlock->CommitFeature(); 8 F+ g" m, r0 Q$ k

# E1 E& v2 e& SnewBlock->Destroy();
0 I7 K. d  y- N. S2 m5 m# J
0 l# _* B( A/ ?$ f//************************************************************************** 7 K! h/ }5 g) i# E* h
//EDIT BLOCK # J" G8 r5 q1 |3 h) y! G

5 c( s  q/ {" e+ ]2 s) VBlockFeatureBuilder *oldBlock = workPart->Features()->CreateBlockFeatureBuilder(blockFeature);
; ~% p  s, J+ L% M+ k9 T
0 {, q' `8 {; `- _: \- r* woldBlock->SetOriginAndLengths(origin, "100", "20", "50");
3 H) y  C: q5 o* r$ V# e
! o8 N1 \6 ?0 U+ N; `+ N3 E1 zoldBlock->CommitFeature(); 9 b3 c; m  D$ o. v) ^3 ]; g4 u
* g& i6 G% o6 L% c2 n
oldBlock->Destroy(); : Q) W( i6 D  G
NX Open for .NET
  F/ g% e) I( C  f9 y. r' b& @The following examples shows how to create a feature builder for a Block Feature and then use the feature builder to create a new Block Feature.  A feature builder is then created to edit the Block Feature.* L, I% Y( S) S' P6 ]
Dim NXSession As Session = Session.GetSession()
" e. Q/ u- i( ]' Q' n: L            Dim workPart As Part = NXSession.Parts.Work
; B# ~1 W$ K+ N% d& h( c& K9 L , C$ y- j: F' n; l, d8 y
            Dim nullFeature As Feature = Nothing- |+ Y  }, R9 G# H1 h

' e7 \- q/ W% E" e7 C- M- S3 b6 b8 V            Dim origin As Point3d = New Point3d(0.0, 0.0, 0.0)
) c. K1 a9 l/ G6 }! Z, T' s : Y  Q. p6 m: x0 F5 ]
            '**************************************************************************# n9 \6 ~4 L) J/ ^6 K( e
            'CREATE BLOCK3 ?9 }/ d" j: F. `

6 k5 B% J! a2 q6 h: m9 _" D            Dim newBlock As BlockFeatureBuilder = workPart.Features.CreateBlockFeatureBuilder(nullFeature)9 V- F7 @; \% _# |* G# E( c! Y
: B7 r& H2 S* y2 t5 b  {
            newBlock.SetOriginAndLengths(origin, "50", "80", "100")
( @% \7 O" t$ M0 V  F' b 5 J- u/ D' z+ {
            Dim blockFeature As Feature = newBlock.CommitFeature()
$ x- O) ~2 p) P # `* ?! k! Z' m9 K* R, |& d
            newBlock.Destroy()
, `& o: N$ G" K+ s6 g! F& t
3 R0 g! _/ S! z- H2 R( M9 e9 E* d0 F            '**************************************************************************
% p  ~/ b5 J4 }0 r9 y            'EDIT BLOCK0 }1 _1 @  b" v! A5 n- o8 Y) T

# ?2 @: E! B: s) s. L+ h8 E            Dim oldBlock As BlockFeatureBuilder = workPart.Features.CreateBlockFeatureBuilder(blockFeature)  C0 V, t6 W/ W. f* J: R
# [9 A0 i* `0 V. o/ u' p: E6 y! _
            oldBlock.SetOriginAndLengths(origin, "100", "20", "50")
' Q! O0 @8 J! f% O' V; A+ ]6 s + f  F1 T3 y/ U- A3 g8 C
            oldBlock.Commit()
4 h4 o1 Z* h: G. W8 u
  f0 D  r3 c7 l1 @8 k            oldBlock.Destroy()
$ t& _3 M. |* P: k5 g% z5 `5 L5 {3 JNX Open for Java
' F0 X! F6 W$ u# t4 e, ZThe following examples shows how to create a feature builder for a Block Feature and then use the feature builder to create a new Block Feature.  A feature builder is then created to edit the Block Feature.! Y' |5 V! g+ |7 ]
Session NXSession = (Session)SessionFactory.get("Session");' m2 g2 p; O$ T4 w
Part workPart = NXSession.parts().work();. ~$ ^% `( w/ m" E" y  a+ G$ F
Point3d origin = new Point3d(0.0, 0.0, 0.0, 0.0);
% o+ V( A! y! R, ]nxopen.features.Feature nullFeature = null;
1 O- @; q. A- J1 I8 B! M//**************************************************************************
* k8 H4 Q& ~! S//CREATE BLOCK9 a4 X& W% V1 m
nxopen.features.BlockFeatureBuilder newBlock = workPart.features().createBlockFeatureBuilder(nullFeature);% ~; C/ a9 T. j5 ]
newBlock.setOriginAndLengths(origin,  "50", "80", "100");
& `6 W$ o8 q0 G. O/ k8 Tnxopen.features.Feature blockFeature = newBlock.commitFeature();
% @; Z2 z& B3 ynewBlock.destroy(); ! v6 L2 A& ?' u0 r
//**************************************************************************
# A- k8 z+ |: }# R* c//EDIT BLOCK# y  H8 s5 H1 Z! ]
nxopen.features.BlockFeatureBuilder oldBlock = workPart.features().createBlockFeatureBuilder(blockFeature);
% s/ b+ I+ u, Q  d- k- xoldBlock.setOriginAndLengths(origin,  "100", "20", "50");" L0 O: m; r0 R( V2 e
oldBlock.commitFeature();& ]$ |& V3 d+ j
oldBlock.destroy();
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|关于我们|sitemap|小黑屋|Archiver|手机版|UG网-UG技术论坛-青华数控模具培训学校 ( 粤ICP备15108561号 )

GMT+8, 2024-11-16 22:20 , Processed in 0.050715 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表