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

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:3 U' v. [0 Y+ o  G8 z
* J. S+ _- B6 N% h. V

& }! s( h# p7 M3 o8 b* R  ]$ v" t; {Option Strict Off( B2 U7 @7 i* G0 O( }1 o1 O3 v
Imports System
+ L# h# B, W7 }& H8 yImports NXOpen2 c% O$ P. {* O1 |
Imports NXOpen.UF
" U' E. F* T7 T$ BImports NXOpen.UI
1 i, z+ ^" N% X1 c1 z
0 f% @- U8 @/ g1 A: |Module Module19 N- d$ Y) N9 N+ y4 H9 `  X
( o8 K; A. M$ a& G$ \
    Dim s As Session = Session.GetSession()
6 v, Z/ p9 Z0 o. R" a/ |    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()" R/ w# P( B8 R+ i; T3 n
    Dim workPart As NXOpen.Part = theSession.Parts.Work8 p" Q* w7 V( Q( R0 b
7 C4 q1 {/ o+ |/ h: r# {2 N5 I: b  k
    Dim displayPart As NXOpen.Part = theSession.Parts.Display, \& {, e9 d: a, U4 j0 w" a4 r
; s. |5 K7 k$ j# v6 e
    '  Explicit Activation' y& W: b& H0 u1 \# R+ n2 b& d
    '      This entry point is used to activate the application explicitly' }* I* ]3 `* Z$ t9 x+ \
    Sub Main()
$ @" V7 [% t4 N
( d5 P5 A4 O5 D: G/ B2 t" k       Dim sp As New Point3d(0, 0, 0)
0 F  x. F) z' v" b, y, t. R. x2 b        Dim ep As New Point3d(50, 50, 0)
. f6 s( _3 P  X1 g0 \6 o  @        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
7 B1 b6 H% J8 c0 q        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)
+ W/ \3 Z; D; P        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
% M1 H- m- `# N2 y* S4 h% k7 T        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)3 S! @& C+ H" V! q& s) E& P; o. T+ J
        Dim point1 As NXOpen.Point& h, Y" B- D& a- f
        point1 = workPart.Points.CreatePoint(sp)
' r3 z2 K, b% |$ y        Dim point2 As NXOpen.Point
- I6 i9 m9 |) N' W        point2 = workPart.Points.CreatePoint(ep)
+ n2 g# R6 w  ^* G+ U% W$ A        associativeArcBuilder1.StartPoint.Value = point1' t4 d, k% B# M. |
        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point
. g0 s$ U$ K3 @1 o        associativeArcBuilder1.EndPoint.Value = point2  j# W& A% ^$ b: N  K! X& f
        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point( n2 `9 `* W- n# N" H
        Dim point3 As NXOpen.Point
4 R4 Z8 t% Q' l0 n$ D; R1 Z        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
; X. `6 A( h3 r) }3 Y1 O        associativeArcBuilder1.MidPoint.Value = point3
7 [& D' @" }& A& }* |) {7 I        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point2 J! t. ?. B$ J
        Dim nXObject1 As NXOpen.NXObject  V' |0 Q" k  l) H6 l3 I* f
        nXObject1 = associativeArcBuilder1.Commit()1 I) j3 u. P9 h. C
        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc); D) ?- c/ Q0 n8 }
        associativeArc2.SetName("123")
& d4 K2 F1 \0 F0 K3 Z) ]        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)2 J( e5 c4 Z* g  _7 l
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point% x( C% f5 P! O5 n( v
        Dim displayModification1 As NXOpen.DisplayModification& j' [+ W# a4 N+ g; |9 p
        displayModification1 = s.DisplayManager.NewDisplayModification()
. \2 p4 x! S3 t& F" L) G1 V        displayModification1 = s.DisplayManager.NewDisplayModification() '
1 {# P0 _) ~, l! k2 d9 `0 J        displayModification1.NewColor = 7     '设置颜色
( u- O1 j* o6 b  l        displayModification1.NewLayer = 10    '设置图层
6 O" \# ^% A  r3 U& E        Dim objects1(0) As NXOpen.DisplayableObject" ]. N3 M/ N3 E  M! P( a6 N" U
        objects1(0) = theLine
3 Q! O. ]! ~& |9 h8 m2 I4 V7 f        Dim object2(0) As NXOpen.DisplayableObject
. h: v+ ~% v! O9 |' h3 j: k; d0 ~        object2(0) = arc1+ q5 H( O8 I, \1 R4 A1 m
        displayModification1.Apply(objects1)
7 T9 P( _% h, a/ ?        displayModification1.Apply(object2)
; [/ m) I8 t; {& }( y        displayModification1.Dispose()
9 I8 q% |' R* ~. C( s$ ^6 I  G% y* B- k. b* {
9 I; c+ h( P6 j+ J$ y
        ' TODO: Add your application code here
% Z. s$ f+ a+ f) |/ S1 g9 ?$ n0 u5 c  K3 O) V( F
    End Sub4 e1 `" ^6 e( [' {) [+ j

9 V3 D' X2 s* Y$ Y0 e$ U( e" }! h, V; f
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
  D* w% o, Y5 u" h1 n0 q* U6 ~& Z" w. {" I9 l2 i3 b) s. f
        'Unloads the image immediately after execution within NX* |8 v+ @: ]/ z( |/ |
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
0 Y/ C, X% ~. X9 ?& a+ n7 D7 t3 p. d0 x) ~; _' c
        '----Other unload options-------
. l4 q5 w  O- Z) Q6 ?7 o& Y        'Unloads the image when the NX session terminates0 y8 l/ l: I5 T5 C- t) j/ I+ m, f0 r
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
" f% ^0 o& y* ~7 V! D& s- A- n, n$ _5 u; O4 Z' Q; x& k  v" r
        'Unloads the image explicitly, via an unload dialog
8 `& ^+ r* f5 E! h8 u        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly6 z8 s' r+ F7 k3 r
        '-------------------------------2 `( t2 q$ ~  {7 r6 t

+ n% E% {* l' ?    End Function
- ]8 @! L" E4 I. r, T& B) \7 ~) G4 E, N  I) N3 e/ ]" F
End Module
* H& f% @2 k7 t6 j
9 C( z5 u: W' N- u9 `5 @( m) I2 k3 @7 V* Q% D! E

$ A! @3 Y0 O' \$ u2 `; J4 k

运行时报错

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

    我知道了