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

[求助] 设置线的颜色

[复制链接]

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

5

主题

39

回帖

409

积分

中级会员

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

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

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

x
怎么才能设置线的颜色呢代码:+ T. f% q' H8 s

1 G* ]  t5 L; j( V6 ^$ q7 K
3 H& X. u5 [0 T* ?5 N* R; l, _3 wOption Strict Off8 N7 O  _' s/ Q  A( j5 V( e1 a
Imports System+ T* U: L) [+ E( v7 _9 y$ E5 a
Imports NXOpen3 z, Q( _* E! u& R' a
Imports NXOpen.UF! o0 X; \$ g1 ~& I2 v
Imports NXOpen.UI* j4 F6 Q8 L3 J) \6 ?5 I
1 u: E4 u5 v# x8 C6 c5 [$ Y; X
Module Module1
9 F! R; x. `# ^! W# B
7 d0 w& h- Y8 R$ }  J% \% O$ `* Y    Dim s As Session = Session.GetSession()$ W% T/ R0 E2 g/ {2 a4 D5 u! t, U  `! C
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()2 g" h/ k: N. z$ E
    Dim workPart As NXOpen.Part = theSession.Parts.Work
) R' h9 v8 V3 q8 r9 g+ f
# j. q& q" Z' F: c# d7 n    Dim displayPart As NXOpen.Part = theSession.Parts.Display
2 F0 ~. I! R7 M8 d% r( p# ?3 ?' X: }: Y- U9 U! J. D) A9 z7 P
    '  Explicit Activation
0 q1 Z: T0 o0 r' `) E- j% N    '      This entry point is used to activate the application explicitly. E  j7 t& z, j& z+ Q( z
    Sub Main()7 ~- ~" Z* v/ S( D3 G8 b& T0 |0 e
9 i9 W; e$ p6 K0 k$ Z
       Dim sp As New Point3d(0, 0, 0)
2 j! H* ?+ f. h( H1 H, ?        Dim ep As New Point3d(50, 50, 0)& H) J0 y' O# {4 W' A' W
        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
& a6 @6 ?; A( V9 a1 p; n3 c7 @( {+ U        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)
4 J" V8 i9 _! }5 d3 W        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder6 ?0 Z8 q' _8 o! v" ?
        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
# _6 a" J: v1 V        Dim point1 As NXOpen.Point
$ |. R% J4 _% `( J$ r, d/ B, T        point1 = workPart.Points.CreatePoint(sp)
& G! ^+ t5 j$ S* S/ ~        Dim point2 As NXOpen.Point) }& h+ b2 t! M/ m* b
        point2 = workPart.Points.CreatePoint(ep)% W( ?  N7 F' q$ O9 n/ `2 V
        associativeArcBuilder1.StartPoint.Value = point1; C/ I' q3 [' G, T8 }% G# C
        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point! [' o) M; B7 `1 H( ^
        associativeArcBuilder1.EndPoint.Value = point2
* i  w  A) S$ V! o1 W* L        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point& w4 i; W' V6 U
        Dim point3 As NXOpen.Point8 q5 T& `: M8 M
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
7 |) k$ X6 v& D: c' u! i        associativeArcBuilder1.MidPoint.Value = point3, E* e! i( z, G  u+ B, x
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point; K+ ?- b7 s0 g3 D$ S& c* J
        Dim nXObject1 As NXOpen.NXObject; A3 k# {& m9 P' [" {& J
        nXObject1 = associativeArcBuilder1.Commit()# G6 U$ c4 b5 E8 v! K" _: z
        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)* @# F8 c! S# ]: W0 G& L
        associativeArc2.SetName("123")
" _( }5 T/ [( s# O( H- c7 O        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)5 r6 z. X+ ~2 i- b; j
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
) V/ [* V$ ^, ?! o        Dim displayModification1 As NXOpen.DisplayModification
" Y  P" }4 |5 a        displayModification1 = s.DisplayManager.NewDisplayModification()
0 y, y6 Q1 @6 M/ b4 l4 p2 p( ^8 h        displayModification1 = s.DisplayManager.NewDisplayModification() '
  T% b* t' E9 [/ Y2 b8 e3 L% x3 @7 Q        displayModification1.NewColor = 7     '设置颜色6 y. T3 j8 y7 ~0 q
        displayModification1.NewLayer = 10    '设置图层
* E8 |, `+ F6 B3 Z        Dim objects1(0) As NXOpen.DisplayableObject
' a5 v, Y( ]" C# j" r2 A. `( ]        objects1(0) = theLine; p/ y5 W; y# U5 H9 m9 A
        Dim object2(0) As NXOpen.DisplayableObject
" L9 l/ O; P0 `- d7 ?, a        object2(0) = arc1
: I- S/ r. _  D# b7 l        displayModification1.Apply(objects1)" f. C1 a& z5 L9 r
        displayModification1.Apply(object2)( w8 y$ u7 C! ~3 ^2 J9 L
        displayModification1.Dispose()
/ d. N: h2 {9 w2 }3 A# `% l# p  e7 n' v

2 ?) A. K& ~# T        ' TODO: Add your application code here
7 R7 q& n" u" q, Q' j5 j. Y4 G5 m" K! q  V% L
    End Sub
% N3 Y% M( ~1 z) r5 D
) ^$ b  v+ ?! M+ L$ i) k
$ V; O+ M7 ^5 Z* x6 O$ ?    Public Function GetUnloadOption(ByVal dummy As String) As Integer
) D% v+ H8 Y+ T; j. Y6 x* W. Y* Z2 v
        'Unloads the image immediately after execution within NX, |/ m1 D, i0 h' y: P6 K
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately# ^, Y$ m$ [* c  _. m

- v% O; x# {6 O# u; `        '----Other unload options-------$ o) z  F# e' V* d
        'Unloads the image when the NX session terminates9 g1 c% ]- U# e7 s  k- X
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination1 Q& i0 s2 c8 U: d
  F, V4 N+ _3 C
        'Unloads the image explicitly, via an unload dialog% U  V- I, }8 u# e
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
7 d% `# U% u0 z1 _! U  R8 ^        '-------------------------------
7 h: j1 W! |9 ~3 i
# h+ K7 T( u- M7 O% @0 E/ [    End Function: {- D# g6 Q+ m/ B* ?

0 v/ \3 z& E$ BEnd Module
: N$ }- w: u: u1 T2 N( V
& f6 ^9 Z- w# z& }) U. ~
+ g- w, v) B+ b" B9 l! A" V" {% e  A4 u

运行时报错

运行时报错
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了