45guop 发表于 2016-7-21 21:18:53

设置线的颜色

怎么才能设置线的颜色呢代码:


Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI

Module Module1

    Dim s As Session = Session.GetSession()
    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
    Dim workPart As NXOpen.Part = theSession.Parts.Work

    Dim displayPart As NXOpen.Part = theSession.Parts.Display

    'Explicit Activation
    '      This entry point is used to activate the application explicitly
    Sub Main()

       Dim sp As New Point3d(0, 0, 0)
      Dim ep As New Point3d(50, 50, 0)
      Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
      Dim theLine As Line = s.Parts.Work.Curves.CreateLine(sp, ep)
      Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
      associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
      Dim point1 As NXOpen.Point
      point1 = workPart.Points.CreatePoint(sp)
      Dim point2 As NXOpen.Point
      point2 = workPart.Points.CreatePoint(ep)
      associativeArcBuilder1.StartPoint.Value = point1
      associativeArcBuilder1.StartPointOptions = NXOpen.Features.AssociativeArcBuilder.StartOption.Point
      associativeArcBuilder1.EndPoint.Value = point2
      associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Point
      Dim point3 As NXOpen.Point
      point3 = workPart.Points.CreatePoint(New Point3d(0, 50, 0))
      associativeArcBuilder1.MidPoint.Value = point3
      associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
      Dim nXObject1 As NXOpen.NXObject
      nXObject1 = associativeArcBuilder1.Commit()
      Dim associativeArc2 As NXOpen.Features.AssociativeArc = CType(nXObject1, NXOpen.Features.AssociativeArc)
      associativeArc2.SetName("123")
      Dim arc1 As NXOpen.Arc = CType(associativeArc2.FindObject("123"), NXOpen.Arc)
      associativeArcBuilder1.MidPointOptions = NXOpen.Features.AssociativeArcBuilder.MidOption.Point
      Dim displayModification1 As NXOpen.DisplayModification
      displayModification1 = s.DisplayManager.NewDisplayModification()
      displayModification1 = s.DisplayManager.NewDisplayModification() '
      displayModification1.NewColor = 7   '设置颜色
      displayModification1.NewLayer = 10    '设置图层
      Dim objects1(0) As NXOpen.DisplayableObject
      objects1(0) = theLine
      Dim object2(0) As NXOpen.DisplayableObject
      object2(0) = arc1
      displayModification1.Apply(objects1)
      displayModification1.Apply(object2)
      displayModification1.Dispose()


      ' TODO: Add your application code here

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

      'Unloads the image immediately after execution within NX
      GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

      '----Other unload options-------
      'Unloads the image when the NX session terminates
      'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

      'Unloads the image explicitly, via an unload dialog
      'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
      '-------------------------------

    End Function

End Module



页: [1]
查看完整版本: 设置线的颜色