delete sketchpoints in part document automated

delete sketchpoints in part document automated

Anonymous
Not applicable
334 Views
0 Replies
Message 1 of 1

delete sketchpoints in part document automated

Anonymous
Not applicable

Hello everybody,

 

I have a problem to delete some sketchpoints automated.

 

I need a closed area of two different sketches projected into a third one.Both projected sketches changes geometry by changing some parameters. To build the extrusion for the new variation I delete all sketchpoints first (pic. "after deleting without problem") and subsequently create them new. If the sketch is without problems it is working fine (pic. "created sketchpoints").

 

    afterDeleteOk.PNG          afterCreatingOk.PNG          

 

But if there are some parameter changing based problems inside the sketch, the code to delete the sketchpoints fails (pic. "after deleting with problem").

 

afterDelete.PNG      

To fix the problem I do some manual deleting test. I got an message called: 'Autodesk Inventor Professional - Delete Selections' (pic. "error message while deleting sketchpoints manually"). The default button is 'Cancel'. After choosing 'Accept', the picked sketchpoint will be deleted.

 

ErrorManual.png          

Here is some code snipped out of my program - only the deleting part.

 

Dim oPartDoc As Document
oPartDoc = ThisApplication.ActiveDocument

Dim oCompDef As PartComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

Dim oSketches As PlanarSketches
oSketches = oCompDef.Sketches

Dim oSketch As PlanarSketch
oSketch = oSketches.Item("mid")
oSketch.Edit

'Dim oErrMgr As ErrorManager
'oErrMgr = ThisApplication.ErrorManager

'Dim oMessSec As MessageSection
'oMessSec = oErrMgr.StartMessageSection

Dim b, oCountEnd As Integer
b = 1
oCountEnd = 24

Dim oSkEntity As SketchEntity

For b = 1 To oSketch.SketchEntities.Count
	If b > oCountEnd Then
		oSkEntity = oSketch.SketchEntities.Item(oCountEnd + 1)
		If oSkEntity.Type = 83896576 Then
			On Error Resume Next
			'If oMessSec.HasErrors = True Then
			oSkEntity.Delete()
			'End If
		End If
	End If
Next

'after that create new SketchPoints to get a closed loop for Extrusion

oSketch.ExitEdit

InventorVb.DocumentUpdate()

I do a test using the ErrorManager but I does not get it working. My test is included in the code but commented out. I am not sure it is the right way.

Maybe changing the default button in the messagebox is a solution? How can I do this?

 

I am grateful for any help that points me in the right direction!

 

Greetings,

Jana

 

 

0 Likes
335 Views
0 Replies
Replies (0)