11-10-2016
04:33 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-10-2016
04:33 PM
Hi Frederic,
I believe that deleting the sketch from the sketch OnNewSketch event is problematic. I am able to recreate the crash. I also tried using a Document Changed event to delete the sketch and Inventor crashes.
How important is it that the sketch is not created until the requirement is meant? Would just calling ExitEdit on the sketch in the OnNewSketch event be enough? You could display the message box telling them to add the side definition and then call ExitEdit. They would need to click on the sketch that was created to edit it. (hopefully after doing what they are supposed to).
Here is the VBA code I used to test ExitEdit.
Private Sub SketchEvents_OnNewSketch(ByVal DocumentObject As Document, ByVal Sketch As Sketch, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)
If BeforeOrAfter = EventTimingEnum.kAfter Then
Dim oDocDef As SheetMetalComponentDefinition
Set oDocDef = DocumentObject.ComponentDefinition
If oDocDef.ASideDefinitions.count = 0 Then
' If DocumentObject.EnvironmentManager.EditObjectEnvironment.DisplayName = "Flat Pattern" Then
If DocumentObject.EnvironmentManager.EditObjectEnvironment.DisplayName = "2D Sketch" Then
'Call MsgBox("You must create an A Side Definition First", "Missing A Side Definition", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Call MsgBox("in OnNewSketch in kAfter - closing sketch, please edit the sketch after you do something")
Sketch.ExitEdit
End If
End If
End If
End Sub
Thanks,
Wayne
Wayne Brill
Developer Technical Services
Autodesk Developer Network