Linear Pattern (PatternData.IAccessSelection2) fires OnClose and SW crashes

Hi Guys,

This on has me stumped and eventually cause SolidWorks to crash ...   (SW2013 sp-latest --- running a SW2012 api dll set ADD-IN)

I am trying to get the feature data from a LPattern feature.  (code not shown)

PatternData = swFeat.GetDefinition

Dim HaveAccess As Boolean = PatternData.IAccessSelections2(ModelDoc, Nothing)

Dim D1holes = PatternData.D1TotalInstances

PatternData.ReleaseSelectionAccess()

Pretty straight forward and this works fine while I have my property manager page open.   This code gets run by the OnSelectionboxListChanged (the first time)

In addition to the above, I get the PersistantID of the feature which all works.... (I do the same for HoleWizard features)

After all the selecting is done and I close the PMP, I run through the collected PersistantIDs get the the objects , determine the type look for LPattern and run the code above.

This time (with no open selection page or selection box etc)  IAccessSelections2 cuases OnClose to fire.  I added this code to onclose to catch it and continue.

    If reason = swPropertyManagerPageCloseReasons_e.swPropertyManagerPageClose_Okay Then

              If userAddin.ONG_Lpattern = True Then

                Try

                    Dim e As New System.Runtime.InteropServices.COMException("cancel close", 1)

                    Throw e

                    Exit Sub

                Catch ex As Exception

                    Exit Sub

                End Try

              End If

          End If

The HaveAccess comes back as true, I have valid data in PatternData, and all is good, then releasing the data fires OnClose again.

Eventually SW craches always with a reference to GetObjectByPersistReference3 --- have not figured out where yet

CMD:AppRunTime ATTR:PageFileBytes=269086720 ATTR:PageFileBytesPeak=276951040 ATTR:PoolNonpagedBytes=194192 ATTR:PoolPagedBytes=2205896 ATTR:PrivateBytes=269086720 ATTR:VirtualBytes=2187776000 ATTR:VirtualBytesPeak=2248110080 ATTR:WorkingSet=114094080 ATTR:WorkingSetPeak=386510848 ATTR:AvailableReservesMask=7 ATTR:GDIHandlesTotal=10000 ATTR:GDIHandlesUsed=1425

uiDveApiPage2_c "Vertical Drill"

"1770dc13-2958-4f31-af24-f71d2fd8fcff"

"Access Violation at 4982ee13 (virtual address 00000000), attempt to read from memory"

CMD:GDIHandles ATTR:used=1484 ATTR:load=14.84 ATTR:free=8516 CMD:CommitChargeMB ATTR:used=4799 ATTR:load=61.67 ATTR:free=2983

auModelDocExt_c::XDispatch::GetObjectByPersistReference3;auModelDocExt_c::XDispatch::GetObjectByPersistReference3;auModelDocExt_c::XDispatch::GetObjectByPersistReference3;auModelDocExt_c::XDispatch::GetObjectByPersistReference3;auModelDocExt_c::XDispatch::GetObjectByPersistReference3;auModelDocExt_c::XDispatch::GetObjectByPersistReference3;auModelDocExt_c::XDispatch::GetObjectByPersistReference3;auModelDocExt_c::XDispatch::GetObjectByPersistReference3;auModelDocExt_c::XDispatch::GetObjectByPersistReference3;

slduiu:4982EE13:0057EE13,sldapiu:44F6B099:0048B099,slduiu:496A3619:003F3619,slduiu:4969D1E5:003ED1E5,mfc100u:69813E1D:001C3E1D,mfc100u:69814062:001C4062,mfc100u:698BEDDE:0026EDDE,mfc100u:698BE12A:0026E12A,mfc100u:698BE08C:0026E08C,slduiu:496A27A5:003F27A5,mfc100u:698BB8DD:0026B8DD,mfc100u:698BBC84:0026BC84,mfc100u:697701C7:001201C7,USER32:76C69BD1:00019BD1,USER32:76C672CB:000172CB,USER32:76C66829:00016829,ntdll:76DA1225:00051225,USER32:76C6685A:0001685A,USER32:76C63838:00013838,USER32:76C66BAD:00016BAD,COMCTL32:FB6B0BBF:000A0BBF,COMCTL32:FB6B47FE:000A47FE,USER32:76C69BD1:00019BD1,USER32:76C63BFC:00013BFC,USER32:76C63B78:00013B78,mfc100u:698BC940:0026C940,mfc100u:698BE0A4:0026E0A4,mfc100u:698BB8DD:0026B8DD,mfc100u:698BBC84:0026BC84,mfc100u:697701C7:001201C7,USER32:76C69BD1:00019BD1,USER32:76C698DA:000198DA;

CMD:AppFinish ATTR:PageFileBytes=431808512 ATTR:PageFileBytesPeak=431816704 ATTR:PoolNonpagedBytes=198512 ATTR:PoolPagedBytes=2207912 ATTR:PrivateBytes=431808512 ATTR:VirtualBytes=2357637120 ATTR:VirtualBytesPeak=2362249216 ATTR:WorkingSet=287182848 ATTR:WorkingSetPeak=386510848 ATTR:AvailableReservesMask=7 ATTR:GDIHandlesTotal=10000 ATTR:GDIHandlesUsed=1484

430435, 386510848, 287223808, 2309208, 2206904, 214768, 198272, 431767552, 431816704, 431767552

1371760805

0

T=1821;I=0;

Anyone have any ideas ????

SolidworksApi macros