When i try to use the code below to move or copy a component in an assembly,i will get an error message :
"Some or all selected objects were not transformed. Review limitations and check input."
Does anyone know what i did wrong?
Thank you!
Imports NXOpen
Public Class MyProgram
Public Shared Sub Main()
Dim theSession As Session = Session.GetSession()
Dim lw As ListingWindow = theSession.ListingWindow
Dim selectedobj = Snap.UI.Selection.SelectObject("Select")
selectedobj.AllowMultiple = True
selectedobj.SetFilter(Snap.NX.ObjectTypes.Type.Component)
selectedobj.Title = "Select components"
Dim selectcom, trans As Snap.NX.Component
Dim result As Snap.UI.Selection.Result = selectedobj.Show()
If result.Response <> Snap.UI.Response.Cancel AndAlso result.Response <> Snap.UI.Response.Back Then
Dim p = Snap.UI.Input.GetPosition("", "").Position
If IsNothing(p) = False Then
Dim isCopy = Snap.UI.Input.GetChoice({"Move", "Copy"}, "", "", "", Snap.UI.Block.EnumPresentationStyle.RadioBox)
Dim isCopyBool = CBool(isCopy)
Dim xform As Snap.Geom.Transform = Snap.Geom.Transform.CreateTranslation(p.X, p.Y, p.Z)
'For Each obj As Snap.NX.NXObject In result.Objects
' Try
' If isCopyBool Then
' selectcom = CType(obj, Snap.NX.Component)
' trans = selectcom.Copy(xform)
'
' Else
' selectcom = CType(obj, Snap.NX.Component)
' selectcom.Move(xform)
' End If
' Catch ex As Exception
' lw.WriteLine(ex.Message)
' End Try
' Next
Try
selectcom = CType(result.Objects(0), Snap.NX.Component)
trans = selectcom.Copy(xform)
Catch ex As Exception
lw.WriteLine(ex.Message)
End Try
End If
End If
End Sub
End Class