×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

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!

*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

How to process all detailviews?

How to process all detailviews?

How to process all detailviews?

(OP)
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

RE: How to process all detailviews?

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

RE: How to process all detailviews?

(OP)
Thanks @Cowski. So the main problem was with calling view.

CODE

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

Why is {} so important?

With best regards
Michael

RE: How to process all detailviews?

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

RE: How to process all detailviews?

(OP)
Thanks @Cowski, now it's all clear.

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! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close