Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change lines with a VB prgramm

Status
Not open for further replies.

Sim77Son

Mechanical
Aug 4, 2012
18
Hello,

first i`m new to VB.net. I recorded a journal to select all hidden lines in a drawing sheet, change them from dashed to solid and give them a colour. This works but only in the part i recorded it.

My question is how I must change the journal(gruen_machen_1.txt) to select all hidden linesin all drafting views at once in a part.

In my second Journal(gestrichel_machen_2) i have the same problem. I want to select all lines and arcs with a special colour and change them into dashed lines.


If someone could help me that would be great!

Im working with NX 8.0.2.2
 
Replies continue below

Recommended for you

Sim77Son,

A journal will only record some of the steps that you make while recording in NX. If you look at your journal, you will see entries that refer to menu selections, such as:

Code:
' ----------------------------------------------
'  Menü: Bearbeiten->Auswahl->Detailliertes Filtern...
' ----------------------------------------------

and then nothing explicit after it. This means that journaling didn't record that entry and you need to learn how to code the actual method to perform that function. Unfortunately, I don't speak German so I can't figure out exactly what the steps are that the Journal went through.

If you look through this forum and other places on the Web, as well as the .Net reference and samples in the UG/NX Documentation, you can start to piece together how to edit your journal so that it performs the functions you want.

I know this doesn't exactly tell you how to do what you want, but hopefully it sends you in the right direction.

Jeff
 
Here is an example journal for changing curve font. Note that you need to change the integer value for the curve color.

Code:
Option Strict Off
Imports System
Imports NXOpen

Module organize_file

    Dim s As Session = Session.GetSession()
    Dim workPart As Part = S.Parts.Work
    Dim dispPart As Part = s.Parts.Display
    Dim lw As ListingWindow = s.ListingWindow
    

    Sub Main()
        Dim linename As String = "Line"
        Dim arcname As String = "Arc "
        Dim curvecolour As Integer = 134 ' Change this colour number as required
        Dim curves As CurveCollection = workPart.Curves
        Dim curvesubstring As String = Nothing
        Dim line1 As Line = Nothing
        Dim arc1 As Arc = Nothing
        Dim objects1(0) As DisplayableObject

        Dim displayModification1 As DisplayModification = Nothing
        displayModification1 = s.DisplayManager.NewDisplayModification()
        displayModification1.NewFont = DisplayableObject.ObjectFont.Dashed

        Dim markId1 As Session.UndoMarkId
        markId1 = s.SetUndoMark(Session.MarkVisibility.Visible, "Edit Curves")
        For Each crve As Curve In curves
            curvesubstring = crve.ToString.Substring(0, 4)
            If curvesubstring = linename Then
                line1 = DirectCast(crve, Line)
                If line1.Color = curvecolour Then
                    objects1(0) = line1
                    displayModification1.Apply(objects1)
                End If
            ElseIf curvesubstring = arcname Then
                arc1 = DirectCast(crve, Arc)
                If arc1.Color = curvecolour Then
                    objects1(0) = arc1
                    displayModification1.Apply(objects1)
                End If
            End If
        Next
        displayModification1.Dispose()
    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function

End Module

Frank Swinkels
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor