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

[求助] 设置线的颜色

[复制链接]

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

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

45guop 楼主

2016-7-21 21:18:53

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

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

x
怎么才能设置线的颜色呢代码:
  B8 n$ V: I* l
# g! P3 ^! W1 I, F8 P3 O4 y6 ?# Y, s3 E7 C  a
Option Strict Off2 ]+ ^5 Z# ~4 T9 C# ~+ T
Imports System
" O$ u: Y% I* i0 ~! ZImports NXOpen; E* {1 o9 b% D2 r) H
Imports NXOpen.UF7 X  e- I' ?: @0 z9 w9 O9 b- N
Imports NXOpen.UI
" }5 B  O* t  q! D' H9 D/ l/ |* a2 n2 W: f, U7 h' w
Module Module1
# H2 r! P  e* [7 a. N8 t3 G3 \% S2 U/ W* f  X! O# f% n
    Dim s As Session = Session.GetSession()
5 s1 z6 Q, Q) V; q8 h) w    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()) O6 f- p& I7 l( w) \2 \/ N& b
    Dim workPart As NXOpen.Part = theSession.Parts.Work& u" r( H% p7 [6 U% I/ k

  g4 A, f8 ?  Y% g0 B" u+ p    Dim displayPart As NXOpen.Part = theSession.Parts.Display! Y# E" u8 @/ V- M
9 `( ^* N" d. m# i
    '  Explicit Activation' M0 I5 Q/ x2 F. e/ g% C
    '      This entry point is used to activate the application explicitly
  v2 u7 N+ O0 K( J    Sub Main()
& h. k3 B; t; @% @$ f3 ^* \9 c* @( O$ ?. w% A9 {5 U
       Dim sp As New Point3d(0, 0, 0)
1 x& v+ ]' W& k: ~8 X" a% E) O        Dim ep As New Point3d(50, 50, 0)  g9 C$ L- ^& B7 A' n
        Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing7 K6 k, a% r- u3 Z2 \) P6 O0 x2 W
        Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)& O0 c9 N8 r9 U7 _2 y5 Y
        Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
$ p9 T( C6 j8 a3 o" d        associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
7 E( }0 v# }8 h( u2 M' w7 a        Dim point1 As NXOpen.Point5 B/ y: O8 O/ D4 X6 [2 |/ A0 w, t
        point1 = workPart.Points.CreatePoint(sp)
1 b: f2 I9 Z- i( P* i        Dim point2 As NXOpen.Point3 |6 V" Y* |8 O: c7 g
        point2 = workPart.Points.CreatePoint(ep)
& U0 }+ V$ w0 S+ H# k# N        associativeArcBuilder1.StartPoint.Value = point1
' E3 d6 \. |& e4 `3 l# _' e        associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point! \4 C' `3 C+ z& ^6 y
        associativeArcBuilder1.EndPoint.Value = point2
; Y: [' P0 |0 S& v6 {6 Y        associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point
* U; D# n! k0 u8 s! O0 z" U        Dim point3 As NXOpen.Point  h2 K; W% u, |4 i' n. T1 C2 @
        point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))4 T! j. b/ Y/ M+ T
        associativeArcBuilder1.MidPoint.Value = point3  y# f! m; a4 [/ m4 [
        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point( q9 Z. p! }; @! k) Q
        Dim nXObject1 As NXOpen.NXObject" G/ ?; T' R: k, s! I; `7 A% b1 y1 z
        nXObject1 = associativeArcBuilder1.Commit()" l2 M2 ]( q5 c2 m. l
        Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)
7 l# s( d. @9 g2 P- L" E        associativeArc2.SetName("123")0 j! T( Z  f. q: C3 e6 `# L
        Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
, n2 n: D9 g6 j  k2 `3 R7 u1 S: s        associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point) \# ?) K& q$ b: j; x! V
        Dim displayModification1 As NXOpen.DisplayModification
$ _8 D/ s: t! P$ A+ E5 E        displayModification1 = s.DisplayManager.NewDisplayModification()
8 }( r; q: y: K1 F        displayModification1 = s.DisplayManager.NewDisplayModification() '
2 q# f" l/ I' k3 K/ `9 a        displayModification1.NewColor = 7     '设置颜色) m/ S+ @/ x7 n+ `
        displayModification1.NewLayer = 10    '设置图层
0 b; j& u" ~8 e* `- Y3 Q        Dim objects1(0) As NXOpen.DisplayableObject" k  {# B& m/ D6 Z' w% G/ {/ u; d3 }
        objects1(0) = theLine
+ K) v5 N7 B% x        Dim object2(0) As NXOpen.DisplayableObject
# M" Y1 h" [  c; A2 u" p: L! R        object2(0) = arc1- K& u0 @& W5 P
        displayModification1.Apply(objects1)/ [( l1 ~# j1 @3 W5 h+ _& @; p
        displayModification1.Apply(object2)
* b( F, \2 h3 r. K0 C; ~- W" X  p        displayModification1.Dispose()8 Y, l/ a7 h; N, ^5 M
# `; S) H. T5 N- H$ y# T" w

; w1 C; `0 i: g  X/ T, e* M7 I        ' TODO: Add your application code here
) z# N/ M/ N. u; T% q9 b
+ i# I7 I& [; j9 O7 a& ^$ O9 L% P    End Sub' i, @$ v0 I  b6 z; S3 x0 f

5 J% ~. ?* z! q0 j! R+ s: H/ `  Q& x- q1 A% N( n
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
5 n4 ^9 o4 b# |/ e5 t" K- _/ Z: D1 L3 z% k' O
        'Unloads the image immediately after execution within NX7 g# I" q8 H) F: i
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
' r4 D! E) Z1 s
! U3 Y& s$ D* T- T        '----Other unload options-------
0 J+ h( a0 x# P1 S; f" x7 g- o+ M        'Unloads the image when the NX session terminates, E5 y! @4 V; h
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination! B$ F0 n, v; W# N

. w, W' A- g! i. l4 _! d: F: G        'Unloads the image explicitly, via an unload dialog# ]4 j4 O4 `' J, E/ V
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly4 l# M" p4 j1 X1 t, ?, @' E* Q+ N4 W
        '-------------------------------7 Q% J: t. Z; P- T2 F

2 P% O" c& w- Q5 B% l/ b& e( I/ X- @    End Function
. e) G2 {6 c& g; n! P1 r3 e, z  K/ }
End Module
' `1 [, Z  E; K& s3 o" u/ c, F' t" A; u9 V
* K2 ]6 V* G* N- W0 X' P

" T. `3 }2 J; D& R4 x4 T- z7 x9 x

运行时报错

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

    我知道了