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

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:5 g# h8 Q& p6 V$ h4 M( N
3 J# u# g) V1 c5 z: B, a, r
4 [0 i' z! p4 k( {$ ]1 N- {4 o
Option Strict Off' v* I% a7 Q" \2 [/ O, O$ U
Imports System6 d; Q/ e% e/ R: m+ j
Imports NXOpen. w. _) P4 s" a9 |0 }
Imports NXOpen.UF
6 O3 n* }: Z4 _0 [4 v) tImports NXOpen.UI
" m. W* R. s  Z. Y
+ {8 u# \* A: ZModule Module1  n9 N( a! `: z/ T% z$ Q$ L- }

( }& q( [: ^6 D% O+ K% {; O, m    Dim s As Session = Session.GetSession()1 m* s' f, s2 `9 u% @6 n/ h
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()( _# ]* _7 q, L, u& W. t, y9 `
    Dim workPart As NXOpen.Part = theSession.Parts.Work+ t2 L2 J3 D" ?6 v& C, Y5 X

1 x( X) q+ d( ?    Dim displayPart As NXOpen.Part = theSession.Parts.Display
3 i# v3 x# ]4 x8 J+ E% K4 R3 F6 M8 x! M% r+ H
    '  Explicit Activation
9 V- `) K; C) Y! l2 R    '      This entry point is used to activate the application explicitly
0 I: z1 h* h8 D    Sub Main()6 ^' l5 Y6 b3 n' D

6 N. s$ T4 T( V; Y7 E# ?7 s       Dim sp As New Point3d(0, 0, 0), I3 H- ]! o0 J- ~+ O
        Dim ep As New Point3d(50, 50, 0)
" y' t' M6 X! X) X6 T2 L. Z        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
0 n% L# S( i% [1 B3 N9 q2 q# {        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)0 O/ M- b* Z# v% E8 q
        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder* F2 j+ d; W6 {: ^( d
        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
: C4 G; o; r6 ?! j7 m$ A1 d        Dim point1 As NXOpen.Point1 }5 ], R8 p% ^9 D% G
        point1 = workPart.Points.CreatePoint(sp)
" B( h+ A: Z, t+ S: p        Dim point2 As NXOpen.Point3 x0 Z( o8 u% ?8 p, B/ F9 `
        point2 = workPart.Points.CreatePoint(ep)
6 L$ z# @4 P7 U5 j5 g        associativeArcBuilder1.StartPoint.Value = point1
$ G7 ?0 t) \: m4 b        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point8 m) @# @) r+ F( ~4 l: M0 @
        associativeArcBuilder1.EndPoint.Value = point2
& \2 [  @3 \, b% C" t* r/ P        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point) q  o! D! t2 I0 p+ j
        Dim point3 As NXOpen.Point
6 q% b4 W! q& y& I$ j        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))' N' `% a$ C  u1 s' C. C
        associativeArcBuilder1.MidPoint.Value = point3
6 N# I% [, p6 G- O# H        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
8 E8 D6 Y; R  j& r        Dim nXObject1 As NXOpen.NXObject% T" {! `" G( x; x3 h
        nXObject1 = associativeArcBuilder1.Commit()
. O; k" q  ^; O2 E" a* A+ j1 n        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)
% F, t) D+ v$ H. d9 M        associativeArc2.SetName("123")$ |" E8 @9 _; W/ N- c* O3 U
        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)4 h/ x8 R& a) j9 j4 x
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point; z; v$ d6 n) g
        Dim displayModification1 As NXOpen.DisplayModification3 v; V) E5 o8 F; {7 X' _- l( K; M/ }
        displayModification1 = s.DisplayManager.NewDisplayModification()
* \+ j8 R; D  i3 N: K5 V        displayModification1 = s.DisplayManager.NewDisplayModification() '
4 T4 e7 s+ ?8 F0 i        displayModification1.NewColor = 7     '设置颜色" s3 b( a1 W+ E' q
        displayModification1.NewLayer = 10    '设置图层% L  C6 K& Q' g) \
        Dim objects1(0) As NXOpen.DisplayableObject
. p9 x% t  |$ \# ~1 y! v3 f: ^        objects1(0) = theLine* ?) q# C# P5 i, _# E
        Dim object2(0) As NXOpen.DisplayableObject
2 s6 }; n, l8 p# m" L        object2(0) = arc10 P7 b- @& j7 l9 p3 S
        displayModification1.Apply(objects1)
9 [$ A9 [4 r6 T, b. W        displayModification1.Apply(object2)
( O/ m, i% C* P1 L! Z0 i8 H7 O        displayModification1.Dispose(); p# F9 F0 C' R9 a$ K$ W7 t0 s8 d

  m$ q) d% B7 ?: Z3 j4 h, U. u9 D# z9 Q8 ?6 ]- ~( h
        ' TODO: Add your application code here
! z0 q' I) _' K  g+ J# r/ o" s* K0 v& E: X7 R  a
    End Sub
8 h2 I, d0 h* Y0 [; p
5 \  L( Z4 p. D& H) p
$ s, R1 Y6 J: b0 j) J2 b; X    Public Function GetUnloadOption(ByVal dummy As String) As Integer: s6 ^( m; x2 h0 V4 U& r) A' t
* A+ l2 ]( R8 T9 H; H( x# i; }
        'Unloads the image immediately after execution within NX. ?4 ?6 o& U# s6 o
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately& @9 ~3 I% x' n- |) k: x1 D

. t& D& B4 h' m2 I" u8 O6 H1 ^- y+ X! y2 m        '----Other unload options-------
9 |, R3 t  }& P' I0 D1 J        'Unloads the image when the NX session terminates5 E0 d0 Q1 z; x2 N3 G9 I! }
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination; \1 {' C4 N) x" c; S- B& J7 \) B+ ^

- @# [1 ?/ N& i: @) b( U$ a        'Unloads the image explicitly, via an unload dialog2 T5 M! ^; K8 q3 {- y4 [
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
0 O7 q+ ~& t- f; n, d& F: Z        '-------------------------------
* h6 x" _7 R; X" x& [* \( m- ~1 }  K7 `$ f
    End Function
" z# @, f3 b% t, _
5 Q# u) z( g! REnd Module9 x( B. l1 I+ H$ _" I5 H6 ]1 X+ D- `3 {
' h/ ?' s" b. J/ T9 q
& Q4 i1 z8 {  w5 w- O* H+ E
/ g0 L* W. n& P, V  G

运行时报错

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

    我知道了