cancel
Showing results for 
Search instead for 
Did you mean: 

SYSTEM FATAL MESSAGE 6144 (MERGE1)

Builder
Builder

So I have an assembly and I can provide the assembly if needed.

 

 

Tag tag, newTag;
UFSession.GetUFSession().Wave.AskLinkXform(extractFace.Tag, out tag); 

UFSession.GetUFSession().So.AskAssyCtxtPartOcc(tag, part.Tag, out newTag);

 

When I get to a certain linked body, I ask for the LinkXform....and I get it,

Then I ask for the "AskAssyCtxtPartOcc" and I get a an

AccessVioationException, and then nx gives me a fatal error and crashes.

Any explanation would be awesome.

Thank you.

2 REPLIES

Re: SYSTEM FATAL MESSAGE 6144 (MERGE1)

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Well, that is not much to go on, so a shot in the dark here: 

 

Are all of the components fully loaded?

 

Re: SYSTEM FATAL MESSAGE 6144 (MERGE1)

Siemens Pioneer Siemens Pioneer
Siemens Pioneer

Hi -

 

Don't know what excatly you are trying to do , with your code....

 

Maybe you get some hints from this program , I created for some years ago..

Take a look into line number: 99+100

 

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports System.Collections.Generic

' created by LKL 12-03-2013
' program link some selected component´s into some other selected component´s and perform subtractoperation 
' program assumes that the component´s selected as toolbodies ,has it´s toolbody on layer 20. Can be changed if nessesary >> Dim Tool_Layer As Integer = ? <<
' program will also link to topassembly and the subtractoperation´s targetbody can be a solid in the topassembly
' program handles link and subtract in ALL targetcomponent´s ,and even targetbodies in the topassembly

