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

[求助] 设置线的颜色

[复制链接]

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

5

主题

39

回帖

409

积分

中级会员

积分
409
发表于 2016-7-21 21:18:53 | 显示全部楼层 |阅读模式

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

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

x
怎么才能设置线的颜色呢代码:1 _& h, j) f% |& M; R; @  e5 Z
) f6 @( l- C2 j6 B1 t' c' r* f
7 k5 t- O2 b% G# ^
Option Strict Off" r2 d, S5 ?& ~: j% p
Imports System
# E8 E" f+ @# y" G0 K# uImports NXOpen
  v# N# n2 q9 F6 gImports NXOpen.UF
0 H+ K2 e* T# a& g6 Q5 xImports NXOpen.UI# y2 u: \/ m& x' \3 c) f* ^& k

4 [( f; F- z# |" uModule Module1/ |: T4 B% G- Z5 a

: N* ~, v6 }2 d) {4 ?0 S    Dim s As Session = Session.GetSession()8 @4 z) t/ a) N$ w+ ?$ S0 f8 g
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()3 X  K" e1 f! i! [7 q# {! H
    Dim workPart As NXOpen.Part = theSession.Parts.Work+ A% k, o7 T- i) D/ J5 Y( H0 Z+ i
5 R5 J' g/ a0 E: e  Y
    Dim displayPart As NXOpen.Part = theSession.Parts.Display7 u( S9 x7 h9 k

+ A% ^" c6 ^8 p" G& h3 o$ k) g0 }    '  Explicit Activation
3 m( I: S+ Z$ |    '      This entry point is used to activate the application explicitly
3 n) \1 L4 u, ], ?* c/ }9 e    Sub Main()  u9 ^+ \: q- A0 o9 G2 k
* |' _- t: Y( o5 e9 f3 x* w$ T
       Dim sp As New Point3d(0, 0, 0)
; @; i+ D; F: c1 a6 l/ I* x        Dim ep As New Point3d(50, 50, 0)3 U" W, h  K0 m) i; ^# }9 r
        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
: q" t5 Y, H. V/ }( }5 u, Z        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)/ }  n0 E1 s( Y8 D
        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder9 U- u. x) W% f7 N- J3 `5 y. L
        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc); R6 ^9 i! Z! `8 W" L+ W
        Dim point1 As NXOpen.Point, m4 \5 r0 @) S6 ^( W& a4 |
        point1 = workPart.Points.CreatePoint(sp)8 [. ^8 M+ g5 s6 |/ k
        Dim point2 As NXOpen.Point
. ?5 h) Q+ S* |% t  m  x2 r- I        point2 = workPart.Points.CreatePoint(ep)
' t" n( \# R$ p* ~! G9 D" m1 [( J        associativeArcBuilder1.StartPoint.Value = point1: }: y* B6 [; r# R4 A( \
        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point
7 G- u. K" l" b1 T. s        associativeArcBuilder1.EndPoint.Value = point21 r, i  Q: k8 f1 b- j8 j
        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point; D8 r+ ?  e$ ?5 `" t# T& X
        Dim point3 As NXOpen.Point
4 s% o' y+ t* I- |5 Q6 i$ W        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))& H6 x8 o9 }7 j, v7 r6 M
        associativeArcBuilder1.MidPoint.Value = point3/ b( S: t' O% {) v
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
4 ^* O, q6 [4 N& l7 c9 ^        Dim nXObject1 As NXOpen.NXObject
" [6 W1 M6 E1 i" \7 W) s        nXObject1 = associativeArcBuilder1.Commit()
% s& ^( A: O+ h* k* }# B: Y        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)
5 j+ p5 `# n# I* B4 Y, x6 \        associativeArc2.SetName("123")
1 m* D9 i6 \1 }8 z* t1 o        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)/ |2 t* T* U% a
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
# G# ]( X+ O% x6 k1 S( ?& v        Dim displayModification1 As NXOpen.DisplayModification% Q2 c3 y" s  W  G& x2 I
        displayModification1 = s.DisplayManager.NewDisplayModification()% Z9 u, M7 k% p( {
        displayModification1 = s.DisplayManager.NewDisplayModification() '
2 O, d: X( k2 d        displayModification1.NewColor = 7     '设置颜色
4 D' T, ~5 p, l* D        displayModification1.NewLayer = 10    '设置图层
3 Z. O% t9 ^+ A4 G7 `9 V) A        Dim objects1(0) As NXOpen.DisplayableObject2 [0 L& n* Q/ `' I6 Q) v. q
        objects1(0) = theLine0 r2 T8 N1 A4 E7 O/ \0 ^2 o
        Dim object2(0) As NXOpen.DisplayableObject2 j8 h0 i* `6 i
        object2(0) = arc1: _8 F! F6 f8 O2 Z
        displayModification1.Apply(objects1)1 w0 X7 S; U1 m; {9 C
        displayModification1.Apply(object2)* \, _$ g  H# E7 Q' F* R% I
        displayModification1.Dispose()5 p3 c) e, X( S+ O* {9 T+ b

9 t9 t6 `$ I' S) r1 \. f* N+ W. T! {! `; \
        ' TODO: Add your application code here
( G2 w' O6 j$ k3 Y0 |
( b8 S+ `0 Z* ], i( X    End Sub
& G1 J! F6 b7 a4 M+ f
% k9 b8 g% H( E6 ^& k% N
: N: H6 n/ z& B/ s    Public Function GetUnloadOption(ByVal dummy As String) As Integer  T) H$ O) G! Z3 d# N! T

( q2 v6 _, q/ D7 p- J        'Unloads the image immediately after execution within NX- K3 j' j' n: D" X, c" v4 u/ x
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately4 O) e+ d+ h+ t8 n
/ b! y7 [$ O$ t# K( a
        '----Other unload options-------
4 K& Z/ e/ R# z0 t7 Z% B1 J: W        'Unloads the image when the NX session terminates4 o3 }$ i' ?! j; F  z5 g( g
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination- g% `0 d2 `( A# g( n
1 p, N, L, r  `5 f3 W
        'Unloads the image explicitly, via an unload dialog
+ N. ?* P& x2 |: {        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly- ]6 W; g; U/ o0 F
        '-------------------------------
3 W8 q' A0 i% {2 i, |
+ B9 A3 [6 R! c! ]( z& Q7 e    End Function
6 W& G9 e5 Y; L: A% U: F, v$ G8 x* N* @
End Module& K3 Q( L- N4 C0 b* {
8 s7 O5 t' ~: C* K6 F
0 B/ X0 y; J9 [* u# l: j

+ |& y# d) ?; I; d0 G

运行时报错

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

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了