Deleting Silhouette Curve Entities Causes Inventor to Crash

Deleting Silhouette Curve Entities Causes Inventor to Crash

They_Call_Me_Jake
Advocate Advocate
469 Views
2 Replies
Message 1 of 3

Deleting Silhouette Curve Entities Causes Inventor to Crash

They_Call_Me_Jake
Advocate
Advocate

Trying to delete specific sketch entities from a silhouette curve using iLogic but when I do if I need to go back and delete the Silhouette curve it causes Inventor to Crash whether I try to delete the silhouette curve first and then the 3DSketch or if I just try to delete the 3DSketch with the silhouette curve still in it.  The only thing that allows me to delete the silhouette curve and then the 3DSketch is to let it crash the first time then reopen the part and enter into edit mode of the sketch and click save which throws a warning that you cannot save a part while in sketch edit mode and asks if you'd like to exit edit mode and continue to save, then click OK which will exit edit mode and Save. Then enter edit mode again and repeat trying to save in edit mode only this time it doesn't give a warning it just exits edit mode and saves. Then I can enter edit mode one more time and it will let me delete the silhouette curve without crashing then exit edit mode and then I can delete the 3DSketch.  I don't know if this is a bug or if there is something in my code that is causing it to become locked in a mode that if not exited will cause inventor to crash. Here is the code I'm using if someone can tell me if it's my code or not.

Sub Main()
Dim ThisDoc As PartDocument = ThisApplication.ActiveDocument
Dim oFace As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Pick a Face Sketch will be on")
Dim oPartDef As PartComponentDefinition = ThisDoc.ComponentDefinition
Dim oSurf As SurfaceBody = oPartDef.SurfaceBodies.Item(1)
Dim oSketch3D As Sketch3D = oPartDef.Sketches3D.Add
Dim oSilhouette As SilhouetteCurve = oSketch3D.SilhouetteCurves.Add(oSurf, oFace, True)


For Each oEnt In oSilhouette.SketchEntities
    If oEnt.Type = ObjectTypeEnum.kSketchLine3DObject Then
        DeleteEntity(oEnt)
    End If
Next

End Sub

Sub DeleteEntity(ByRef oEnt As SketchLine3D)
	oEnt.Delete
End Sub

 

0 Likes
Accepted solutions (1)
470 Views
2 Replies
Replies (2)
Message 2 of 3

They_Call_Me_Jake
Advocate
Advocate

Other things I have tested was just creating the silhouette curve and then without deleting any sketch entities, deleting the 3DSketch (works) deleting the silhouette curve first (works) then the 3DSketch (works) or if I do delete some of the silhouette Curve Sketch Entities, if I break the link first, then I can deleted the 3DSketch with no issues. Again, not sure if this is a bug, the way it's supposed to work or there is something wrong with my code. Any help would be greatly appreciated.

0 Likes
Message 3 of 3

They_Call_Me_Jake
Advocate
Advocate
Accepted solution

So after researching some more I think the reason that I was getting the crashing issue is because of the associativity of the Silhouette Curve to the part. If you start deleting lines that it thinks are supposed to be there it doesn't like it. On a different note, my whole reason for needing to delete some of the SketchLines was to mimic creating the Silhouette Curve with inner faces removed and after updating the Autodesk.Inventor.Interop reference in Visual Studio to use 2021's version it appears that the SilhouetteCurves.Add method has been changed to SilhouetteCurves.AddSilhouette with more options to be able to exclude straight lines and inside faces like the options in the UI. 

0 Likes