|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
怎么才能设置线的颜色呢代码:
! l& ]) B+ l3 c% o9 g; K0 A$ a
/ b4 i+ s% d* u6 `9 ?. Y/ C4 e: d0 m# R% h5 r
Option Strict Off
, b3 v8 D0 D' A; n2 t4 N3 ^Imports System% c' j; o# h' O5 x+ F
Imports NXOpen
1 I# R6 c5 S7 |) T, H/ G1 SImports NXOpen.UF% P; u5 K3 s0 a; r4 T
Imports NXOpen.UI
. v1 y+ v. V6 @( V. y: p3 }* P
* n% A6 f6 j7 `( m$ q! _ bModule Module10 o1 g3 f# ^- O# e" s$ M
. i* i6 M0 a/ X6 {' k5 C! [+ e Dim s As Session = Session.GetSession()9 q1 x9 Q o5 Z& ?- R+ R# w4 M
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession() q2 | C( e: z% f/ f! n9 x' s
Dim workPart As NXOpen.Part = theSession.Parts.Work8 @. ?5 |7 n; N# }- G1 u( n6 I
3 g# A4 R4 ~' k9 I8 S
Dim displayPart As NXOpen.Part = theSession.Parts.Display
% Y( e4 K6 |: l" |! L4 ], R* Q; ?* U. e, c
' Explicit Activation
1 B' j) Y& x5 S9 O4 _ ' This entry point is used to activate the application explicitly) ~7 F: ]; ]( y5 I- v3 u, u
Sub Main()
4 `- G9 ?+ M, S1 S& C( }- L
! p/ J- x; d* _ Dim sp As New Point3d(0, 0, 0)7 ], g8 i j1 y( q8 e
Dim ep As New Point3d(50, 50, 0)7 x. g2 R: m; E& |% B
Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing0 p2 x7 b) S% q# v. X' ^
Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)1 J5 Y- ]" p1 J6 @" w+ p
Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
* S; B7 q' v; X/ R2 c- k( B associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
: q) ]. x6 x3 Y3 @. Z Dim point1 As NXOpen.Point P9 N0 v# b S
point1 = workPart.Points.CreatePoint(sp)2 K) d* q5 E- e4 J! R' S& a
Dim point2 As NXOpen.Point. H1 x% G# e, X" w+ d: x4 ?
point2 = workPart.Points.CreatePoint(ep)
: x: s- v5 }- ^; [+ Z% A k4 T associativeArcBuilder1.StartPoint.Value = point1
& x2 C+ X/ s5 z7 P. K! G associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point+ Q7 |0 _2 |& M# O- q4 Y/ \0 S
associativeArcBuilder1.EndPoint.Value = point2
9 ~7 V R0 z: A! ?, e% D associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point
: f0 }# [# k! t/ @: A Dim point3 As NXOpen.Point0 f! N* L; c7 @* b$ ~) F
point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0)), L; n8 P2 O `+ u& T
associativeArcBuilder1.MidPoint.Value = point3/ k/ b# F& f( L8 t+ X7 [
associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point' [) D; g2 R* B2 r5 D V% `* p+ d' o
Dim nXObject1 As NXOpen.NXObject
) Q6 Z$ Z7 Z5 p w% K nXObject1 = associativeArcBuilder1.Commit()- f' i! M; L6 {& X, K
Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)/ N- ~! n2 ]3 D* J/ t& g7 Q) J* V
associativeArc2.SetName("123")
* D2 ]4 b) j7 f3 C& y( B/ c Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)5 f2 L$ Q" G1 }, m
associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point. T' }% U- _3 k# i
Dim displayModification1 As NXOpen.DisplayModification
2 q! X# I0 Y, p- q& p displayModification1 = s.DisplayManager.NewDisplayModification()( ~+ J) l4 T5 [! S) u: s
displayModification1 = s.DisplayManager.NewDisplayModification() '
4 X% W6 f b1 S: { displayModification1.NewColor = 7 '设置颜色7 ~& W; N8 U& p
displayModification1.NewLayer = 10 '设置图层
5 @2 W! P. X. B- p5 s Q Dim objects1(0) As NXOpen.DisplayableObject0 e2 r* t: F3 n: _; e, E
objects1(0) = theLine0 D5 ^2 F+ S% Z; R% k2 R
Dim object2(0) As NXOpen.DisplayableObject
# {0 l. m! D' O$ b object2(0) = arc1
) R; e1 l( |" L) K" A3 l6 g displayModification1.Apply(objects1)
[. V' B. N; ~ displayModification1.Apply(object2)
) Y, i7 R& K7 M7 | displayModification1.Dispose()
* f' `6 S) N& O) A) e) L, x7 i/ B4 h6 d9 }" R+ N8 t, p* ]' A1 X
/ t" ?. T( c: x7 Z
' TODO: Add your application code here * G, a8 i! l% H# ~' T9 }
+ z3 a9 _* D8 k2 I End Sub
2 A+ d* y4 \4 w$ S
- B h2 L0 N) b/ |& Z' H( ]9 K+ H+ L8 @
Public Function GetUnloadOption(ByVal dummy As String) As Integer
3 M; z' h/ I0 H% m* y( t# [7 T2 q ~& L
'Unloads the image immediately after execution within NX
, W: E6 d, |; [ B! d% B GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
& R2 n7 ?4 K' p5 N' ?1 c- P$ k5 o- G% t; V% a$ P3 M
'----Other unload options-------
" S3 N ~: u0 f) ^' B. l 'Unloads the image when the NX session terminates
% S. c2 Y. P/ S, R 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination' y! f- \' d5 t; b
/ E- x- S* b, r$ M) w% A! T$ O, u 'Unloads the image explicitly, via an unload dialog
9 d: F% @* ?+ a3 ?3 O 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly7 F# ~) p3 \0 ?% _% O3 \
'-------------------------------
% N' O- \, B; B/ ]# Z3 f6 U
+ f) L$ A/ [, F$ N8 ^ End Function
0 S0 X) S7 O# r, h1 H# z1 X. \0 B1 J# v" w
End Module- C0 @3 U$ \8 ~+ x* P
6 N4 x( e4 ^' Z1 T; }! ]# a$ B
7 T0 Q1 g5 a/ e% `; \8 H" @
6 P* _- j0 H$ ?7 P' G* m/ e- } |
-
运行时报错
|