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

[求助] 设置线的颜色

[复制链接]

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

45guop 发表于 2016-7-21 21:18:53 |阅读模式

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:0 I5 V  L, W& }1 s$ k" e1 o! a
5 ^1 P6 _/ P0 F  ~8 l
6 v5 R0 x$ l4 ^) U+ c$ u, t
Option Strict Off
/ L* w. P: l1 }2 V. M: jImports System
6 d0 \- Z0 t# B$ O, k* ^6 FImports NXOpen
1 m, x; j; A  k: y: N! E5 qImports NXOpen.UF( p" U! D( c3 W: e9 }8 _
Imports NXOpen.UI
+ k3 w& ~$ B; t5 N
& J2 d" I: {9 P& L$ M* c) S& E2 kModule Module1( p# A8 T' q* a7 A2 F4 q

$ ?# b' o" F1 B/ x+ {0 z    Dim s As Session = Session.GetSession()0 C0 ?1 R/ N; F
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()* D  q9 `9 r4 m* b
    Dim workPart As NXOpen.Part = theSession.Parts.Work
# R8 X; }$ R7 [. K* g$ {. z+ I- \$ n
    Dim displayPart As NXOpen.Part = theSession.Parts.Display7 g6 p; f  l9 A

9 L/ c2 ^" y: d4 }! L3 h* ~    '  Explicit Activation
* A5 m$ k' I; z    '      This entry point is used to activate the application explicitly: x. A1 v2 s7 W# Q, a$ o
    Sub Main()
+ i' c. z. u3 t! X, j+ x2 @
3 P0 [6 m5 N" g6 z       Dim sp As New Point3d(0, 0, 0)
& G+ Q4 X& m- h        Dim ep As New Point3d(50, 50, 0)
- Y( G" I' |0 a; [0 I9 Y& T3 l, T        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing8 Q. Q! C2 P6 ?6 w5 ]$ S# w
        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)4 U: P5 s, m8 `9 j. L( ^
        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder9 |! ?& z0 T& m- h
        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
# D7 [0 W: c5 \& t. ~        Dim point1 As NXOpen.Point
+ W8 o: F. M* a4 }. C* b' B- Q# b        point1 = workPart.Points.CreatePoint(sp)
0 Q' g4 m. d& F* n1 H        Dim point2 As NXOpen.Point3 L8 Y9 Q  f# \2 O4 y
        point2 = workPart.Points.CreatePoint(ep)
7 [2 @; e0 z/ ^2 n+ b        associativeArcBuilder1.StartPoint.Value = point1- ~' t4 o5 V7 B" x
        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point/ _2 m$ \" |* a) `% @
        associativeArcBuilder1.EndPoint.Value = point2
/ m0 I+ Z  |( ^        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point, X$ h0 _& [: Y9 K, |7 D
        Dim point3 As NXOpen.Point+ k: m* {5 D7 H8 F5 M/ `
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
( Z' O3 ^1 _" j" U* @! b1 M2 q( l        associativeArcBuilder1.MidPoint.Value = point3
/ R, H; W" f0 j% T+ a0 \. K: s# a1 T        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point1 e9 T# F0 ^0 l& w: f- r2 N3 O
        Dim nXObject1 As NXOpen.NXObject" R2 g/ `4 g7 l) ~' f
        nXObject1 = associativeArcBuilder1.Commit()
- }, ]! O! h% r. o( s8 q1 ?# ~% A        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)
3 _4 b' C% B/ _! ?) J& u        associativeArc2.SetName("123")7 Z/ ?: p8 o) @( L2 {. \
        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
7 H7 p, {+ C6 E8 @8 I4 a        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point/ U: f8 g5 G6 U2 _. d3 b
        Dim displayModification1 As NXOpen.DisplayModification0 N7 g4 e9 \! ]# u% i2 A/ U! Q
        displayModification1 = s.DisplayManager.NewDisplayModification()5 W( S( b$ a% M6 N
        displayModification1 = s.DisplayManager.NewDisplayModification() '
# H" X5 x# y  }, S9 e- Y( v2 c3 p        displayModification1.NewColor = 7     '设置颜色
/ |6 C6 ?' H3 l, K8 k& g6 f2 q        displayModification1.NewLayer = 10    '设置图层$ V" x# p# i  v- q/ k6 v
        Dim objects1(0) As NXOpen.DisplayableObject
- N/ ^+ \4 g; J9 ]# P7 ?0 [        objects1(0) = theLine6 {, B1 b" h8 i$ ~# K
        Dim object2(0) As NXOpen.DisplayableObject( I1 |) k) \+ u
        object2(0) = arc1
' U7 ?! f+ k4 {& _        displayModification1.Apply(objects1)4 H* y& O: j1 m
        displayModification1.Apply(object2), `4 r1 g7 z5 w+ ~
        displayModification1.Dispose()
* z! D3 k9 J, Q9 g2 _, T
0 L, u! l; C. O; h4 s( W4 e; s9 b$ C4 @, _8 A/ J
        ' TODO: Add your application code here 8 N% Y9 A  Q/ E" X' W/ m

# n& g  Z* a1 C6 L6 B" m    End Sub
. \3 S. H3 J! B! p- E' E$ t6 E) W0 Y- l9 Q! f. w# u! v

' B, L$ K, r0 c# x3 {# M4 x5 ]3 d    Public Function GetUnloadOption(ByVal dummy As String) As Integer% @/ B+ O; b! O! m
, b) u, i5 c0 n: @0 |1 R' C3 p# p
        'Unloads the image immediately after execution within NX% W, a: D. L$ x% c8 [$ G! R  K% h8 c5 X& m
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
# v+ T9 H% q8 p2 @! c( B
1 w- h% m: u# ^, c        '----Other unload options-------# l" g) L) @( J7 W6 v0 l
        'Unloads the image when the NX session terminates6 ]2 X4 L4 a& \/ }% g( h
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination7 m# H8 n7 h, L+ v( }2 I- C, s
! ]8 \. ~( a0 ?- a
        'Unloads the image explicitly, via an unload dialog! R  }/ G7 k" E2 X6 I$ N- S0 N
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
+ F( c& y9 Q4 ]  B        '-------------------------------* r$ ~  G( x% u( g0 D
$ c7 M! w* u) [, D+ b
    End Function
8 t% F3 P2 Q7 \( v. i) j9 M
* l, y& V% i* l4 E% HEnd Module
+ y) B* N! U5 A* \, d
) K2 A. H$ M0 n) j$ ^$ s" c7 x$ r; @1 E
5 q. Y5 z0 M( [: a

运行时报错

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

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了