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

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:) T( n+ O9 d2 }: @: f9 g
- T8 r- W4 S$ b& x+ q

- p; ^/ P2 k8 UOption Strict Off3 @% W/ o: [8 r5 n2 ?* }# f+ }
Imports System
. u! d" M8 b4 g' L: `" m6 B& TImports NXOpen
" l( B' T. w( V5 ~) C) jImports NXOpen.UF) |2 J% g0 q& J! Z1 h1 \
Imports NXOpen.UI5 ?2 P9 P. d% u2 q# G" y9 X

; g: l6 }5 @0 a1 mModule Module1
8 }8 M+ s+ ]7 q) @
7 p% o/ k3 \8 j- p    Dim s As Session = Session.GetSession()7 |% u  N. ?# p+ t1 o4 r
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
$ R8 @; r& ~# b# `  i" g: A/ }! g0 s    Dim workPart As NXOpen.Part = theSession.Parts.Work
: F; m8 T- `, Z
) u# c* c  }; b) s/ m9 c    Dim displayPart As NXOpen.Part = theSession.Parts.Display8 H2 {, _7 y* A4 g

7 i" o  E9 T5 {3 [, ]) c  U7 @    '  Explicit Activation3 J" Z: D3 M# n% P" S
    '      This entry point is used to activate the application explicitly2 F5 l8 N3 A5 B( t- k
    Sub Main()3 w) W- L$ e; D# y- r

% J  _4 m# x8 B9 o) J       Dim sp As New Point3d(0, 0, 0)
* [) l( o; ~/ t( V- y        Dim ep As New Point3d(50, 50, 0)8 K- I& H7 a$ S' V) Y  z5 @1 D
        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
3 V& @2 b, E. l' \9 U9 N2 L        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)
, f4 y( w' N. y* y/ R# W! S        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
' f* w' [/ B; k! s        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
; D* K6 x+ L8 Y+ s2 m9 z% Z        Dim point1 As NXOpen.Point
8 g; M8 R$ m! S! B5 w        point1 = workPart.Points.CreatePoint(sp)2 {, e3 r! T) h, Z+ {4 j
        Dim point2 As NXOpen.Point
6 w* R# t) B5 g- ]! [8 O# F        point2 = workPart.Points.CreatePoint(ep)
* p. B  P0 n+ }( f8 T5 N' h: y6 s        associativeArcBuilder1.StartPoint.Value = point1* S3 e, ?" x' ]4 y( O- Q5 a
        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point
, e9 p2 _; |; @0 \" p; i: D        associativeArcBuilder1.EndPoint.Value = point2% w( J) y, m9 Y7 }9 I1 x
        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point8 z, r' X" X( Q. Z
        Dim point3 As NXOpen.Point4 G) g/ D  i9 @
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
1 T! ?  k4 K. B% v0 i/ U        associativeArcBuilder1.MidPoint.Value = point3
/ j" i) b' s) P( }        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point* }7 T% _9 d6 \) S3 O* F; j( w8 `
        Dim nXObject1 As NXOpen.NXObject9 o2 U4 F& P0 X  y, q- ^
        nXObject1 = associativeArcBuilder1.Commit()) ]7 u; R( O$ M: C+ I- h
        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)6 {# _! v$ \3 z8 o* I# B4 ]
        associativeArc2.SetName("123")5 ]! r& e: p2 c3 p
        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)1 ^2 d0 R+ w1 @& o" E8 B5 Z) \
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point# F  k2 C* K% F4 A% c
        Dim displayModification1 As NXOpen.DisplayModification
8 q" H& M+ x5 D# ~( f        displayModification1 = s.DisplayManager.NewDisplayModification()3 N4 E  }6 Y, ~1 E4 y( t8 g; h& Z
        displayModification1 = s.DisplayManager.NewDisplayModification() '
* u7 D) q0 ~6 r        displayModification1.NewColor = 7     '设置颜色8 ]. T& K: T4 s" Y5 a: ~1 w4 h
        displayModification1.NewLayer = 10    '设置图层" q% {7 S* O7 y. B+ q
        Dim objects1(0) As NXOpen.DisplayableObject
% O2 u! l* |( L* ]/ \. I6 [        objects1(0) = theLine
0 }" P% r) d2 S; d' g" D        Dim object2(0) As NXOpen.DisplayableObject$ [1 |/ R2 a5 `# e8 n
        object2(0) = arc1: _: b/ g8 W: ^" c6 L+ |- W
        displayModification1.Apply(objects1)
0 B; s1 G5 F% _- J4 ]        displayModification1.Apply(object2)) G- i1 \" @$ f6 w3 V
        displayModification1.Dispose()' D6 R3 a, G: ~' d6 _) a; ^
  B( Q% y- t, }( `( r2 L( o

' y% d" ?7 t& r/ e# M. b- X& g        ' TODO: Add your application code here 2 H. w% X* d3 H
) C+ X# s0 h/ H+ ?& L$ H) @
    End Sub7 p8 \/ C: J0 q# q' C3 E6 q$ z

$ N% M  T) b& H1 s4 t! M) f) g) d6 R5 A+ y: S- T( c
    Public Function GetUnloadOption(ByVal dummy As String) As Integer7 Y, {' b( P" \+ V2 N, B( a; p& Q
& F* U0 J8 |. C" D6 {  Q! C' ~9 T
        'Unloads the image immediately after execution within NX1 X. R: Z+ s4 A4 z. f8 Z, h
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately2 I7 S1 y+ R( @: u2 d6 y9 b$ P+ z

' D4 J$ v$ _2 I" s( P# K6 h/ L        '----Other unload options-------3 @4 U4 P3 V6 ~3 e" P
        'Unloads the image when the NX session terminates
2 r  d0 t8 B$ R/ L, j# d7 V5 m        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
' p) c$ X8 @( M: {0 n# {
. u$ L0 ^/ Y/ D, m  V# v        'Unloads the image explicitly, via an unload dialog' I9 O0 d7 G9 H
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly6 x* d! t& O$ N. K
        '-------------------------------
# v6 V9 N" ~# [' j' `5 F; h& p9 @3 B* f0 X' T
    End Function
# m& z* X8 n. i3 t, S+ a, j
# x( X4 |8 R& P; h9 Y4 cEnd Module& b, w+ k/ Y0 p
1 P3 B& D% o* L* i  h
! @1 T( v8 Y( @
1 U) B+ z" S/ y( l

运行时报错

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

    我知道了