Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

How to process all detailviews? 1

Status
Not open for further replies.

niedzviedz

Mechanical
Apr 1, 2012
307
Hello,

I wanna process all detail views to change label on it. Below is my code, but I receive an error "cannot convert detailview to 1-dimensional array view."

Code:
Option Strict Off

Imports System
Imports NXOpen

Module NXJournal

	Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
	Dim workPart As NXOpen.Part = theSession.Parts.Work
	Dim displayPart As NXOpen.Part = theSession.Parts.Display
	
Sub Main (ByVal args() As String) 

	Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
	markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

	'Dim views1(0) As NXOpen.View
	'Dim detailView1 As NXOpen.Drawings.DetailView 
	
	Dim startSheet As Drawings.DrawingSheet = theSession.Parts.Work.DrawingSheets.CurrentDrawingSheet
	
	
	'for each views1 as Drawings.DraftingView in startSheet.SheetDraftingViews
	for each dview as NXOpen.Drawings.DetailView in startSheet.SheetDraftingViews
	
		'views1(0) = detailView1
        'If views1.Name.Contains("DETAIL") Then
		
		'for each dview as NXOpen.Drawings.DetailView in views1 
			
                       			
			Dim editViewSettingsBuilder1 As NXOpen.Drawings.EditViewSettingsBuilder = Nothing
			editViewSettingsBuilder1 = workPart.SettingsManager.CreateDrawingEditViewSettingsBuilder(dview)

			theSession.SetUndoMarkName(markId1, "Settings Dialog")

			Dim editsettingsbuilders1(0) As NXOpen.Drafting.BaseEditSettingsBuilder
			editsettingsbuilders1(0) = editViewSettingsBuilder1
			workPart.SettingsManager.ProcessForMultipleObjectsSettings(editsettingsbuilders1)

			'editViewSettingsBuilder1.ViewDetailLabel.LabelParentDisplay = NXOpen.Drawings.ViewDetailLabelBuilder.LabelParentDisplayTypes.LabelOnBoundary
			editViewSettingsBuilder1.ViewDetailLabel.LabelParentDisplay = NXOpen.Drawings.ViewDetailLabelBuilder.LabelParentDisplayTypes.Label

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

			theSession.DeleteUndoMark(markId2, Nothing)


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

			Dim nXObject1 As NXOpen.NXObject = Nothing
			nXObject1 = editViewSettingsBuilder1.Commit()

			theSession.DeleteUndoMark(markId3, Nothing)
			theSession.SetUndoMarkName(markId1, "Settings")
			editViewSettingsBuilder1.Destroy()
			
		'next
		'End If
		
	next
	

End Sub

End Module

Any tips how to repair it?


With best regards
Michael
 
Replies continue below

Recommended for you

Code:
Option Strict Off

Imports System
Imports NXOpen

Module process_detail_views

    Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
    Dim workPart As NXOpen.Part = theSession.Parts.Work
    Dim displayPart As NXOpen.Part = theSession.Parts.Display

    Sub Main(ByVal args() As String)

        Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
        markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

        Dim startSheet As Drawings.DrawingSheet = theSession.Parts.Work.DrawingSheets.CurrentDrawingSheet


        For Each dview As NXOpen.Drawings.DraftingView In startSheet.SheetDraftingViews

            If Not TypeOf (dview) Is Drawings.DetailView Then
                'skip non detail views
                Continue For
            End If

            Dim editViewSettingsBuilder1 As NXOpen.Drawings.EditViewSettingsBuilder = Nothing
            editViewSettingsBuilder1 = workPart.SettingsManager.CreateDrawingEditViewSettingsBuilder({dview})

            theSession.SetUndoMarkName(markId1, "Settings Dialog")

            Dim editsettingsbuilders1(0) As NXOpen.Drafting.BaseEditSettingsBuilder
            editsettingsbuilders1(0) = editViewSettingsBuilder1
            workPart.SettingsManager.ProcessForMultipleObjectsSettings(editsettingsbuilders1)

            'editViewSettingsBuilder1.ViewDetailLabel.LabelParentDisplay = NXOpen.Drawings.ViewDetailLabelBuilder.LabelParentDisplayTypes.LabelOnBoundary
            editViewSettingsBuilder1.ViewDetailLabel.LabelParentDisplay = NXOpen.Drawings.ViewDetailLabelBuilder.LabelParentDisplayTypes.Label


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

            Dim nXObject1 As NXOpen.NXObject = Nothing
            nXObject1 = editViewSettingsBuilder1.Commit()

            theSession.DeleteUndoMark(markId3, Nothing)
            theSession.SetUndoMarkName(markId1, "Settings")
            editViewSettingsBuilder1.Destroy()

        Next


    End Sub

End Module

www.nxjournaling.com
 
Thanks @Cowski. So the main problem was with calling view.

Code:
editViewSettingsBuilder1 = workPart.SettingsManager.CreateDrawingEditViewSettingsBuilder({dview})

Why is {} so important?

With best regards
Michael
 
The curly braces tells the compiler to treat the variable as an array. It acts as a sort of shortcut to the following code:

Code:
dim myDetView(0) as DetailView
myDetView(0) = dView
editViewSettingsBuilder1 = workPart.SettingsManager.CreateDrawingEditViewSettingsBuilder(myDetView)

www.nxjournaling.com
 
Thanks @Cowski, now it's all clear.

With best regards
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor