Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Copy Paste all tables in a sheet

Status
Not open for further replies.

c_driver

Computer
Dec 20, 2019
1
I’m tasked with finding a way to copy all tables on a specific layer of a specific sheet, and then past them to the work-active sheet. As boilerplate I referenced for how to cycle threw all the tables, and modified that code to utilize cutcopypastebuilder. I'm uncertain if I am approaching this the best, any ideas? I’ve posted the code below, thanks!

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module2

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work

Sub Main()

Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

'lw.WriteLine(workPart.FullPath)

'create list of layer numbers to Move tabular notes from
Dim tabularNoteLayerList As New List(Of Integer)
tabularNoteLayerList.Add(1)

'call sub to Move tabular notes
MoveTabularNotes(tabularNoteLayerList)


End Sub

Sub MoveTabularNotes(ByVal layerList As List(Of Integer))

Dim myTabNotes As New List(Of Annotations.TableSection)
Dim tmpTabNote As NXOpen.Tag = NXOpen.Tag.Null
Dim myTabNote As NXOpen.Annotations.TableSection
Dim type As Integer
Dim subtype As Integer

Do
theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_tabular_note_type, tmpTabNote)
If tmpTabNote = NXOpen.Tag.Null Then
Continue Do
End If
If tmpTabNote <> NXOpen.Tag.Null Then
theUfSession.Obj.AskTypeAndSubtype(tmpTabNote, type, subtype)
If subtype = UFConstants.UF_tabular_note_section_subtype Then
myTabNote = (Utilities.NXObjectManager.Get(tmpTabNote))

If layerList.Contains(myTabNote.Layer) Then
myTabNotes.Add(myTabNote)
End If

End If
End If
Loop Until tmpTabNote = NXOpen.Tag.Null

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Move Tables")

'Dim nErrs1 As Integer
'nErrs1 = theSession.UpdateManager.AddToDeleteList(myTabNotes.ToArray)
Dim cutCopyPasteBuilder1 As Drafting.CutCopyPasteBuilder
cutCopyPasteBuilder1 = workPart.DraftingManager.CreateCutCopyPasteBuilder()
cutCopyPasteBuilder1.DestinationView = workPart.Views.WorkView

Dim nErrs1 As Boolean
nErrs1 = cutCopyPasteBuilder1.ObjectsToCopy.Add(myTabNotes.ToArray)
cutCopyPasteBuilder1.Transform.Option = GeometricUtilities.ModlMotion.Options.None
cutCopyPasteBuilder1.InitPaste()
Dim nXObject2 As NXObject
nXObject2 = cutCopyPasteBuilder1.Commit()

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(markId1)

End Sub

End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor