|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
怎么才能设置线的颜色呢代码:
0 w4 R* G6 K% v
, R* P# I' J, e2 J7 v6 L3 }6 [! C7 u! p* J/ S. \. E# n
Option Strict Off
0 [$ W. V) E' [" w' uImports System
' x: A, S- j: M! W7 tImports NXOpen
- [1 l1 B/ V; z; N2 Q. ~% S2 RImports NXOpen.UF
2 b" [% U" G; t. } ?6 xImports NXOpen.UI5 _9 H: r! ]4 F0 {5 [
) d8 ?* [! m2 z/ O, g# h) o
Module Module1
. v- d4 A! G! U* {
1 I. F6 O& }" C- P" g% Q, q( Q. \5 P Dim s As Session = Session.GetSession()0 t# Z7 B; i( l; v5 p. X
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()8 c( N8 \) `$ U
Dim workPart As NXOpen.Part = theSession.Parts.Work% [" U4 h6 x& t. R
* T A' P8 e% e( L/ } Dim displayPart As NXOpen.Part = theSession.Parts.Display
" h9 k7 H' s) ]- \% i1 x/ X, n. t/ L" E9 p
' Explicit Activation
* U! `% [+ {* n3 b+ F! F$ l ' This entry point is used to activate the application explicitly
' F& `2 B; N! T4 D$ e, I Sub Main()" c" w' r* a2 G2 s; B/ C! Z
3 g1 _0 \3 @, @+ Y( M9 b
Dim sp As New Point3d(0, 0, 0)7 {, z" o2 O3 V2 |7 n% ]9 v5 m- z
Dim ep As New Point3d(50, 50, 0); v7 T" t" g' w! [
Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
. H5 ^& E0 c8 X3 h3 ~; [3 ?0 W Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)0 F$ [: T$ ^& \) O9 p4 b
Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder* ` ~4 n/ L# h6 W& q
associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)) E/ H- {# @# p/ M0 I* D
Dim point1 As NXOpen.Point F# D. |; Z1 b$ p v: ?/ z
point1 = workPart.Points.CreatePoint(sp)
) J& w- I `0 X6 V3 ` Dim point2 As NXOpen.Point
6 P# i' n5 m2 ]: [" k4 W1 L5 k, v' E point2 = workPart.Points.CreatePoint(ep)& Z" |9 v, j% d( F8 R
associativeArcBuilder1.StartPoint.Value = point18 z+ O3 S# D, M- v8 l( b
associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point2 s b5 ]/ t. W6 C+ N1 e/ n, j& _
associativeArcBuilder1.EndPoint.Value = point2, m% t% a; m q# t6 ?& ~) e: W
associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point
) x; L; P0 x9 `* `& G* @( O5 F6 x Dim point3 As NXOpen.Point$ W1 Q/ q$ y1 M1 _9 }9 _8 _3 p0 u
point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
" C' a/ P% f* M% w1 ~8 j associativeArcBuilder1.MidPoint.Value = point3' J- e5 |. K# _/ N" Y# F* D
associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
) J, R, u9 O" {* ~. O Dim nXObject1 As NXOpen.NXObject
. l+ R$ P" U$ O" C* ] nXObject1 = associativeArcBuilder1.Commit()1 |" W8 F6 L' K& M- P' ~
Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)9 ^7 a; A/ r- e+ j$ z+ ]5 i
associativeArc2.SetName("123"), A) w) {5 y! b7 n% z- }+ |. Y: l6 M6 W
Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
; c3 q0 {) P ]0 T! a5 T1 B& F; Q associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point8 E& i* F! {0 @( E! g
Dim displayModification1 As NXOpen.DisplayModification* S- e9 J, L3 A
displayModification1 = s.DisplayManager.NewDisplayModification()
1 s& I: ]' N p5 U0 u displayModification1 = s.DisplayManager.NewDisplayModification() '( I K+ w4 J2 X& N1 ^
displayModification1.NewColor = 7 '设置颜色
* O6 ~% g9 C2 h- K w) } displayModification1.NewLayer = 10 '设置图层
' E" `+ l' V0 K+ l Dim objects1(0) As NXOpen.DisplayableObject
8 P7 }! u) C* |% }+ c objects1(0) = theLine
, F# f% I, c* l+ N Dim object2(0) As NXOpen.DisplayableObject( R6 i+ T; H% I* d5 v
object2(0) = arc1; M7 C3 y9 ?8 N5 y4 m. b9 O
displayModification1.Apply(objects1)( W2 J# m% t- {$ S% v& f' f
displayModification1.Apply(object2)
" Y) s/ [8 Y$ \$ V! M displayModification1.Dispose()
) O8 g6 u9 @$ W1 o9 K5 c4 S
0 R, U3 f4 t0 N6 ~( j0 |& i `3 w/ D0 U9 Y8 e7 G
' TODO: Add your application code here * H6 W" m. [ u: T
( f5 r: r' B4 \" }7 o. _! L/ U End Sub
3 e& }8 ~: O3 y1 E* g% ?$ q3 e! n, d$ e5 r
7 n2 Y7 T5 [7 E6 t Public Function GetUnloadOption(ByVal dummy As String) As Integer
( t- u- U. O. j7 |* U8 |
# I- ?' Z0 g" q% H/ B0 i% X 'Unloads the image immediately after execution within NX
% A9 I" b! J; _5 T& L, j8 k GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
4 q8 L* ?* P) r+ k# B3 r6 c% v" @2 a, K0 j
'----Other unload options-------
6 \3 [" N8 n1 w; N) q 'Unloads the image when the NX session terminates
& ~: q3 c- J7 Q( h! n 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination# h4 n: X) v$ M. W9 _' _
: Y1 H' B5 ^7 b% {
'Unloads the image explicitly, via an unload dialog
% z9 E5 d% l' X, \ 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly, b' R1 }- g: {, s8 ?
'-------------------------------( |1 Q) H* G: ?( b9 r
N0 U" {6 {( T+ [* U+ q
End Function0 H, I R$ c* q$ C4 x5 Q' j5 G/ o
! \( P8 f! O. r) k, `# n9 {* `9 {
End Module9 ]& T( d9 y. e8 \! d$ ?
9 l, j! ?4 C' w/ e8 V9 J7 ?# D
3 s* L1 ~# P' |& F* C. Z0 Y3 X: a, c9 g" v5 u* H
|
-
运行时报错
|