Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Journal to toggle between fully shaded and wireframe

Status
Not open for further replies.

niedzviedz

Mechanical
Apr 1, 2012
307
0
0
PL
Hello everyone,

I have created this journal to change shading on selected view in drafting. It toggle between fully shaded and wireframe. It's works ok, but it has one problem, the display doesn't change after journal end. When I change display part to another, and return back, view updates and shading is ok.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI

Module Module1

        Dim theSession As Session = Session.GetSession()
	Dim ui As UI = UI.GetUI()
	Dim ufs As UFSession = UFSession.GetUFSession()
	Dim workPart As Part = theSession.Parts.Work
        'Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
            Return
        End If

        'lw.Open()

	Dim selectedviews (-1) As TaggedObject
        Dim theDrftView As Drawings.DraftingView
	Dim response1 as Selection.Response = Selection.Response.Cancel

start1:
        response1 = SelectDraftingView(selectedviews)

        EditView(selectedviews)
end1:
    End Sub


    Sub EditView(ByVal selectedviews () As TaggedObject)  


	Dim markId1 As Session.UndoMarkId
	markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Settings")

	Dim status as string	

        For Each selectedview as Drawings.DraftingView in selectedviews

		   if selectedview.Style.Shading.RenderingStyle = Preferences.ShadingRenderingStyleOption.Wireframe then

		  	selectedview.Style.Shading.RenderingStyle = Preferences.ShadingRenderingStyleOption.FullyShaded
			workPart.DraftingViews.SuppressViewBreaks(selectedview)
			selectedview.Regenerate()		
			selectedview.UpdateDisplay() 
			selectedview.Commit()
			workPart.DraftingViews.RestoreViewBreaks(selectedview)
		

		   elseif selectedview.Style.Shading.RenderingStyle = Preferences.ShadingRenderingStyleOption.FullyShaded then
	
			selectedview.style.Shading.RenderingStyle = Preferences.ShadingRenderingStyleOption.Wireframe	
			workPart.DraftingViews.SuppressViewBreaks(selectedview)  
			selectedview.Regenerate()
			selectedview.UpdateDisplay() 	 
			selectedview.Commit()
			workPart.DraftingViews.RestoreViewBreaks(selectedview)


		   
		   end if 	

	next

        Dim nErrs1 As Integer
        nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
	theSession.DeleteUndoMark(markId1, Nothing)


    End Sub



    Function SelectDraftingView(ByRef selobj() As TaggedObject) As Selection.Response

        Dim theUI As UI = UI.GetUI

	Dim resp As Selection.Response = Selection.Response.Cancel
        Dim prompt As String = "Select a drafting view"
        Dim message As String = "Select a drafting view"
        Dim title As String = "Selection"
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim selectionMask_array(0) As Selection.MaskTriple
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False

        With selectionMask_array(0)
            .Type = UFConstants.UF_view_type
            .Subtype = UFConstants.UF_all_subtype
        End With

         resp = theUI.SelectionManager.SelectTaggedObjects(prompt, message, scope, _
                selAction, includeFeatures, keepHighlighted, selectionMask_array, selObj)


        If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
 '           selView = CType(selObj, Drawings.DraftingView)
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If

    End Function

    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

Maybe someone has some advice what to add to this code to update immediately? I added some command to update view, but it doesn't helped.


With best regards
Michael
 
Status
Not open for further replies.
Back
Top