PLM之家PLMHome-工业软件与AI结合践行者

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:
. `  |6 h, ~1 s6 `) U! z5 U7 x" d$ D' L2 Z; p- r7 i' L( M

# m7 _! E, Y8 [! @; xOption Strict Off( K1 p3 N3 d* X1 Q4 r) i3 ]
Imports System2 {0 q; J  y( t: x8 {
Imports NXOpen
+ D0 c( j2 j- {% AImports NXOpen.UF
6 I( a/ g4 U, l6 _3 {5 yImports NXOpen.UI1 Y1 S& B# A6 m! i

/ P6 _& m" G, m6 [2 VModule Module1
6 A( `; [# Q# w, I% k
4 X9 E2 b9 V% `2 d0 y    Dim s As Session = Session.GetSession(): W$ d$ w) R/ ~6 x3 K9 }
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()% V6 Y+ A" s7 R0 E; R% U
    Dim workPart As NXOpen.Part = theSession.Parts.Work* R4 B7 P$ S1 b: E
8 e* T- O; h/ W( U4 x% N( R2 ^+ V$ J
    Dim displayPart As NXOpen.Part = theSession.Parts.Display
0 x' U7 ^  y4 Y3 c% }
' z) j( m/ Q* `7 F: x    '  Explicit Activation
. }! b2 n* J- O    '      This entry point is used to activate the application explicitly
7 N* P9 K/ V% i    Sub Main()
6 n8 d: u7 Z. u. u/ ~
: A5 w+ Y# D9 o& S       Dim sp As New Point3d(0, 0, 0)
; V3 F8 k! |+ l% ^        Dim ep As New Point3d(50, 50, 0)
' B* j, X+ P2 n        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
8 i" m& G! }+ H1 E1 y4 g4 A        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)
" ^$ {0 D3 L5 U: M. I5 J3 v% ?        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
8 V- f/ t1 ~+ X        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)* x% O! H) g/ m: G
        Dim point1 As NXOpen.Point. g% ^5 W: G- f: P  Z' S# Y
        point1 = workPart.Points.CreatePoint(sp)
& h7 ~3 `2 O9 \( X. @        Dim point2 As NXOpen.Point
# N6 ]% r/ N) G8 A& [) ^3 j4 X        point2 = workPart.Points.CreatePoint(ep)
$ P' y3 \5 _$ `- v$ {3 L  r; D        associativeArcBuilder1.StartPoint.Value = point1. |" q2 J" e% f
        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point' k- ]9 ~" l6 k% N* |  |
        associativeArcBuilder1.EndPoint.Value = point2
; L! f: @4 F- L3 V# F        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point# x1 ]) W- u7 j" _4 [: y& M2 p
        Dim point3 As NXOpen.Point
# y" i1 a, e9 N; s+ {        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))! H2 Y- N( w0 a8 i
        associativeArcBuilder1.MidPoint.Value = point3
3 S/ F" }+ G, N8 s. c2 \        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
; o8 j* B" b# j$ s0 F        Dim nXObject1 As NXOpen.NXObject
  x: H7 F- e: J3 ?: P        nXObject1 = associativeArcBuilder1.Commit()
! ?2 w/ s- G& S8 S& C        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)8 q' @2 G8 i, V3 K
        associativeArc2.SetName("123")
9 W, E1 Q! W% k8 h2 v9 v" Q        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
' R% o/ p7 N6 O        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
+ i! K" ^% ]6 }        Dim displayModification1 As NXOpen.DisplayModification
  X4 ^  S! _" C- r- I3 t        displayModification1 = s.DisplayManager.NewDisplayModification()
6 W9 {! t0 F' b  E3 [; C& o        displayModification1 = s.DisplayManager.NewDisplayModification() '
  U. n% ~3 K. c7 B: {( Y* m        displayModification1.NewColor = 7     '设置颜色& E  R. V. ^% q
        displayModification1.NewLayer = 10    '设置图层9 h6 \, M3 v9 I) V, M6 [* K
        Dim objects1(0) As NXOpen.DisplayableObject9 m0 f- F2 d1 z- B
        objects1(0) = theLine
8 e' `/ A; x1 h" d/ E1 o" |! Y. m& f        Dim object2(0) As NXOpen.DisplayableObject
4 W6 M& b( f: N/ {! ?1 w) r        object2(0) = arc1( X% v6 i6 \+ {9 u
        displayModification1.Apply(objects1): x$ x; S' A7 T  @
        displayModification1.Apply(object2)! w9 |% e+ i' ^$ L. f
        displayModification1.Dispose()9 ]( E# Z" `5 A4 D; P2 r8 l

( }1 D1 e& F' G% N9 b5 n( B* V# i% x" O' M; B3 D
        ' TODO: Add your application code here . I/ v4 d. f* X. c8 I

9 P5 _) \% N) g! Z9 S# a2 h1 P& F    End Sub
$ {1 V1 Y; N0 V, g) {. u2 r& F( Y! \  i4 x9 S6 z* A

7 |% y9 M" g) S3 t    Public Function GetUnloadOption(ByVal dummy As String) As Integer/ ^- M+ k% P# B* v
' E) @$ l) g& d7 x5 `
        'Unloads the image immediately after execution within NX8 R4 [3 X8 P* v# Y, r8 r/ O
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately6 m' c8 f; z  C, k

6 Y* e7 Y) G, g, A        '----Other unload options-------
) x' t  a8 [% _4 W9 S! i2 |! I        'Unloads the image when the NX session terminates
, c1 R* i% }- T8 e        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination. m/ N+ l0 F- g% |) U6 v

) V4 @7 r1 a) v! H: A, V- y' Z9 {# L4 W        'Unloads the image explicitly, via an unload dialog
% v; M% @! Z* c) J        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly0 o, b0 V3 _2 _# s/ b/ L0 h2 U, x: x3 C7 g
        '-------------------------------& q: Y5 G# h# q- _- C& Q" ?
" F  Y1 [" _) C/ k; o* i
    End Function7 v# \3 S( G% i
9 k7 e- C) U5 g- l9 u+ |0 ?; }' c
End Module
  Q6 }6 m) k. a" I- X9 [* G" W5 _: S, z3 l, {( T& a) H

4 R' }; K+ `( I
( i: p$ l0 V/ _" R( t

运行时报错

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

    我知道了