I am trying to copy lines and arcs of the flat pattern to the clipboard. I have the following code to select the lines and arcs...
'SELECT ALL ARCS AND LINES IN FLAT PATTERN GEOMETRY IN ORDER TO COPY THEM TO THE CLIPBOARD
Dim length As Integer
Dim journalID As String
Dim i As Integer
Dim markID3 As Session.UndoMarkId
markID3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Copy")
Dim copycutBuilder1 As Gateway.CopyCutBuilder
copycutBuilder1 = workPart.ClipboardOperationsManager.CreateCopyCutBuilder()
copycutBuilder1.CanCopyAsSketch = True
copycutBuilder1.IsCut = False
copycutBuilder1.ToClipboard = True
copycutBuilder1.DestinationFilename = Nothing
length = 0
'Loop to find out the total number of lines and arcs for setting the number for array "objects1"
For Each obj As DisplayableObject In theSession.Parts.Work.Curves
If TypeOf obj Is Arc Then
obj.Highlight()
length = length + 1
obj.RedisplayObject()
ElseIf TypeOf obj Is Line Then
obj.Highlight()
length = length + 1
obj.RedisplayObject()
End If
Next
'PAUSE
theUI.NXMessageBox.Show("Information", NXMessageBox.DialogType.Information, "Length = " & length)
theUI.NXMessageBox.Show("Information", NXMessageBox.DialogType.Information, Message)
theUI.JournalPause()
Dim objects1(length) As NXObject
i = 0
'Loop to select all lines and arcs and put them into array "objects1"
For Each obj As NXObject In theSession.Parts.Work.Curves
If TypeOf obj Is Arc Then
journalID = obj.JournalIdentifier
objects1(i) = CType(workPart.Arcs.FindObject(journalID), Arc)
i = i + 1
ElseIf TypeOf obj Is Line Then
journalID = obj.JournalIdentifier
objects1(i) = CType(workPart.Lines.FindObject(journalID), Line)
i = i + 1
End If
Next
theUI.NXMessageBox.Show("Information", NXMessageBox.DialogType.Information, "Length = " & length)
theUI.NXMessageBox.Show("Information", NXMessageBox.DialogType.Information, "i = " & i)
theUI.NXMessageBox.Show("Information", NXMessageBox.DialogType.Information, "OK?")
theUI.JournalPause()
'COPY LINES AND ARCS OF FLAT PATTERN GEOMETRY TO CLIPBOARD
[highlight #EF2929]copycutBuilder1.SetObjects(objects1)[/highlight]
Dim nxObject1 As NXObject
nxObject1 = copycutBuilder1.Commit()
copycutBuilder1.Commit()
copycutBuilder1.Destroy()
theSession.DeleteUndoMark(markID3, Nothing)
However, when the program gets to the line highlighted in red [copycutBuilder1.SetObjsects(objects1)], I get a journal execution error message stating:
"NXOpen.NXException:Incorrect object for this operation"
I'm not sure what I'm doing wrong. Can anyone please help?
Thanks!