Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

how to Set Transparency in NX Solid model Using KF?

Status
Not open for further replies.

ragutz2

New member
Joined
Nov 11, 2009
Messages
2
Location
US
I think someone else already asked this (thread561-333498) does anyone know how to change transparency of a solid_body using Knowledge fusion? Is there an attribute or class on KF to control this?

Please help, thanks.
 
Hello @ragutz2,

Some time ago I've create this code, changing journal for colour face. I don't know what is knowledge fusion, but maybe it will work for You.

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
            .NewTranslucency = 40
            .Apply(faceArray)
            .Dispose()
        End With

    End Sub

    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

I have find out, that this code have one disadvantage, it work perfect in part, but sometimes doesn't work in assembly, and I don't have idea why.
In line:
Code:
.NewTranslucency = 40
I set translucency for 40 percent.


With best regards
Michael
 
Niedzviedz I will try your approach.

Thanks and Regards!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top