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

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:' O; ~& K0 b$ ~5 H9 a% T
9 B4 M) b4 t  s4 v2 N  \- Q9 C
; S9 h, K' A9 x9 b; N: P- ?
Option Strict Off
8 p- Q( K% d6 {! y  N: \# {/ _Imports System
+ r- p% Z0 q9 k# T4 d% M4 xImports NXOpen
( k! B+ X3 G& g. K8 v; p: hImports NXOpen.UF" N) \4 j' O$ N1 T5 M1 Z
Imports NXOpen.UI- @4 |$ c5 p: q0 B1 [, }

+ h( p  a9 n' lModule Module1
" T7 ?0 A; r) E( h+ }3 r
1 j, C$ O. j5 H6 F" p: n    Dim s As Session = Session.GetSession()
1 n6 s7 n* e, n) P0 s1 W4 r% t9 {* Z( E    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()* K; P9 F7 W& F/ G
    Dim workPart As NXOpen.Part = theSession.Parts.Work6 i4 f% o: D* J5 v( v5 K" n

. Q. D! {! [0 r; y    Dim displayPart As NXOpen.Part = theSession.Parts.Display
. S0 a& O6 D1 [& v% L) R6 p# ]+ ^3 ]- a& P8 U& q7 e+ b  E5 h8 P
    '  Explicit Activation
+ d; z8 H8 j0 g2 x7 t7 i    '      This entry point is used to activate the application explicitly
" `( m1 p  d1 o* ?. w: W2 x1 ^* b    Sub Main()
# M( u8 R; x3 Z5 y) i5 x
" _" k$ O* m5 A: u" N$ Q$ }8 Q" S% E       Dim sp As New Point3d(0, 0, 0)
0 V8 y' n3 c4 P/ k        Dim ep As New Point3d(50, 50, 0)
  c/ L3 d& P( U5 {! g        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing" d2 ^% O  \. m( g1 T
        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)
* ^9 q) e$ r8 v; f& F$ H7 x; ~        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder& M/ R4 y" l  a: w/ _( h
        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)$ e" v5 z$ G) y) f% [+ i
        Dim point1 As NXOpen.Point9 y0 Q" U7 I8 R' a7 y
        point1 = workPart.Points.CreatePoint(sp)
9 S, u% N  V/ m: i$ }5 d. @        Dim point2 As NXOpen.Point
1 N" B. U( n. l' b; H9 N- ~        point2 = workPart.Points.CreatePoint(ep)) \2 n/ F6 c6 w: m% P: b
        associativeArcBuilder1.StartPoint.Value = point1/ Q- |! e" {2 b! W( u
        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point
$ `( q# G. X+ [" R/ V- P& r        associativeArcBuilder1.EndPoint.Value = point2! a( }$ M+ I( P; M# u
        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point
; A% I* @" k; h& E7 m3 `        Dim point3 As NXOpen.Point5 F8 f0 Q1 v( a: ^0 C
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))( o! U; a* D# D9 d; M7 N5 Q9 X
        associativeArcBuilder1.MidPoint.Value = point3
# M. v8 e/ a4 k$ q/ A        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point+ c, X1 t# \+ x
        Dim nXObject1 As NXOpen.NXObject
2 D/ x5 M1 ]+ L. H7 [        nXObject1 = associativeArcBuilder1.Commit()
. p) H: D- y/ Q        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)
/ Y! z5 M4 w, C        associativeArc2.SetName("123")6 e2 }: [/ J" L7 \, A
        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)* _/ _9 S) r& Q
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
& U6 {' o) {! D! J/ X: w' e        Dim displayModification1 As NXOpen.DisplayModification
9 c( _6 V! a8 f+ O6 v9 N+ i        displayModification1 = s.DisplayManager.NewDisplayModification()
- ~; t' v9 M0 u9 l& d        displayModification1 = s.DisplayManager.NewDisplayModification() '4 p$ [/ s5 a  ?
        displayModification1.NewColor = 7     '设置颜色$ _5 L  l/ b& Q- G
        displayModification1.NewLayer = 10    '设置图层
8 e6 _  Y% K$ X# X; X( W, o/ G# G        Dim objects1(0) As NXOpen.DisplayableObject
6 t( |+ z$ {" D        objects1(0) = theLine7 y& T  G. K( e7 c( D$ V7 K
        Dim object2(0) As NXOpen.DisplayableObject
) e0 R9 n# W6 J4 L7 p, e  q: v        object2(0) = arc1( x- f& b6 Z% k2 \4 B
        displayModification1.Apply(objects1)
8 _/ Y" u4 X7 z" j' s5 z% a        displayModification1.Apply(object2)1 u1 w8 N$ [/ k1 H# X. }& q
        displayModification1.Dispose()7 o  N$ d% Y' }/ s2 Z

6 e4 B! N& Q6 L  ~% _
2 A! [# T  t! `        ' TODO: Add your application code here 5 {. A. ~* e: o4 u
1 u, C* I6 \3 }( c, Z: Q
    End Sub2 j* Q. P+ s, ]3 w
- r) `' U" s. f3 l
1 b4 ?, N  e, W7 a: O) o. C" y
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
# }% X0 T3 A; w5 u. V3 J- t2 {, _7 j' Y( }$ m' x9 t- [8 N( b# ?# B7 Y
        'Unloads the image immediately after execution within NX
+ j( l$ v( y3 |( H8 l/ H1 T: k        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately4 |) p, f( o! w4 D0 g4 l/ n4 [4 E' e
1 _4 o% p! N6 K2 P. q
        '----Other unload options-------
2 G+ Z+ N* C% L7 }/ G3 `4 L        'Unloads the image when the NX session terminates
7 L2 {7 R' c$ }+ [        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
" S8 \! l1 ~. G
' K1 S$ d1 O7 x# W: d        'Unloads the image explicitly, via an unload dialog/ v0 v' R& D  O' M* k5 C
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
8 b8 I% T* \0 b' y        '-------------------------------; s  `7 s! c2 v; L

6 q9 x$ g. E0 O! D2 B9 {    End Function1 J, f" ]  @9 [
* o0 Q/ U8 R% k8 }
End Module
5 H, s: G# W. d- \: O  |; F7 {3 y* t/ M
( X4 T# `6 j$ R. }( f  y

& w4 K7 [- C$ E0 @( R

运行时报错

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

    我知道了