×
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

change all parts translucency automatically

change all parts translucency automatically

change all parts translucency automatically

(OP)
Hi,can anybody help me. I'm working on journal. I want to change all dispalyedparts translucency automatically.
Not ask for selecting body.

RE: change all parts translucency automatically

Hello,

(See-Thru All) may help?


regards,
Mathi Krishnan
NX10.0.2.6

RE: change all parts translucency automatically

(OP)
mathisudar2007 thanks for reply.
Can I have the details?

RE: change all parts translucency automatically

can you tell more, why, when, how ?

I assume that you know about the display state "See through all" ?

Regards,
Tomas

RE: change all parts translucency automatically

(OP)
Sorry for not describing my issue clearly.

I'm looking for a journal that can change the displayed parts automatically.
just like the icon of Shaded ,the icon of Static Wireframe.

I found a journal that can change the translucency by selecting the parts one by one.
How can I modify the journal and make it to select all displayed parts automatically ,change the translucency value.

This is the journal I found.

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 = 50
.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


Thanks

RE: change all parts translucency automatically

Can you describe how do you do it
In NX interactive mode.

So I exactly understand it. (And maybe helping)

RE: change all parts translucency automatically

We still want to know why and if you have tried the DIFFERENT STYLES of the display state "See through all" ?
(

Regards,
Tomas

RE: change all parts translucency automatically

(OP)
a984928,Thanks for you reply.
Dou you means how to excute the code?
You can do it by clicking the command Tools → Journal → Edit and paste the code ,play it.

RE: change all parts translucency automatically

(OP)
Tomas,Thanks for remind me the commad " see through-all".
I just tried it.But I found when I excuted the commad, the original colors dispeared.
I don't want it happen.



RE: change all parts translucency automatically


I run your journal and on the selection dialog I choosed "Select All"
and all the assembly components are applied the translucency.

Is this is what you want OK if not please describe how you
perform this in NX interactive mode. (In real NX session not by journal

RE: change all parts translucency automatically

(OP)
a984928,Thanks for you reply.

I want components can be selected antomaticaaly even if them can be seleced by " select all".

I don't know how to perform this in NX interactive mode.I have not NXopen Lisence.

RE: change all parts translucency automatically


I used some of your code and some code from this post

http://www.eng-tips.com/viewthread.cfm?qid=343035

I hop this can helping (run journal in an opened part assembly No selection needed)


Option Strict Off

Imports System
Imports System.Collections

Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Assemblies

Module changeColorOfPreSelectedFaces_v3

Dim theSession As Session = Session.GetSession()

Sub Main()

Dim disPart As Part = theSession.Parts.Display
Dim i As Integer = 0
Dim faceArray(-1) As DisplayableObject
Dim allComp1 As ArrayList = New ArrayList

Dim root As Component = disPart.ComponentAssembly.RootComponent
If Not IsNothing(root) Then
getAllComponents2(root, allComp1)
Dim dispobj As DisplayableObject = Nothing
Dim cnt1 As Integer = allComp1.Count
Dim objectArray1(cnt1 - 1) As DisplayableObject
For i = 0 To cnt1 - 1
dispobj = DirectCast(allComp1(i), DisplayableObject)
ReDim Preserve faceArray(i)
faceArray(i) = dispobj
Next
End If

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

End Sub

Sub getAllComponents2(ByVal comp As Component, ByRef allComp As ArrayList)
Dim child As Component = Nothing
Dim space As String = Nothing
For Each child In comp.GetChildren()
allComp.Add(child)
getAllComponents2(child, allComp)
Next
End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.UF.UFConstants.UF_UNLOAD_IMMEDIATELY
End Function

End Module

RE: change all parts translucency automatically


Changed to run on a peece part or on an assembly part



Option Strict Off

Imports System
Imports System.Collections

Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Assemblies

Module changeColorOfPreSelectedFaces_v4

Dim theSession As Session = Session.GetSession()

Sub Main()

Dim disPart As Part = theSession.Parts.Display
Dim workPart As Part = theSession.Parts.Work
Dim i As Integer = 0
Dim faceArray(-1) As DisplayableObject
Dim allComp1 As ArrayList = New ArrayList
Dim dispobj As DisplayableObject = Nothing

Dim root As Component = disPart.ComponentAssembly.RootComponent
If Not IsNothing(root) Then
getAllComponents2(root, allComp1)
Dim cnt1 As Integer = allComp1.Count
For i = 0 To cnt1 - 1
dispobj = DirectCast(allComp1(i), DisplayableObject)
ReDim Preserve faceArray(i)
faceArray(i) = dispobj
Next
Else
i = 0
For Each objBody As Body In workPart.Bodies
ReDim Preserve faceArray(i)
faceArray(i) = CType(objBody, DisplayableObject)
i = i + 1
Next
End If

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

End Sub

Sub getAllComponents2(ByVal comp As Component, ByRef allComp As ArrayList)
Dim child As Component = Nothing
Dim space As String = Nothing
For Each child In comp.GetChildren()
allComp.Add(child)
getAllComponents2(child, allComp)
Next
End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.UF.UFConstants.UF_UNLOAD_IMMEDIATELY
End Function

End Module

RE: change all parts translucency automatically


Final correcting


Option Strict Off

Imports System
Imports System.Collections

Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Assemblies

Module changeColorOfPreSelectedFaces_v5

Dim theSession As Session = Session.GetSession()

Sub Main()

Dim disPart As Part = theSession.Parts.Display
Dim workPart As Part = theSession.Parts.Work
Dim i As Integer = 0
Dim faceArray(-1) As DisplayableObject
Dim allComp1 As ArrayList = New ArrayList
Dim dispobj As DisplayableObject = Nothing
Dim root As Component = disPart.ComponentAssembly.RootComponent
Dim markId1 As Session.UndoMarkId

markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Change Transluency")

Dim objBody As Body() = workPart.Bodies.ToArray()

If objBody.Length > 0 Then
For i = 0 To objBody.Length - 1
ReDim Preserve faceArray(i)
faceArray(i) = CType(objBody(i), DisplayableObject)
Next
Dim changeBodytransluency As DisplayModification = _
theSession.DisplayManager.NewDisplayModification()
With changeBodytransluency
.ApplyToAllFaces = true
' .NewColor = newColorCode
.NewTranslucency = 75
.Apply(faceArray)
.Dispose()
End With
End If

If Not IsNothing(root) Then
getAllComponents2(root, allComp1)
Dim cnt1 As Integer = allComp1.Count
For i = 0 To cnt1 - 1
dispobj = DirectCast(allComp1(i), DisplayableObject)
ReDim Preserve faceArray(i)
faceArray(i) = dispobj
Next
Dim changeBodytransluency As DisplayModification = _
theSession.DisplayManager.NewDisplayModification()
With changeBodytransluency
.ApplyToAllFaces = true
' .NewColor = newColorCode
.NewTranslucency = 75
.Apply(faceArray)
.Dispose()
End With
End If

End Sub

Sub getAllComponents2(ByVal comp As Component, ByRef allComp As ArrayList)
Dim child As Component = Nothing
Dim space As String = Nothing
For Each child In comp.GetChildren()
allComp.Add(child)
getAllComponents2(child, allComp)
Next
End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.UF.UFConstants.UF_UNLOAD_IMMEDIATELY
End Function

End Module

RE: change all parts translucency automatically

(OP)
a984928 Thanks for your help.
The code works great.

I'm just beginning with journals.I don't know how to start.
I think it's a good place for studying.

Thank you again.

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