Quantcast
Channel: NX Journaling - Journaling / NXOpen API
Viewing all articles
Browse latest Browse all 787

Move component

$
0
0

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
 
PublicClass MyProgram
 
    PublicSharedSub Main() 
        Dim theSession As Session = Session.GetSession()Dim lw As ListingWindow = theSession.ListingWindowDim 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.ComponentDim result As Snap.UI.Selection.Result= selectedobj.Show()If result.Response<> Snap.UI.Response.CancelAndAlso result.Response<> Snap.UI.Response.BackThenDim p = Snap.UI.Input.GetPosition("", "").PositionIf IsNothing(p)=FalseThenDim 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'    NextTry
                    selectcom =CType(result.Objects(0), Snap.NX.Component)
                    trans = selectcom.Copy(xform)Catch ex As Exception
                    lw.WriteLine(ex.Message)EndTryEndIfEndIfEndSub 
EndClass

Viewing all articles
Browse latest Browse all 787

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>