|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
怎么才能设置线的颜色呢代码:
1 b; n; h) z( N+ R
7 ~- U) m W; I9 p
: B# i( [. g# j' ^6 B3 IOption Strict Off
3 U0 B$ X, \; xImports System
- b. f) V% p W$ l' HImports NXOpen
% W) x* G( u& {8 I$ j9 g+ \Imports NXOpen.UF5 \9 [4 m- F' a/ a3 Q7 B$ X
Imports NXOpen.UI( ~6 H! L# O: v9 ~: p
7 F' _0 _" J4 W5 rModule Module1' V7 m6 d: L p# R% d
. f! X' I' U# x Dim s As Session = Session.GetSession(). s9 g$ s3 I& L U( S' h( `
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()4 B# _. J% C% G& s0 Y* x# f9 c
Dim workPart As NXOpen.Part = theSession.Parts.Work
. M( X" d: r; }' T! V3 A
& ?+ O e0 J3 x4 P% x3 ~ Dim displayPart As NXOpen.Part = theSession.Parts.Display2 C0 ~5 M# s, R' T: Y; `! _
! u( m7 W# O% Q7 X$ d ' Explicit Activation0 J. R7 o8 f# b6 X8 a0 E! S
' This entry point is used to activate the application explicitly
( S# z5 o& j( i2 K Sub Main() c5 L! f8 l1 B/ { m3 B% r: L
, E2 h% x- S1 q% |
Dim sp As New Point3d(0, 0, 0)' o8 ]" D& t/ L- L) b' }
Dim ep As New Point3d(50, 50, 0)( u9 L( g) Y6 p, {/ z6 N! }3 k
Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing9 C& X8 s' c v2 J+ t9 ?
Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)' ^ N, F" I) G' [) L/ {
Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
$ o# T5 [8 y& J! d7 [' D+ @ associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc). w/ h" Z \" O$ o
Dim point1 As NXOpen.Point
: ^) K! g8 A/ g. q/ x# g5 ? point1 = workPart.Points.CreatePoint(sp)
1 e) x3 ^: b# [" U# ^ H4 } Dim point2 As NXOpen.Point9 H* \7 [) s! |9 \ A8 I; q: m4 g, D
point2 = workPart.Points.CreatePoint(ep)- j! }; T5 k/ ~! `. N
associativeArcBuilder1.StartPoint.Value = point1. T n5 K; m" k7 z
associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point/ J( o$ y6 z' {) \. D- ~6 s
associativeArcBuilder1.EndPoint.Value = point21 A# V5 ]/ y, q4 H7 N4 X/ V
associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point) q' _* U+ O, m% o& s2 f
Dim point3 As NXOpen.Point4 [/ d" z. s- C
point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
9 A, A5 O3 y% M& b( H associativeArcBuilder1.MidPoint.Value = point3
& Y7 ~1 @, ^/ F9 f" Y" _# S3 I associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
; i9 x$ e8 f+ c* f" O) O- X5 X Dim nXObject1 As NXOpen.NXObject6 w5 [4 R3 a- i! {
nXObject1 = associativeArcBuilder1.Commit()- n5 e" Z6 O' s; b! c/ O
Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)( X- P. U! c5 f$ x3 ~1 k% f* x
associativeArc2.SetName("123")
$ Y" t F; E9 k8 L9 j7 q [ Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
8 @6 W6 Q: V" S2 V associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point1 q( B8 ~& G1 Q7 M. Z8 G
Dim displayModification1 As NXOpen.DisplayModification q- f, b5 G! s* E/ r
displayModification1 = s.DisplayManager.NewDisplayModification()
- J/ l' e# L( l4 m, d$ O: C displayModification1 = s.DisplayManager.NewDisplayModification() '4 Y# D |# s B2 f
displayModification1.NewColor = 7 '设置颜色
6 S' y" C& \7 x% Y; t displayModification1.NewLayer = 10 '设置图层( d! _5 d1 b, P8 \; I
Dim objects1(0) As NXOpen.DisplayableObject
+ G) M, h9 Z3 g/ o$ F& o objects1(0) = theLine
: _0 i! z4 o: q. i' C& ^: V Dim object2(0) As NXOpen.DisplayableObject
9 ~( q# g% _# v. w object2(0) = arc1
4 E3 B: ?) b/ b, H displayModification1.Apply(objects1)5 j3 g( ?3 P2 Q7 @3 j
displayModification1.Apply(object2)# n$ d! A0 O& S
displayModification1.Dispose()0 c$ J3 m& D1 E0 } K- L
4 `" _3 O: W' F0 g! a! N. I# z. Y8 L( G
' TODO: Add your application code here 4 k. L) T- L' I7 k8 a6 O# F
5 H" ]4 u; a2 m End Sub% g; m4 ], N' c" Z
+ I" ]3 g5 t6 c) e1 w' Q: ?; P7 z/ x: x
Public Function GetUnloadOption(ByVal dummy As String) As Integer
/ p' R( r3 P) n; A+ b- q; }
8 \8 K5 `3 ?- I1 q' X4 z6 g 'Unloads the image immediately after execution within NX- `4 P! n% V* o& q3 k+ i
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
D1 C" W' s6 ~4 X# Y i7 W& Z; {' ]9 p. }! H+ c1 x+ d/ ~
'----Other unload options-------
! f* v" [- e- s6 j. M9 w7 _ 'Unloads the image when the NX session terminates! P) d) s; M& K# K2 v2 I6 g6 p9 M
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
" c# V) ]0 y, `, r' j+ R: {8 D4 H$ Q" P+ H) E
'Unloads the image explicitly, via an unload dialog
1 G- A; S7 x6 f( C6 \7 `4 r 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
3 c6 T1 o& J8 j8 f! t+ R1 L9 J '-------------------------------
1 e: m" g: f5 k4 g% f! A2 z/ f3 f
End Function" U: r4 \( R* K! w; ]! L
" T$ ^% g7 j3 i n* d9 y
End Module
3 U. S6 @1 K5 J- h8 l3 }0 L
) o! q. b/ w, @; _ l
: B$ |; E7 f- y6 u. @3 _% J1 q9 Q- |2 L/ U$ p; o: \; L
|
-
运行时报错
|