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

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:
. w/ f& V) H$ {. L
" p: v# A6 R% N9 L' t( s5 h; Z4 r
Option Strict Off
4 B7 X' P- h5 V: w6 OImports System. n% ?' K6 R* ^
Imports NXOpen
5 A; r( e5 g, a3 _3 G5 G5 G. PImports NXOpen.UF
: i& o$ b5 C  x, J. l( YImports NXOpen.UI$ W* w9 N% f0 g

4 J" K& |: J: i0 ~' }- @Module Module1  A; ?, M- ?! ~+ T

' O; E4 h9 ]1 u3 h# D' i    Dim s As Session = Session.GetSession()2 {1 r9 G+ u- ~5 q# w
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()( z2 L9 o3 }9 s# v$ a8 J8 C
    Dim workPart As NXOpen.Part = theSession.Parts.Work
8 T0 u9 c) [: h* R6 g- o! D1 @+ `* ?" O
    Dim displayPart As NXOpen.Part = theSession.Parts.Display5 p8 R( t6 E9 i, R% C  _( V0 r9 W# j
* x5 q3 c% [) F3 d; v, R  f& j3 z$ N
    '  Explicit Activation
. i6 S+ k+ l/ h# c0 c    '      This entry point is used to activate the application explicitly( ~  T- M4 i! N& D3 ?1 ?- _4 L
    Sub Main()" r" |% B) i+ g3 O% c% j: e

) J) B8 D( I4 Z       Dim sp As New Point3d(0, 0, 0)
! y1 u% _* ?4 x) i        Dim ep As New Point3d(50, 50, 0)4 m) i$ X# e% s8 {8 ]
        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
4 n: g. c. m1 q& w* |( o! {$ N        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep), ~, u8 F% q, ]4 s4 b  p8 Z) ?1 Z
        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder' g! \6 _/ p! H& u1 {1 n
        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc). A! e" K3 I+ `/ [
        Dim point1 As NXOpen.Point
8 \2 f6 [9 d! |' W9 @        point1 = workPart.Points.CreatePoint(sp)/ @4 {& p% q" @. ^. s2 K
        Dim point2 As NXOpen.Point5 h' \; x. W0 g4 T' i5 p
        point2 = workPart.Points.CreatePoint(ep): S! z; e; [, ~' A! T
        associativeArcBuilder1.StartPoint.Value = point1
- f4 D# X* _3 U/ ^        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point
/ [8 v0 d; z) @  F# O+ O        associativeArcBuilder1.EndPoint.Value = point28 R4 k) D6 _* n8 o
        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point6 {" T; x9 [/ m( S9 z, C0 g4 Q
        Dim point3 As NXOpen.Point) U+ L! \, k' n- e/ b% ]
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))- |+ @# h7 a* P" A
        associativeArcBuilder1.MidPoint.Value = point3
+ [" @. j% w5 n: a8 Y# P' x        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point4 Z3 a. a2 P& d* L+ `; C
        Dim nXObject1 As NXOpen.NXObject; m; U! P3 |; J8 |) v
        nXObject1 = associativeArcBuilder1.Commit()1 j% d3 y6 `$ H; D  @
        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)
2 L1 F# t1 N6 G  W4 w, f1 |* W. z# M' s        associativeArc2.SetName("123")
/ q1 I) x0 H6 h+ n        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)$ x, r6 h. ?' U" q
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point: \6 O" }3 J3 a! e" q
        Dim displayModification1 As NXOpen.DisplayModification
9 Y. e+ W) H: N3 [5 ~        displayModification1 = s.DisplayManager.NewDisplayModification()' w+ X: Z/ J! A* m( P1 |
        displayModification1 = s.DisplayManager.NewDisplayModification() '$ N, }$ m$ M' d8 f5 t
        displayModification1.NewColor = 7     '设置颜色7 o: d  y* @# R! K. j. O
        displayModification1.NewLayer = 10    '设置图层3 J0 L- v" m2 e" w- X) m2 P) {9 K
        Dim objects1(0) As NXOpen.DisplayableObject5 }& E  J+ @1 c! W% ~5 N" c
        objects1(0) = theLine! h7 Z3 w4 C& z( D2 w( D
        Dim object2(0) As NXOpen.DisplayableObject: Y  F$ {" V: d: n- b
        object2(0) = arc1
* M$ A& j( c. [        displayModification1.Apply(objects1)
% Y; `8 C3 I; I; `        displayModification1.Apply(object2)6 b8 ^+ I- a" C
        displayModification1.Dispose()
3 I4 K$ W. z) n* ^0 a' I7 D, c# Y
! b) L" n, E  `6 p# l0 g$ U( S& \' L2 c3 A* }0 j9 p6 e
        ' TODO: Add your application code here
* T7 L! O& w( m% `, [; b, F
) N  B' ^; _5 s3 Y4 G    End Sub6 k  p6 g# [* i& k1 a$ \* M$ k: e" Q

$ C5 m8 j) {* K6 Z; E
, r- Y+ Q5 J6 u* S    Public Function GetUnloadOption(ByVal dummy As String) As Integer3 o* ~% {/ t. p# n% S4 m  E; F, S

$ [+ p4 S3 w& X) L. X        'Unloads the image immediately after execution within NX
* ~* r3 k2 {& l0 s$ ?, C& |! G2 T        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
( \1 a" c0 ^# n$ M( u( w* A4 ^; ?1 b. S6 u
        '----Other unload options-------4 g2 A  r2 ~- ]7 n0 ~
        'Unloads the image when the NX session terminates4 X: w" E1 @7 E
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination, K9 h& @; Z" b! G$ K
$ M2 `( }9 Y$ X% U; M# x
        'Unloads the image explicitly, via an unload dialog' I6 a8 g0 I5 f. @6 A9 D# V
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly4 |, A3 `0 [2 W
        '-------------------------------
% F/ f7 _6 _; B! w* ~
8 L# |6 v" M/ o- O/ ?& ^    End Function
# t, e+ W, }- m) y6 f4 j/ U
# ^. R" [; n2 X' r/ e1 `, M- tEnd Module
9 j& A* b8 f8 l
5 J0 `2 Y; H+ Y2 ^
, o0 N6 u$ s4 Z  k' @  F, E. w% _6 Q

运行时报错

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

    我知道了