PLM之家PLMHome-国产软件践行者

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:% C# k4 T, H: }( q" X3 i

+ t2 a9 w; c* b/ e( z  f9 ]" I- A
0 R, p! z/ F2 U3 COption Strict Off
/ j4 `% i. c* b$ \) WImports System" b; X, q2 l% d4 c- j( D0 I' o
Imports NXOpen2 s$ A9 e# w3 C! l% T
Imports NXOpen.UF8 G# w3 q: l6 p) r
Imports NXOpen.UI( o: R% ?' V! G/ W1 @* U  _. C
9 P% j8 J! N# G! @
Module Module1/ E7 @: l% v# Z$ \

5 i( x' v# a( ^* @/ M    Dim s As Session = Session.GetSession()
( h; i' @2 I. ]0 ]/ W! `    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()9 g5 X3 q+ a1 O% T5 N
    Dim workPart As NXOpen.Part = theSession.Parts.Work
$ O6 v. T2 e5 z5 T$ _* @+ Z% D6 f4 |: z& B/ k1 [
    Dim displayPart As NXOpen.Part = theSession.Parts.Display4 s) w9 S2 [! v! M. x/ Z& L+ a

" W+ l7 e2 B* M) ?7 I# A    '  Explicit Activation
5 R% w* V$ l! Q2 x5 v+ F    '      This entry point is used to activate the application explicitly
0 _& L# w$ ]( A5 v7 `4 o' O3 G0 t    Sub Main()2 b8 l1 `+ \8 W0 [/ t1 o
: ^; d6 u. N7 y
       Dim sp As New Point3d(0, 0, 0)
' E& F' {$ K6 X9 @: o        Dim ep As New Point3d(50, 50, 0)' I9 X! y, A) L& ]( k  K; X
        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
% B8 j' G. m' a( h4 _; Z; e7 ^        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)
- C3 X6 z" {: \  k        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
# Q9 H- o" f  c8 F        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
2 r8 q9 H$ t# }) x1 t2 `$ s        Dim point1 As NXOpen.Point, `" v8 L% i% F& B* u
        point1 = workPart.Points.CreatePoint(sp)
% l, x/ g4 H) e) j        Dim point2 As NXOpen.Point
9 ]% A( c& \0 `" K4 d        point2 = workPart.Points.CreatePoint(ep)
2 c+ T$ p, V: N- R$ V& L        associativeArcBuilder1.StartPoint.Value = point1! h- C6 g. r0 P. A5 Y+ Y
        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point. O$ M9 g4 t8 Z, V
        associativeArcBuilder1.EndPoint.Value = point2
& L: U% i+ `7 R/ w) t        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point
$ l7 ^: ]& C" L+ Z4 l        Dim point3 As NXOpen.Point9 y+ h( D% ^4 a6 U4 s, e( [
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
* o* _& }) Y, w; R* [4 C5 J2 D( R8 k        associativeArcBuilder1.MidPoint.Value = point3) G0 G* {1 v1 z8 g! Z  S1 ~3 h
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point/ q, b" ?- h% P
        Dim nXObject1 As NXOpen.NXObject
  o9 N7 U4 f9 T- C, l1 h; O        nXObject1 = associativeArcBuilder1.Commit()6 G7 l( \" `8 @2 Z
        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)% s' ^. Z) O1 u8 R) _7 |7 v
        associativeArc2.SetName("123")& t/ y$ Q& O+ E
        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
6 e# l; e0 B( H$ ~! v: J. z        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
, t& e7 x, ?& O0 I/ N, I        Dim displayModification1 As NXOpen.DisplayModification0 f# V; }) b3 l9 h; ?+ R
        displayModification1 = s.DisplayManager.NewDisplayModification()
, p7 y8 B$ t8 g4 E        displayModification1 = s.DisplayManager.NewDisplayModification() '
% Z9 ^5 Q8 f+ C% d' Y! q' ?! ~        displayModification1.NewColor = 7     '设置颜色
! s  ~! A* D5 @( ~9 \% z/ B- Y; b        displayModification1.NewLayer = 10    '设置图层7 ~2 M6 h8 M9 p! d9 R
        Dim objects1(0) As NXOpen.DisplayableObject
0 |, m! |) C5 S        objects1(0) = theLine
# _- H- F! T# c2 m. `$ `0 K        Dim object2(0) As NXOpen.DisplayableObject1 R: h3 L& m1 t
        object2(0) = arc1
4 j& C0 O2 @# W& f; {0 K; N" o        displayModification1.Apply(objects1)7 q4 A( ^6 g/ G( z
        displayModification1.Apply(object2): N- Z- W: H( N  u$ Q* Q2 I6 D6 H% ~9 g
        displayModification1.Dispose(): S! K3 r0 }. N
' |. U) c% c% |. |  W

5 ]/ [3 _0 }& c% J        ' TODO: Add your application code here 9 U+ F5 p& [0 J8 v/ F6 j/ ~0 u
) m7 m5 _$ S2 H1 x
    End Sub
' \8 v* y+ L6 F
$ Q2 h( V7 z6 s, X, Y2 D. A+ M+ _
) f$ i) ^5 {  [9 c8 F6 k; G- \; _    Public Function GetUnloadOption(ByVal dummy As String) As Integer
. ~  G0 ?. M7 j8 h5 g$ M% i1 m
1 C. V/ Y. v) T9 q6 ]- l/ P        'Unloads the image immediately after execution within NX* P5 g4 P1 l% m" p3 r
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately2 y. X0 g" X' H. z8 f
/ @! f0 |9 ^4 k# l% h
        '----Other unload options-------
7 h( S0 j8 ]2 w# m' R  Q        'Unloads the image when the NX session terminates" K& W0 }( Y5 J
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination$ y) U! ~- P8 ~$ W7 w5 T1 f
: w1 f% x$ k" L. W
        'Unloads the image explicitly, via an unload dialog) }4 e9 i" [1 z7 z- t/ w
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
4 `! ?% A% s6 M: K9 I3 }' j        '-------------------------------
% x9 ]4 V% n1 k. R6 r1 p6 q2 R
& h1 w8 u" U' B' w    End Function
4 U' r/ v$ e1 r9 T1 I- W4 R1 J: E
( k; e, h' i9 U; e6 s, t3 w' G6 ZEnd Module5 h/ O8 O. L, i; X2 N- @1 n# V

; S# }( Y) H5 r' o, L# b
0 c3 ~6 z2 n  L. C/ ^
/ y5 [2 Z( V2 G  K8 [3 X5 d; M) D7 ~

运行时报错

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

    我知道了