Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Change characteristic of all PMI FCF in part

Valued Contributor
Valued Contributor

Hi,

 

I'm trying to edit all PMI FCF in parts and change its characteristic from Straingtness to Flatness. What I've come up with is:

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
 
Module Module1
 
    Sub Main()
 
        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()
 
        For Each myFCF As Annotations.Fcf In workPart.Fcfs
 
            'lw.WriteLine(myFCF)
            pmiFeatureControlFrameBuilder.Characteristic = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Flatness
 
        Next
 
 
        lw.Close()
 
    End Sub
 
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
 
        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
 
    End Function
End Module

I'm unable to select PMI FCF and edit it. Please help me.

4 REPLIES

Re: Change characteristic of all PMI FCF in part

Valued Contributor
Valued Contributor

Please give any clue on how to select single PMI FCF in part so that I can manage to edit it further.

Re: Change characteristic of all PMI FCF in part

Valued Contributor
Valued Contributor

Below is the code which does what I want:

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
 
Module Module1
 
    Sub Main()
 
        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()
        Dim myFCF

        For Each myFCF In workPart.Annotations.fcfs.ToArray() ' Change fcfs to another annotation name to loop thru all of them in part
             Dim x as string 
             x = myFCF.JournalIdentifier
        Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
        markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

        Dim fcf1 As NXOpen.Annotations.Fcf = CType(workPart.FindObject(x), NXOpen.Annotations.Fcf)

        Dim pmiFeatureControlFrameBuilder1 As NXOpen.Annotations.PmiFeatureControlFrameBuilder = Nothing
        pmiFeatureControlFrameBuilder1 = workPart.Annotations.CreatePmiFeatureControlFrameBuilder(fcf1)

        ''' Change characteristics
        pmiFeatureControlFrameBuilder1.Characteristic = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Flatness  
        Dim nXObject1 As NXOpen.NXObject = Nothing ''' Commit changes
        nXObject1 = pmiFeatureControlFrameBuilder1.Commit()
        Next
        lw.Close()
 
    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
 
    End Function
End Module

Re: Change characteristic of all PMI FCF in part

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

2 items of note:

  1. Don't forget to destroy the builder object when you are done with it. The objects may show some strange behavior later if you edit it and forget to destroy the builder object that performed the edits.
  2. There's no need to get the journal identifier of the object in this case. If you declare the loop variable with the proper type, you can use it directly.

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
 
Module Module1
 
    Sub Main()
 
        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        For Each myFCF as NXOpen.Annotations.Fcf In workPart.Annotations.fcfs
            Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
            markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
    
            Dim pmiFeatureControlFrameBuilder1 As NXOpen.Annotations.PmiFeatureControlFrameBuilder = Nothing
            pmiFeatureControlFrameBuilder1 = workPart.Annotations.CreatePmiFeatureControlFrameBuilder(myFCF)
    
            ''' Change characteristics
            pmiFeatureControlFrameBuilder1.Characteristic = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.Flatness  
            Dim nXObject1 As NXOpen.NXObject = Nothing ''' Commit changes
            nXObject1 = pmiFeatureControlFrameBuilder1.Commit()
            pmiFeatureControlFrameBuilder1.Destroy
        Next
        lw.Close()
 
    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
 
    End Function
End Module

Re: Change characteristic of all PMI FCF in part

Valued Contributor
Valued Contributor

Thank you for improving the answer!