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

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:/ B$ E. w( s. g6 I  P

7 [5 B! K0 G+ ~. y* B
4 K7 H' r+ R; ~' O. k2 S/ }( q8 nOption Strict Off
9 a# {& t1 n7 EImports System
6 V- i; N$ `9 e: b$ ]Imports NXOpen
: N: \8 d5 @0 u7 Y  o& K, m* I3 jImports NXOpen.UF, C, A- U- G+ O' k2 D
Imports NXOpen.UI
- E- }( j+ U% D1 X' h+ A$ K
% P; y( b" @0 x" ~+ j! C. i: j$ z: |Module Module1
8 ^, [; E/ a  d* ^: e0 |
$ Y' ^; U6 n- ?7 W4 u$ d/ i    Dim s As Session = Session.GetSession()/ s8 Y' C6 R" |: d' x+ j7 C
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
/ ]! Y8 u' Y, F# R; @! e    Dim workPart As NXOpen.Part = theSession.Parts.Work
; H: o6 Z6 u7 o3 t0 Q
# L7 ?# K; J+ y1 Y1 x, C  j    Dim displayPart As NXOpen.Part = theSession.Parts.Display  J- L3 O  M) Q
9 r( M8 e9 S" m' x! a% \+ ^
    '  Explicit Activation
! b3 v$ m* K8 y  L5 _8 ~6 |6 B    '      This entry point is used to activate the application explicitly
( @' p5 O3 B) s6 o+ u# x6 Y    Sub Main()! |- i2 o! }6 h
4 e& M# r9 e  t, l; u3 d
       Dim sp As New Point3d(0, 0, 0)
7 A% B7 s+ d. \( l) j9 T        Dim ep As New Point3d(50, 50, 0)- o" O5 D# p; b. k& F+ g; Z
        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing& x/ C2 [/ J* m
        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)
& z5 g2 D. s% |5 s+ d        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder5 O5 {! h7 D# X% h
        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
4 |) l) y9 _) @% K. t        Dim point1 As NXOpen.Point# j# Q9 W' H8 S( q( l
        point1 = workPart.Points.CreatePoint(sp)4 q% Z7 ~1 q# n& p1 }; L
        Dim point2 As NXOpen.Point
) L0 Y6 z& l% E5 U: z4 o        point2 = workPart.Points.CreatePoint(ep)
% ^  _  T4 ?6 Z3 H  q        associativeArcBuilder1.StartPoint.Value = point1
9 b; t9 M7 ~. y$ c0 T        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point" U: Q; [9 a% A& c; U
        associativeArcBuilder1.EndPoint.Value = point2
/ F0 K7 g4 T2 c& C$ }  V        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point  D9 `: n- n" e7 B! T+ Y
        Dim point3 As NXOpen.Point' Q- g7 M3 u. e% p
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))3 Y: b$ _, X4 P* `0 G
        associativeArcBuilder1.MidPoint.Value = point3
/ H2 S  K4 U- L# O: G# e, h$ M# S        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
0 P1 W0 I8 L* o1 G$ _- R        Dim nXObject1 As NXOpen.NXObject) N5 [' i" |% b: P  B
        nXObject1 = associativeArcBuilder1.Commit()
  ]6 ]2 \( A/ `) c* s2 n8 r! r        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)
8 h% ^- S6 u9 |, G0 c  S+ g" m        associativeArc2.SetName("123")# k# {/ i0 v/ m
        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc): J5 v" @4 L, J2 f
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
2 W& |4 R8 I& C8 S7 k        Dim displayModification1 As NXOpen.DisplayModification7 s% Z7 {9 y- _! C  Z  |5 V
        displayModification1 = s.DisplayManager.NewDisplayModification()5 ~5 d1 B% R9 l6 B/ R" w
        displayModification1 = s.DisplayManager.NewDisplayModification() '
- x4 P) U+ t9 ]9 c' ~        displayModification1.NewColor = 7     '设置颜色
1 J, E3 R) q8 R% u7 j. p        displayModification1.NewLayer = 10    '设置图层- S! N* d2 V* s
        Dim objects1(0) As NXOpen.DisplayableObject2 n" `# G$ `! Z* T9 Z+ m
        objects1(0) = theLine
/ |+ m. t. O) z; F& g        Dim object2(0) As NXOpen.DisplayableObject3 W7 W7 E+ G0 c" z9 L& x( c: |/ A
        object2(0) = arc1
7 Y) q' |* a9 }- e        displayModification1.Apply(objects1)
' w2 o; x  j! G4 T" N) X        displayModification1.Apply(object2)% R- y* @- Z' `
        displayModification1.Dispose()4 q8 J  M5 K$ \. i
- @) S/ h% J; q/ C3 M+ s
+ ?" o: E( t1 S
        ' TODO: Add your application code here
6 E1 s& ~) W7 i) g- Z
) j& h2 E! C6 |, Y5 [$ ?# k9 V    End Sub. @# b( r2 f$ T7 U, P
% G# o6 o* \8 H4 V$ ]; }

& p; K+ b/ E" V- T9 c; ^    Public Function GetUnloadOption(ByVal dummy As String) As Integer! u# @$ t3 {" j# r! X

# Q+ r8 c! J& t) S( N7 f) {. Q' r        'Unloads the image immediately after execution within NX3 r" b! p6 S+ {' R7 D
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately( H5 J3 ~- d8 n1 n

& ?' H# K7 i, l# \2 [        '----Other unload options-------8 I; m$ e0 u* Y( N" P4 }
        'Unloads the image when the NX session terminates. R( `% E, o2 B. ~* o
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination9 x9 \7 c7 t# R2 H
% a' n" P6 u. o" S7 j% R
        'Unloads the image explicitly, via an unload dialog
, R1 b$ [  ^- s" F# |4 ~        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly% t6 s. F9 \. Z  r: k5 Z4 P
        '-------------------------------
1 l6 b9 ]  x7 y) k" x0 N" K, M: G# h+ D  g) s% S, `7 h: o
    End Function2 M4 w- l4 G8 T1 s
/ Y& z  v; |; b* f
End Module. r% O. x3 K' q* V1 ~" q3 t

! B+ l& A  e' E
2 c* F! e$ f% V5 E  T1 D. }# U) Z# ~8 P; `) L$ ?

运行时报错

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

    我知道了