×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Mask triples NX10

Mask triples NX10

Mask triples NX10

(OP)
Hello,

I have question about mask triples in NX 10. Did something changes in this dialog , because I have journal to select face and change it color. In NX 8.5 it works perfect - select only face, but in NX 10 it also selecting solid body.
Below is my code:

CODE

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI


Module changeColorOfPreSelectedFaces_v2
    Dim theSession As Session = Session.GetSession()
    Dim sel As Selection = NXOpen.UI.GetUI.SelectionManager

    Sub Main()
        '' Integer variable to store color code in.
        Dim newColorCode As Integer = 114

        newColorCode = Convert.ToInt32(6)
 


        '' The selectFaces method takes an NXobject array by reference 
        Dim selectedObjectsArray() As NXObject
        SelectFaces(selectedObjectsArray)

        '' Need to recast the face NXObjects to Displayable objects
        Dim faceArray(selectedObjectsArray.Length - 1) As DisplayableObject
        For i As Integer = 0 To selectedObjectsArray.Length - 1
            faceArray(i) = CType(selectedObjectsArray(i), DisplayableObject)
        Next

        '' A display modification object is used to change to color of the faces.
        Dim changeFaceColor As DisplayModification = theSession.DisplayManager.NewDisplayModification()
        With changeFaceColor
            .ApplyToAllFaces = False
            .NewColor = newColorCode
            .Apply(faceArray)
            .Dispose()
        End With

    End Sub


    '' The following routine is from GTAC

    ' ----------------------------------------------
    '   sub to select faces
    ' ----------------------------------------------

    Sub SelectFaces(ByRef selectedObjects As NXObject())

        Dim ui As UI = NXOpen.UI.GetUI

        Dim message As String = "Select Faces"
        Dim title As String = "Selection"

        Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
        Dim keepHighlighted As Boolean = False
        Dim includeFeatures As Boolean = False
        Dim response As Selection.Response

        Dim selectionAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific

        Dim selectionMask_array(1) As Selection.MaskTriple
        With selectionMask_array(0)
            .Type = UFConstants.UF_solid_type
            .Subtype = 0
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_FACE
        End With

        response = ui.SelectionManager.SelectObjects(message, title, scope, _
                                         selectionAction, includeFeatures, _
                                     keepHighlighted, selectionMask_array, _
                                                      selectedObjects)

        If response = Selection.Response.Cancel Or response = Selection.Response.Back Then
            Return
        End If

    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = NXOpen.UF.UFConstants.UF_UNLOAD_IMMEDIATELY

    End Function
End Module 

With best regards
Michael

RE: Mask triples NX10

Check the NX 10 release notes; sometimes changes to the API are noted. If you can't find anything there, I'd suggest contacting GTAC with this. They are the only ones that can give a definitive answer on what changed and why.

www.nxjournaling.com

RE: Mask triples NX10

(OP)
Thanks @Cowski, I will contact them. Maybe there is a bug in NX 10. I also noticed, that when I process whole assembly with journal to set some properties and I save and close it, after reload It to new session of NX they are gone, even if I force in journal to save every part after modification. But if I open some parts in new window and then save, they appear after reload. Similar problem I have encounter in NX 9. Can You check by Yourself, if this problem also appears on Your machine?

With best regards
Michael

RE: Mask triples NX10

Maybe try to force a subtype like this :

.Subtype = UFConstants.UF_solid_face_subtype

RE: Mask triples NX10

(OP)
Thanks for help, but it didn't work. I have create thread about this issue at our support. Probably on Monday/Tuesday I will receive some information.

With best regards
Michael

RE: Mask triples NX10

(OP)
Hello everyone,

I have some info about this problem. Like I said, I contacted our NX support, and they help me solve the problem. There is an error in my code.
there is:

CODE

Dim selectionMask_array(1) As Selection.MaskTriple
        With selectionMask_array(0) 

But should be:

CODE

Dim selectionMask_array(0)As Selection.MaskTriple
        With selectionMask_array(0) 

The best thing is that, this is working fine in NX 8,5, I don't know how it's works in 9, but in 10 the problem appears.

One more questions about mask triple. I have this code for change body translucency. I use two selectionMask_array. Can I merge them somehow?

CODE

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI


Module changeColorOfPreSelectedFaces_v2
    Dim theSession As Session = Session.GetSession()
    Dim sel As Selection = NXOpen.UI.GetUI.SelectionManager

    Sub Main()

        '' The selectFaces method takes an NXobject array by reference 
        Dim selectedObjectsArray() As NXObject
        Selectbody(selectedObjectsArray)

        '' Need to recast the face NXObjects to Displayable objects
        Dim faceArray(selectedObjectsArray.Length - 1) As DisplayableObject
        For i As Integer = 0 To selectedObjectsArray.Length - 1
            faceArray(i) = CType(selectedObjectsArray(i), DisplayableObject)
        Next

        Dim changeBodytransluency As DisplayModification = theSession.DisplayManager.NewDisplayModification()
        With changeBodytransluency
            .ApplyToAllFaces = true
        '    .NewColor = newColorCode
            .NewTranslucency = 40
            .Apply(faceArray)
            .Dispose()
        End With

    End Sub


    '' The following routine is from GTAC

    ' ----------------------------------------------
    '   sub to select faces
    ' ----------------------------------------------

    Sub Selectbody(ByRef selectedObjects As NXObject())

        Dim ui As UI = NXOpen.UI.GetUI

        Dim message As String = "Select body"
        Dim title As String = "Selection"

        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim keepHighlighted As Boolean = False
        Dim includeFeatures As Boolean = False
        Dim response As Selection.Response

        Dim selectionAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific

        Dim selectionMask_array(1) As Selection.MaskTriple
	With selectionMask_array(0)
            .Type = UFConstants.UF_component_type
            .Subtype = UFConstants.UF_component_subtype
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY 
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY 
        End With

        With selectionMask_array(1)
            .Type = UFConstants.UF_solid_type
            .Subtype = 0
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY 
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY 
	End with

        response = ui.SelectionManager.SelectObjects(message, title, scope, _
                                         selectionAction, includeFeatures, _
                                     keepHighlighted, selectionMask_array, _
                                                      selectedObjects)

        If response = Selection.Response.Cancel Or response = Selection.Response.Back Then
            Return
        End If

    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = NXOpen.UF.UFConstants.UF_UNLOAD_IMMEDIATELY

    End Function
End Module 


With best regards
Michael

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources