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

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:5 B- K# h5 T8 A5 x; W- H4 Y) g8 x( e
4 Q) t* ^5 d" r/ I( {& {

1 o$ L- F, n/ M" I( OOption Strict Off
5 n+ ~& W4 |# w2 y1 C- jImports System6 |5 P/ ^: U2 B5 {5 z& n
Imports NXOpen
# i6 j" N9 t; ^+ _& kImports NXOpen.UF6 Y) x( U; o! n+ t- Q
Imports NXOpen.UI4 C) `9 Z8 M. k, u' P' u

& \9 _8 w+ N* I% i; y4 yModule Module1- o5 r" i2 p+ F( ?5 D2 [7 O7 D( }

# Z9 `( `0 e" [% @$ ^- c5 Z    Dim s As Session = Session.GetSession()9 \" ]; Q0 o5 W0 L7 H6 g8 N
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()8 c! i6 M  X( Z& u
    Dim workPart As NXOpen.Part = theSession.Parts.Work5 p9 b2 @9 Q1 s- y

' N, C1 z1 F, j' `7 v    Dim displayPart As NXOpen.Part = theSession.Parts.Display
. C, ^0 h3 C( B5 E  U% }+ o; i7 z% |
5 h7 U# |9 b( `8 q; u) w- G7 s    '  Explicit Activation
9 z* ?* h: v' v, H% Y; I    '      This entry point is used to activate the application explicitly6 g5 _9 a( \' n. ^) u) a2 K" F% J
    Sub Main()! H* M7 E0 Y& S0 `1 o" Z
0 A, ]; M' t5 y# ^
       Dim sp As New Point3d(0, 0, 0)
2 {/ D7 K# s0 s' {& r, i! V        Dim ep As New Point3d(50, 50, 0)
$ y  k- V) |2 i$ a4 `" T" x        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
$ ]6 i. o4 \+ K+ a. t) {2 @" t( W        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)2 F8 j1 Q3 k! I# q
        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
  b) s! ?4 [( ~1 v" ]: r+ @* }: R        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
# Y9 I" t2 g  F        Dim point1 As NXOpen.Point. V+ t2 ~+ \! }, l6 m  v: b/ g
        point1 = workPart.Points.CreatePoint(sp): S5 [3 o7 r3 R& w2 }0 Z% x5 `
        Dim point2 As NXOpen.Point! W$ l7 ]$ _% i' z1 b! T1 B. z
        point2 = workPart.Points.CreatePoint(ep)
( w" a, a' m# i; V2 I! Z5 P& T, Q        associativeArcBuilder1.StartPoint.Value = point1" M7 w  m, f- P0 A) z# Y
        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point
9 p- D* a) E8 h# B* P7 t        associativeArcBuilder1.EndPoint.Value = point2& Y- ]# {4 w: f( O0 t" {
        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point
6 z' M; P; y; w5 X( R" N/ ~        Dim point3 As NXOpen.Point+ s+ q9 v- ^! S+ B; D
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
7 [* ^5 [/ W, U; P9 j        associativeArcBuilder1.MidPoint.Value = point3
8 {- }+ K" q) E1 b        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point( W* J( W0 n7 i
        Dim nXObject1 As NXOpen.NXObject) V( W, H3 N; `, k& C, e; F1 t
        nXObject1 = associativeArcBuilder1.Commit()$ v0 @* B1 C" ~1 f; o" N
        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)
0 A, r7 ]9 ]( N        associativeArc2.SetName("123")
4 n: k* V, R. X        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
, b& O6 u# S# \  o9 g1 v  I8 C        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
, B6 \; B! M, m) Z. Q        Dim displayModification1 As NXOpen.DisplayModification. k/ N. y4 u! `' L1 O' O3 j% p
        displayModification1 = s.DisplayManager.NewDisplayModification()9 ^) Z* @6 w5 o4 a
        displayModification1 = s.DisplayManager.NewDisplayModification() '- X  Z* e- \, A9 l* u4 j
        displayModification1.NewColor = 7     '设置颜色
# z6 _* W; y& O2 h+ M' N        displayModification1.NewLayer = 10    '设置图层5 w( W7 i$ J1 B5 k
        Dim objects1(0) As NXOpen.DisplayableObject: Q$ d' z' M; P; `: B3 `. }9 K
        objects1(0) = theLine- d+ v% I( o. a5 q$ }4 v
        Dim object2(0) As NXOpen.DisplayableObject: V3 V/ O0 |& \5 v  e6 c
        object2(0) = arc1# f& N  ^+ @) p/ x  ?
        displayModification1.Apply(objects1)
2 N* i0 D, I) z* ?" J: a1 p        displayModification1.Apply(object2)
; F! q! T  H6 V9 E& Q) j' S; x, K        displayModification1.Dispose()
8 }% o6 T0 h& Q) P$ M7 _4 I7 o% o: I8 V+ k( w6 U

1 F/ p" }  f& Y! v6 T6 e        ' TODO: Add your application code here
/ X3 r/ s& m/ j/ X6 i+ e- |1 W0 R
    End Sub
: z6 X, v$ c( C/ T) b( ~
; F0 l+ g7 N' Q2 X
4 e" ^- L$ J* x/ z$ b    Public Function GetUnloadOption(ByVal dummy As String) As Integer
5 |; s- s- e. Y7 u4 `' b) k7 @4 ?; }5 s: [3 r4 A6 n& R' L5 v9 @
        'Unloads the image immediately after execution within NX
8 |0 `; }5 J) ?        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately7 Y4 b3 w# ~! t6 t0 @
  ^; H* V, F/ y/ R! v
        '----Other unload options-------# H" L) N2 d+ |3 f4 D. j/ {" J7 I
        'Unloads the image when the NX session terminates
- ^/ i' j4 O! _9 d( m- F. t        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
8 @# d6 V: J9 H+ A9 T' g+ w3 S
        'Unloads the image explicitly, via an unload dialog  r, F* i, ^; _3 b' a
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
, S. d: [( p8 J' ^        '-------------------------------! q, ~( V: h6 _. H5 N

% H1 ]. L  Z' E5 G    End Function4 q8 y" u0 G3 V  f: T+ |! P, o0 P

+ X! G1 {+ X9 V' KEnd Module: s. {$ G7 K) T& o
1 U/ f( Y& F; L1 z

8 I  Z( b. g: I1 E* F& H9 Q8 m' F) n4 b2 H2 ~' S

运行时报错

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

    我知道了