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

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:
. [9 N0 a; H) J  D* ?) Q7 G6 m
0 a7 q+ @1 a0 s0 J% g) _* B& I5 H& F  s1 h# I* g: f
Option Strict Off
7 D3 g; {2 W' F0 C6 @( e. k) XImports System
- E6 f3 W% N& s0 h% ^2 l$ D: \, pImports NXOpen
* Z1 I! H6 i* }Imports NXOpen.UF, [& J* P& a$ a1 ]7 P# a  j
Imports NXOpen.UI* |  R$ m: f5 B' d- w
9 q& i' n8 G8 d+ G3 u, \
Module Module1" K$ P9 e9 z3 n8 ]" q

) d+ F' W# ]4 j- t" P  L/ @    Dim s As Session = Session.GetSession()
- J0 \7 @- l8 H. G) n9 n    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
  v, a8 ^! ]6 A9 p8 f( Z    Dim workPart As NXOpen.Part = theSession.Parts.Work, S3 M: v3 g4 p* n8 A! R( c
6 V2 x2 a& L6 q, H$ ~: }; M
    Dim displayPart As NXOpen.Part = theSession.Parts.Display
  V' w+ e9 g8 w$ o, {$ Z! t) |% H4 Y6 I
    '  Explicit Activation
1 \" r9 w, m  D5 a2 R# p% ?    '      This entry point is used to activate the application explicitly3 F5 W. C/ x+ z" |$ {) Y; W5 O
    Sub Main()
4 _; [2 V' J$ k5 S- s! B9 V; h1 H) z' @& E5 E8 C1 \
       Dim sp As New Point3d(0, 0, 0)( _( s. V$ B8 }1 t0 [
        Dim ep As New Point3d(50, 50, 0)1 }, S9 w0 z2 Q( X) @% K
        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing1 o# V. g0 p$ A
        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)
: s. a2 S% ~# [( x        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
% Q& {4 y0 I$ _. b$ h7 K        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
/ u; K. n9 [- B        Dim point1 As NXOpen.Point; N2 y3 E* ]- `4 g( N
        point1 = workPart.Points.CreatePoint(sp)
. f3 ]: J& C3 y) W        Dim point2 As NXOpen.Point
( ]: Y% m: S6 p8 a+ M0 d8 A; W        point2 = workPart.Points.CreatePoint(ep)
0 v9 Y2 V5 x( a* E! n0 `) h% |        associativeArcBuilder1.StartPoint.Value = point1
6 x! o0 O- Z. o& Q: ^0 W* `        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point9 h) c. d/ Y6 i, L  d* c% B
        associativeArcBuilder1.EndPoint.Value = point2& Q- U8 \* y. O# U5 F
        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point& y% B9 _. E# j8 S  x' F9 `  I- k- w
        Dim point3 As NXOpen.Point
* S0 H6 v; I1 l% d2 L7 G' [        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
: w- R1 j6 f% a& ^        associativeArcBuilder1.MidPoint.Value = point3. J) [3 F3 D- b
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
- I! Y) S+ N8 J- J$ W4 V        Dim nXObject1 As NXOpen.NXObject  _' E& F; S3 ]' E: p
        nXObject1 = associativeArcBuilder1.Commit()
/ W8 S3 e8 q! F+ H9 \9 K0 c        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)+ K4 ]3 r7 Q( d1 v4 L+ m
        associativeArc2.SetName("123"), m0 t* B! w. O2 D: {
        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
  V* s6 B- d; \% y3 R        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point2 V! X' @7 w6 i4 A0 e1 z
        Dim displayModification1 As NXOpen.DisplayModification: b. a9 L2 A" j- p
        displayModification1 = s.DisplayManager.NewDisplayModification()
! d) @7 A3 O; M" g% E  Y1 ]        displayModification1 = s.DisplayManager.NewDisplayModification() '
% U  d. @8 U  [( A        displayModification1.NewColor = 7     '设置颜色& ]& }9 p/ b# J/ c. s
        displayModification1.NewLayer = 10    '设置图层6 {, b$ v( f7 o$ J" c2 s7 x
        Dim objects1(0) As NXOpen.DisplayableObject2 p; r; T9 e0 Z6 y3 A0 X
        objects1(0) = theLine7 e( F" A" j8 G' [$ J
        Dim object2(0) As NXOpen.DisplayableObject. y" F5 b+ X- B6 l
        object2(0) = arc1+ P+ m& j, k9 A6 \& d
        displayModification1.Apply(objects1): X# p8 ~4 |9 Y8 M
        displayModification1.Apply(object2)) D: O" Z' I: l' U+ F
        displayModification1.Dispose()
$ R' u: u" c8 z7 S+ `" |% F7 M( `; z' y) E$ g1 T

- a2 B; n8 u) M- U. C$ s        ' TODO: Add your application code here 3 J: h5 ?$ Y; ^
1 ]5 b9 M. P0 D4 l, y9 e
    End Sub
2 {. O% L9 r  V% H% ]3 |+ i9 y: L9 ^/ S( G( a8 ~2 V

6 z; @. o$ ~+ j& D* Z3 V; N- D% G    Public Function GetUnloadOption(ByVal dummy As String) As Integer
& C; t) T. T: ]5 s  d
" G& H5 L8 P8 ^, P- e5 c$ ~: Q9 j        'Unloads the image immediately after execution within NX
3 h) W) b( c  ]+ b# g7 @# n5 X! c* I        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
( s% q2 a8 l* [0 |; H
: D4 t" C& B9 v- ?' }        '----Other unload options-------
3 `9 }( W: h; p2 A0 A        'Unloads the image when the NX session terminates0 U8 O# a. T0 h5 }& W2 m0 U
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
$ u  ^* ^4 o$ }0 F: ]
' n( `; s- A  }        'Unloads the image explicitly, via an unload dialog7 l  t) K8 Q1 {6 x9 {% A. p
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly. U# b" k9 e- n0 `$ K1 }4 V, g& P5 v
        '-------------------------------
. m( ~$ @( k3 V( t
4 |6 T+ l/ R6 ~& I: F! D$ ]    End Function" r& o& d; T& ~! [$ k
+ n! U# \3 l  P2 V
End Module
5 J! Q# j* X& n9 ^3 P" J( V0 _0 }5 a  o
7 J1 o# i# v' U  `
6 |3 C$ m, y8 b

运行时报错

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

    我知道了