Module LKL_select_TARGET_AND_TOOL_in_entire_assy_and_subtract_linked_bodies

    Sub Main()
        Dim s As Session = Session.GetSession()
        Dim ufs As UFSession = UFSession.GetUFSession()
        Dim orig_work_part = s.Parts.Work.Tag
        Dim workPart As NXOpen.Part = s.Parts.Work
        Dim lw As ListingWindow = s.ListingWindow
        lw.open()

        Dim TargetObjectArr() As NXObject 'valgte componenter I ARRAY
        Dim ToolCompArr() As NXObject 'valgte componenter I ARRAY
        Dim TargetObject As NXObject 'component
        Dim ToolComp As component
        Dim Tool_Layer As Integer = 20 ' linker kun bodies fra lag 20 i componenter

        Dim num_result As Integer ' subtract
        Dim resulting_bodies() As NXOpen.tag ' subtract
        Dim FeatureBody As Tag ' subtract
        Dim owner As NXOpen.Tag = NXOpen.Tag.Null
        Dim ownertwo As NXOpen.Tag = NXOpen.Tag.Null
        Dim setTargetWorkPart As NXOpen.Tag = NXOpen.Tag.Null


        '########################### SELECT START #####################################################
        RunSelectFunction(TargetObjectArr, " TARGET ", UFConstants.UF_solid_type)
        '----------------------------------------------------------------------------
        Blank(TargetObjectArr)
        '--------------------------------------------------------------------------
        RunSelectFunction(ToolCompArr, " TOOL ", UFConstants.UF_component_type)
        '----------------------------------------------------------------------
        UnBlank(TargetObjectArr)
        '------------------------------------------------------------------
        '########################### SELECT  END #####################################################
        'ReportBody(TargetObjectArr, " TARGET ")
        'ReportBody(ToolCompArr, " TOOL ")
        '########################### PROGRAM START ###################################################

        For inx As Integer = 0 To TargetObjectArr.length - 1 'loop alle target component
            TargetObject = TargetObjectArr(inx)  'sætter ny target komponenet
            Dim TargetBody As Body = TargetObject

            lw.WriteLine(TargetObject.NAME) 'output til test
            lw.WriteLine("TargetObject.tag" & TargetObject.tag) ' output til test

            If ufs.Assem.IsOccurrence(TargetObject.tag) = True Then 'kontrollere om assembly er tilstede
                TargetBody = TargetObject.Prototype ' subtract
                ownertwo = ufs.Assem.AskPartOccurrence(TargetObject.tag)
                ufs.Assem.AskParentComponent(TargetObject.tag, ownertwo)
                setTargetWorkPart = ownertwo
            Else
                setTargetWorkPart = NXOpen.Tag.Null
            End If


            ufs.Obj.AskOwningPart(TargetBody.tag, owner)
            ufs.Assem.SetWorkPart(owner)



            For inx2 As Integer = 0 To ToolCompArr.length - 1 'loop´er all tool component
                ToolComp = ToolCompArr(inx2) ' sætter ny tool componenet
                lw.WriteLine(ToolComp.NAME)  ' output til test
                '--------------------------------------------------
                Dim ToolPart As Part = ToolComp.Prototype  ' sætter part af component i varibale
                Dim TargetWorkPart As NXOpen.Tag = ufs.Assem.Askworkpart() 'sætter workpart i variable
                Dim LinkedFeat As NXOpen.Tag = NXOpen.Tag.Null 'ufs output
                Dim xform As NXOpen.Tag ' ufs output


                '--------------trim len af charach max 30----------
                Dim FeaNavn As String = ToolComp.Name ' Trim længde af feature navn hvis over 30 karakter
                Dim FeaNavnKaraktAntal As Integer = Len(FeaNavn)
                If FeaNavnKaraktAntal > 30 = True Then
                    Do Until FeaNavnKaraktAntal = 30
                        FeaNavn = Left(FeaNavn, Len(FeaNavn) - 1)
                        FeaNavnKaraktAntal = Len(FeaNavn)
                    Loop
                End If
                '-----------**bleep** trim------------------------------

                For Each ToolBody As Body In ToolPart.Bodies 'looper toolbodies i toolcomponent - normal kun en
                    If ToolBody.Layer = Tool_Layer Then 'linker kun fra lag 20
                        lw.WriteLine(TargetWorkPart & " --- ") 'output til test
                        ufs.So.CreateXformAssyCtxt(TargetWorkPart, ToolComp.Tag, setTargetWorkPart, xform) ' xform definition ( overfører positioner relative fra assembly position, XFORM =output)
                        ufs.Wave.CreateLinkedBody(ToolBody.tag, xform, TargetWorkPart, True, LinkedFeat) ' linker body (importere XFORM positioner fra ufs.So.CreateXformAssyCtxt ,XFORM input) 
                        ufs.Obj.SetName(LinkedFeat, FeaNavn) 'sætter navn på linked body (componet navn,opt trimmed til max 30 char)

                        '----- start subtract------------------
                        ufs.Modl.AskFeatBody(LinkedFeat, FeatureBody)
                        ufs.Modl.SubtractBodies(TargetBody.tag, FeatureBody, num_result, resulting_bodies)
                        lw.WriteLine("Number of resulting bodies after subtract: " & _
                                                           num_result.ToString)
                        '----- end  subtract------------------
                    End If
                Next
            Next
        Next

        ufs.Assem.SetWorkPart(orig_work_part) ' return workpart til original 

    End Sub

    '########################### PROGRAM END ###################################################

    '########################## FUNKTIONER + UNDERPROGRAMMER  ######################################


    '-----------------UNDERPROGRAM TIL REPORT TAG OG DIV OUTPUT , KUN TIL TEST OG TRIM AF PROGRAM----------------
    Public Function ReportBody(ByRef whatbody() As nxobject, ByVal besked As String)

        Dim s As Session = Session.GetSession()
        Dim ufs As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession()
        Dim type As Integer
        Dim subtype As Integer
        Dim selobj As NXObject
        Dim lw As ListingWindow = s.ListingWindow
        lw.Open()
        lw.WriteLine("Selected" & besked & "Bodies : " & whatBody.length.ToString())
        lw.WriteLine("")

        Dim ufsl As UFSession = UFSession.GetUFSession()

        For inx As Integer = 0 To whatBody.length - 1
            selobj = whatBody(inx)
            lw.WriteLine(selobj.NAME)
            ufs.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
            lw.WriteLine("Object: " & selobj.ToString())
            lw.WriteLine(" Tag: " & selobj.Tag.ToString())
            lw.WriteLine(" Type: " & type.ToString())
            lw.WriteLine(" Subtype: " & subtype.ToString())

            If type = UFConstants.UF_component_type Then
                Dim theComp As Component = DirectCast(selobj, Component)
                Dim c_part As Part = theComp.Prototype()
                lw.WriteLine(theComp.Name & " - " & c_part.FullPath)
                lw.WriteLine("-----------------")

            End If

        Next

    End Function

    '-----------------UNDERPROGRAM TIL SELECTION TARGET+TOOL BODY--------------------------------------------------
    Public Function RunSelectFunction(ByRef whatbody() As nxobject, ByVal besked As String, ByVal lktype As String)

        Dim theUI As UI = ui.GetUI
        Dim message As String = " Vælg " & besked & " bodies in component(s)"
        Dim title As String = "Vælg" & besked & "bodies in component(s)"

        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim keepHighlighted As Boolean = False
        Dim includeFeatures As Boolean = False
        Dim response As Selection.Response

        Dim selectionAction As Selection.SelectionAction = _
            Selection.SelectionAction.ClearAndEnableSpecific

        Dim selectionMask_array(1) As Selection.MaskTriple

        With selectionMask_array(1)
            .Type = lktype
            .Subtype = 0
            .SolidBodySubtype = 0
        End With

        response = theUI.SelectionManager.SelectObjects(message, title, scope, _
                                                        selectionAction, includeFeatures, _
                                                        keepHighlighted, selectionMask_array, _
                                                        whatBody)


    End Function

    '-----------UNDERPROGRAM TIL BLANK-----------
    Public Function Blank(ByRef lk() As NXObject)

        Dim BlankObject As NXObject
        For i As Integer = 0 To lk.length - 1
            BlankObject = lk(i)
            Dim TargetBody As Body = BlankObject
            TargetBody.Blank()
        Next
    End Function

    '-----------UNDERPROGRAM TIL UNBLANK---------
    Public Function UnBlank(ByRef lk() As NXObject)

        Dim BlankObject As NXObject
        For i As Integer = 0 To lk.length - 1
            BlankObject = lk(i)
            Dim TargetBody As Body = BlankObject
            TargetBody.UnBlank()
        Next
    End Function


End Module

regards Lars