青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

青华模具培训学院
查看: 1352|回复: 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.* I) Z3 q" H2 {
Builder Method! `( X) A; z4 M7 l! x
The builder method uses the following general steps.
; q* A* e! I* b) O" l' Y: T: ?Create a New Feature# }  o: G' h9 x
Create an instance of the builder object for the desired feature type providing a null object as input.
- `  U" n$ E% n7 j( o# MEdit the properties of the builder object to set the feature parameters and options. ! B% k" n$ J: c1 Q$ [# j7 Z$ a; Y
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 t5 b3 J0 w# P4 e* ^8 i
Use the Destroy method of the builder object to delete the builder object.
' l* o, c; q# n( pEdit an Existing Feature (same steps except provide an existing object)9 _2 S, r; F8 U5 n# Y2 ?0 G  {- v
Create an instance of the builder object for the desired feature type providing the object of the feature to edit.
' B' C% j1 P; q1 S" yEdit the properties of the builder object to edit the feature parameters and options.
/ n( N4 w; F! Y! KUse the Commit method of the builder object to edit the existing feature.
4 o, v8 N  T' y5 RUse the Destroy method of the builder object to delete the builder object. , R6 h2 x: o) v  _7 ^
Each 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./ @1 i% }( D$ k" C$ }' W( w- d
The 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()./ V# d% F) A( Y9 {4 ^. J5 _! D, l
Create and Edit Features - Language Specific Details" M7 g+ N! R) y+ H6 @- h$ F
NX Open for C++
; \; o+ \3 b2 C# ^6 o( s& p! k( q8 ONX Open for .NET
3 w* @% S# P5 \NX Open for Java
7 x1 ~+ D4 N" R0 p& oNX Open for C++0 ~3 Y" \+ |* A* N1 B4 t! L
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.& w! C! p+ [! E
Session *NXSession = Session::GetSession(); ; Z- f% G& X; {# H: \
Part *workPart (NXSession->Parts()->Work()); ! e( [0 |% U6 d( i/ ^5 X6 n! d4 {9 A

. |; F) z. K) p+ g/ o  ]Feature *nullFeature (NULL);
$ \$ k4 C  H# V; |, H" {, k
  g) r9 b3 p" J: XPoint3d origin = new Point3d(0.0, 0.0, 0.0);
2 B1 Z- O0 u- ]# \( h% {" g  x
8 U/ V( [. {5 ^7 }9 q2 z//************************************************************************** : r" A* h- m4 [9 U7 b
//CREATE BLOCK * i4 }1 e# _! M3 U# @: Q

+ v8 i- @6 C' o8 N6 @8 Z) cBlockFeatureBuilder *newBlock = NULL;
5 Y! S$ D) S" }# g- y2 [) wnewBlock = workPart->Features()->CreateBlockFeatureBuilder(nullFeature); ; T* k/ i! v7 m2 T# T

  f1 U: I( v) R5 S1 ynewBlock->SetOriginAndLengths(origin, "50", "80", "100");
- V8 x0 }. o' Q
2 w3 K* y7 l$ I/ RFeature *blockFeature = newBlock->CommitFeature();
4 ~/ `4 J6 j8 A$ G
. ~5 Z+ K* ^% Y. _newBlock->Destroy();
5 z& P8 t* r$ j* x# s
$ F" ^, [! l6 l# F0 z//************************************************************************** 2 `, K% n, R$ Q: l6 i5 v
//EDIT BLOCK 6 H) a$ {: e# N
9 f2 {1 \* f; c( x/ W/ m& I! s
BlockFeatureBuilder *oldBlock = workPart->Features()->CreateBlockFeatureBuilder(blockFeature);
$ a, j& C- a+ p/ u' t) y & ?0 q) k' @8 [: I3 v
oldBlock->SetOriginAndLengths(origin, "100", "20", "50"); $ F& a. s$ _# E" T; ~
6 `+ [: p$ w! v4 s/ f4 P
oldBlock->CommitFeature(); % O5 Z- d4 S  W; V% k! @$ W

7 H! r+ p% G% {oldBlock->Destroy(); : y2 Y3 v8 {" [3 U
NX Open for .NET
1 `3 n3 U9 g* p$ lThe 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.: b$ G/ @  F$ b/ s- O3 T+ a
Dim NXSession As Session = Session.GetSession()# d1 p0 W6 }0 y' a
            Dim workPart As Part = NXSession.Parts.Work' q1 A0 _- x% _; _9 g$ n

4 I9 B3 S. ^1 O            Dim nullFeature As Feature = Nothing! F( I. V2 X6 C( S! ~) U$ |
7 T: J5 z5 s& P9 n0 t8 T. U/ N
            Dim origin As Point3d = New Point3d(0.0, 0.0, 0.0)1 i- O6 \0 u) G

, h8 l* i6 V6 S            '**************************************************************************
; s# t: W. I  |2 B- \8 F# ]: z            'CREATE BLOCK
& B- V4 K: _* x# e( S
  O& G. Y: ^  r            Dim newBlock As BlockFeatureBuilder = workPart.Features.CreateBlockFeatureBuilder(nullFeature)
3 e( D$ T$ y, \. L
3 I& s' C4 g' Y/ J# a/ C5 D            newBlock.SetOriginAndLengths(origin, "50", "80", "100")2 v' H: @1 g- s# b5 c. M: F

& Y& i5 i9 Y. }+ L            Dim blockFeature As Feature = newBlock.CommitFeature(): f' X+ j# @6 p, d7 ]% M3 S
( m1 c$ s7 S: B  [1 w
            newBlock.Destroy()6 u8 ~; c1 d: ~7 I, d1 H/ k$ m

9 g5 d3 a6 `. C6 j            '**************************************************************************
) B. [" E9 V# s* [/ I2 A            'EDIT BLOCK+ a. y- k( h4 U6 J% g
6 n. Y  {5 l+ o! \: _7 z# o
            Dim oldBlock As BlockFeatureBuilder = workPart.Features.CreateBlockFeatureBuilder(blockFeature)) a3 u& _% J& c. N+ f
5 ^. D- p! A% B/ m* k# w* n: C
            oldBlock.SetOriginAndLengths(origin, "100", "20", "50")
5 o8 @: {/ q# ?- j. e9 t
2 i- ^4 M4 z, v8 A, q4 J$ k            oldBlock.Commit()/ n' ^3 a( l6 W& l% v* q
  i9 T9 \4 }! T) S: O
            oldBlock.Destroy()
& z" x4 d( o- h( H5 YNX Open for Java
* C/ g% z5 y4 f- {% SThe 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.
' B0 [8 e" x9 z4 _5 e: Z/ wSession NXSession = (Session)SessionFactory.get("Session");
( l  _- ~# C! l+ Z1 B& g. }+ gPart workPart = NXSession.parts().work();
7 Y: G8 h2 u# F8 r- p" x1 T& SPoint3d origin = new Point3d(0.0, 0.0, 0.0, 0.0);
* `5 \. |$ p- z. Y* a0 Tnxopen.features.Feature nullFeature = null;/ h, o8 g# h4 r
//**************************************************************************, N0 l8 b/ C9 u! a, [; P
//CREATE BLOCK8 ?$ c5 C3 W- i$ Q
nxopen.features.BlockFeatureBuilder newBlock = workPart.features().createBlockFeatureBuilder(nullFeature);
+ U) w" e- R" F( HnewBlock.setOriginAndLengths(origin,  "50", "80", "100");
5 Y, H: m0 E9 x' c; M) rnxopen.features.Feature blockFeature = newBlock.commitFeature();8 |) r) |( s, W" e4 e( S) p
newBlock.destroy();
* \* }5 B: g, O: w//**************************************************************************
6 T- N2 T3 _' h3 _2 r$ C//EDIT BLOCK
, I& N6 a# K8 ^# Jnxopen.features.BlockFeatureBuilder oldBlock = workPart.features().createBlockFeatureBuilder(blockFeature);
5 J6 |, B' k9 i- Z2 G% j3 }oldBlock.setOriginAndLengths(origin,  "100", "20", "50");
+ y9 T8 [2 C, K% D1 W; p  L* loldBlock.commitFeature();
! ~! A* u+ W6 M5 }" }oldBlock.destroy();
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-19 06:05 , Processed in 0.059960 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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