PLM之家PLMHome-工业软件践行者

[求助] 设置线的颜色

[复制链接]

2016-7-21 21:18:53 3378 0

5

主题

39

回帖

409

积分

中级会员

积分
409
发表于 2016-7-21 21:18:53 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
怎么才能设置线的颜色呢代码:( Z+ ]- D0 S0 k+ S4 u7 z4 C

, j: {" \# \* B6 A0 T! A
1 Y2 t, v% D, c* gOption Strict Off! {3 [3 a. V& H9 {2 Z8 d  Y
Imports System
$ O5 Z, N$ K+ K, T  J  R# D. UImports NXOpen! W) r% Y' U' P8 ~* D4 H; j3 Z
Imports NXOpen.UF3 c) E) I" C3 J- ]
Imports NXOpen.UI1 F* ?4 g. Y1 f# @

8 U0 \- O: k/ A, E  K2 K* }( zModule Module1' i1 t8 g$ \: j4 U8 g9 L. h
) c5 l* I) b# K) H! Y
    Dim s As Session = Session.GetSession()  `( U! Y+ _; d
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()1 w/ e! M) W" M0 R
    Dim workPart As NXOpen.Part = theSession.Parts.Work6 S, H8 P0 n6 F

" g: W1 N* B) N  V, F* W* q    Dim displayPart As NXOpen.Part = theSession.Parts.Display# e, ^) ~& C- x- q7 I& V

! d/ s2 k' _5 R4 G    '  Explicit Activation$ I3 ?  ?, ]% e3 u  d
    '      This entry point is used to activate the application explicitly
* P7 E( Z  h+ J* @) v    Sub Main()
/ g  `2 E( \- N+ r) W
0 W; R# r' `) [* {       Dim sp As New Point3d(0, 0, 0)) E% b" n1 G/ J, e4 w
        Dim ep As New Point3d(50, 50, 0)
' Z6 r8 S# S$ \" f- J0 K7 l        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing" u: c$ n- o/ N  K( Y. I
        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)- H( t  `0 t' u/ t7 G$ v
        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder  ?8 w6 e+ b) J! d( e& P
        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
; X: d: `7 S% f- t$ H& q' H9 O6 G3 g        Dim point1 As NXOpen.Point
8 q- M* K( c- q5 l        point1 = workPart.Points.CreatePoint(sp)) k# E6 v0 r5 _5 A
        Dim point2 As NXOpen.Point/ ^( m( g; E- p" j* b2 ~. P
        point2 = workPart.Points.CreatePoint(ep)
4 w  w) K1 z' w" `3 j( C        associativeArcBuilder1.StartPoint.Value = point1
8 r/ }$ A+ ^8 `8 h7 o5 }        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point
' ^$ X# J2 p  D        associativeArcBuilder1.EndPoint.Value = point2
4 C. E. @( D# Q% ?0 A) Q/ P        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point. }+ E9 j9 a" R: _5 V
        Dim point3 As NXOpen.Point) S7 s5 n6 X+ L! v5 |  D7 W* n
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))( }' |" L4 M) n1 Y, h* Y
        associativeArcBuilder1.MidPoint.Value = point38 N2 Q+ w" o7 j4 d0 O' S
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
' u# F! e' g: n  f& ^8 I        Dim nXObject1 As NXOpen.NXObject
( p& x4 t& K9 I6 A& M        nXObject1 = associativeArcBuilder1.Commit()
/ H$ g5 B7 _* y2 E* u" A& s        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)  U: Z/ V" Y/ ]- w
        associativeArc2.SetName("123")+ L2 h7 V4 C" ~2 a4 H! w
        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
  n# V) b/ K0 R6 s& {2 O        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point$ j7 _1 i8 y0 b1 t! I3 C9 g
        Dim displayModification1 As NXOpen.DisplayModification$ a# h- P( E2 D. G4 x
        displayModification1 = s.DisplayManager.NewDisplayModification()
! {7 Y3 m7 \8 [  G4 p& M        displayModification1 = s.DisplayManager.NewDisplayModification() '! e3 {8 B) C+ K3 x: ~
        displayModification1.NewColor = 7     '设置颜色
" k+ a- N! N8 _        displayModification1.NewLayer = 10    '设置图层7 c5 |6 k1 p" p4 @7 L( r2 s+ m
        Dim objects1(0) As NXOpen.DisplayableObject
' S' h( O0 Y) F# Q- J        objects1(0) = theLine# H, d  {  N+ ^: ?
        Dim object2(0) As NXOpen.DisplayableObject* ?5 g1 E9 O2 B0 C  U! m- l
        object2(0) = arc16 I$ I, p4 D( C! N1 l
        displayModification1.Apply(objects1)) J8 a+ q5 n: C3 v, L9 m; T2 y: K
        displayModification1.Apply(object2)
8 Z9 x1 w8 s& q0 z2 M        displayModification1.Dispose()
* J6 R% W0 ~; p/ _. v" V8 g2 O2 i' Z! w* \, T* a) p, L4 k. b: B

8 H& r6 q# s. Z4 B. l        ' TODO: Add your application code here
2 g3 g$ z# K9 i' T; W1 `, y9 ]& y- N8 r2 Y7 Q$ H
    End Sub7 b# I) M) H+ [6 e
; T% i3 V( {+ \1 a$ t7 Z
, `8 b4 n, l2 d* D: w
    Public Function GetUnloadOption(ByVal dummy As String) As Integer" g+ \1 @5 D! Z/ p

) |. G( Q: ]. Z0 L, h6 P        'Unloads the image immediately after execution within NX
# O- V% B) \! O7 D: f# w        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately3 z- w9 o) Z; J$ ^1 }6 c8 F  S
) s! O1 k  U4 `; R% {; F4 O
        '----Other unload options-------
0 q5 _3 v% }% _4 j* B        'Unloads the image when the NX session terminates
$ K5 o4 t( |# Q: @5 K        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination9 ?1 u# Q& x5 }  Y0 i* z
3 B* l# b! X0 p( r) V) _
        'Unloads the image explicitly, via an unload dialog
. R; m$ N7 Z( z4 P  {        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
- T8 S2 X, e/ I! G$ Q5 d8 X        '-------------------------------: q# A% l$ p( B# n. w  {( {
0 N4 @- n3 a$ H% ]! ]
    End Function
( x* r/ X+ k+ \* H6 u" x* C6 J  T5 u$ Q
End Module
* j  P1 k9 c6 H% J* R% x7 w4 {& q9 c5 J

' |' {' ]8 f- x1 _3 t  q+ L' [. V( i! ^- \4 n- ~( j6 d3 G, @; C

运行时报错

运行时报错
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了