AnsweredAssumed Answered

Solidworks Crash During Macro Execution

Question asked by John Alexander on Feb 16, 2016
Latest reply on Apr 20, 2016 by John Alexander

I'm having trouble tracking down the cause of this crash.

The crash happens consistently when using a macro that I wrote for ballooning assembly drawings. The macro registers an even listener that intercepts selection events, grabs a reference to the selected component and inserts a balloon (sketch block instance) in a pre-defined location. It then performs a sequence of updates on the sketch block's attributes. This process normally works without problems - the crash occurs when the user attempts to do something immediately after the sketch block is inserted.

 

After insertion, the user still has control - if they move the balloon in the split second (or longer) that the macro is interacting with the balloon, it will crash.

Some methods/properties that the macro calls after creating the sketch block instance (in the period when the user is capable of causing a crash) are:

InstancePosition, IGetAttributes, IGetLeaderPoints, SetAttributeValue, SetLeader, Definition, Name

 

I'm suspicious that the problem has to do with manipulating the sketch block leader or the sketch block position while the user is dragging it around but I'm not sure how to prevent that from happening. Ideally, I would lock the user out of making edits to the active window while the macro performs the update but every method that I have tried has not worked.

Alternatively, I've thought of testing whether or not the sketchblock is being dragged before attempting to do anything with it; however, I can't seem to find any property or method that would reveal this information.

 

My next step will probably be to have the macro write to its own log file to figure out exactly what property access or method it is calling when it crashes.

 

I've included an excerpt from the Solidworks dump log below.

<MINIDUMP> "03a9be8f-9747-4bb5-9f6f-ff35e5aa9831" </MINIDUMP>

<AD5> auModelDoc_c::XDispatch2::ClearSelection2;auAm_c::JournalWriteNotify;auAm_c::iFireEventV;auDrawingDoc_c::NewSelectionNotify;auModelView_c::RepaintNotify;auModelView_c::GraphicsRenderPostNotify;auModelView_c::RepaintPostNotify;auDrawingDoc_c::ClearSelectionsNotify;auSelMan_c::XDispatch::GetSelectedObjectCount;

<EXCEPTION> "Access Violation at e8f18b48 (virtual address e8f18b48), attempt to write to memory";

<RAWSTACK> sldworks:E8F18B48:E8F18B48,mfc90u:690C8201:00268201,slduiu:49DC7B8B:00DC7B8B,mfc90u:68E93579:00033579,mfc90u:68E92CC8:00032CC8,slduiu:4987DC42:0087DC42,slduiu:49DD7A4D:00DD7A4D,slduiu:49EC8A90:00EC8A90,slduiu:49D7399B:00D7399B,slduiu:49DD6862:00DD6862,slduiu:493EC7B9:003EC7B9,slduiu:493B7982:003B7982,slduiu:494A45A2:004A45A2,slduiu:494AFF40:004AFF40,slduiu:494B0CF2:004B0CF2,slduiu:492D1331:002D1331,mfc90u:68E75B1A:00015B1A,mfc90u:68E750B8:000150B8,sldappu:470B08CB:000F08CB,slduiu:495FC55A:005FC55A,mfc90u:68E732F0:000132F0,mfc90u:68E7369D:0001369D,mfc90u:68E7060F:0001060F,USER32:76E89BD1:00019BD1,USER32:76E83BFC:00013BFC,USER32:76E83B78:00013B78,OPENGL32:F394948E:0003948E,USER32:76E89BD1:00019BD1,USER32:76E898DA:000198DA,mfc90u:68ECE1E6:0006E1E6,mfc90u:68ECEAB3:0006EAB3,sldappu:47000722:00040722;

<UNHANDLED>

</SWEXH>

<SWEXH>

<MINIDUMP> "9455213a-f6ac-4a00-a383-1aa92cf3bf28" </MINIDUMP>

<EXCEPTION> "Invalid Deactivation";

<RAWSTACK> ntdll:76FDF822:0006F822,USER32:76EF117B:0008117B,ntdll:76F88B03:00018B03,ntdll:76F99DAD:00029DAD,ntdll:76F88A4C:00018A4C,kernel32:76D8050E:0003050E,MSVCR90:72A7568D:0005568D,ntdll:76F99D2D:00029D2D,ntdll:76F891CF:000191CF,ntdll:76FC1248:00051248,sldworks:E8F18B48:E8F18B48,mfc90u:690C8201:00268201,slduiu:49DC7B8B:00DC7B8B,mfc90u:68E93579:00033579,mfc90u:68E92CC8:00032CC8,slduiu:4987DC42:0087DC42,slduiu:49DD7A4D:00DD7A4D,slduiu:49EC8A90:00EC8A90,slduiu:49D7399B:00D7399B,slduiu:49DD6862:00DD6862,slduiu:493EC7B9:003EC7B9,slduiu:493B7982:003B7982,slduiu:494A45A2:004A45A2,slduiu:494AFF40:004AFF40,slduiu:494B0CF2:004B0CF2,slduiu:492D1331:002D1331,mfc90u:68E75B1A:00015B1A,mfc90u:68E750B8:000150B8,sldappu:470B08CB:000F08CB,slduiu:495FC55A:005FC55A,mfc90u:68E732F0:000132F0,mfc90u:68E7369D:0001369D;

<UNHANDLED>

</SWEXH>

<AD2> "UNLOAD_ADDIN" "BendSequenceSwu.dll" "" [0.00] 0

<PROCMEM> CMD:AppFinish ATTR:PageFileBytes=637296640 ATTR:PageFileBytesPeak=639062016 ATTR:PoolNonpagedBytes=184788 ATTR:PoolPagedBytes=2003704 ATTR:PrivateBytes=637296640 ATTR:VirtualBytes=2423164928 ATTR:VirtualBytesPeak=2429353984 ATTR:WorkingSet=669597696 ATTR:WorkingSetPeak=669782016 ATTR:AvailableReservesMask=7 ATTR:GDIHandlesTotal=10000 ATTR:GDIHandlesUsed=1253 </PROCMEM>

<MEMORY> 507489, 669782016, 668483584, 2107472, 1987256, 192052, 183948, 635940864, 639062016, 635940864 </MEMORY>

<FT>1455646128

<EOSL>0</EOSL>

T=879;I=0;<AT>

Outcomes