Hello
I have a 98% working macro and I'm drying a little for the other 2%.
This macro automatically adds markings at the end of the bend line, on a marking layer and in yellow.
The problem comes from some part, when the size of the part is reduced, the marking comes out of the part.
By restarting the macro, it is supposed to erase the marking lines, out of time (rarely) the marking does not erase.
And a message appears in debug mode at the top of the window:
" None of these entities can be deleted "
Here's the part of my code to remove the markup:
Sub suppressMarquage()
Dim swModel As Object
Dim vSkSegArr As Variant
Dim vSkSeg As Variant
Dim swSkSeg As SldWorks.SketchSegment
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Numberline As Integer
Dim lNumSegments As Long
Dim myModelView As Object
'On supprime le marquage existant
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set myModelView = swModel.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
Set swView = swDraw.GetFirstView.GetNextView
lNumSegments = swView.GetLineCount2(1)
If lNumSegments > 0 Then
Set swSketch = swView.GetSketch
vSkSegArr = swSketch.GetSketchSegments
For Each vSkSeg In vSkSegArr
Set swSkSeg = vSkSeg
boolstatus = swModel.Extension.SelectByID2(swSkSeg.GetName, "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
swModel.EditDelete
Next vSkSeg
End If
'On supprime l'annotation marquage
Dim bFind As Boolean
Dim swNote As SldWorks.Note
Dim swAnn As SldWorks.Annotation
Dim bret As Boolean
Set swNote = swView.GetFirstNote
Do While Not swNote Is Nothing
bFind = False
Debug.Print "Note:" & swNote.GetText
If swNote.GetText Like "*Marquage laser*" Then
bFind = True
Debug.Print "bFind:" & bFind
Set swAnn = swNote.GetAnnotation
bret = swAnn.Select2(True, 0)
Set swNote = swNote.GetNext
swModel.EditDelete
End If
If Not bFind Then Set swNote = swNote.GetNext
Loop
End Sub
And if necessary an example of MEP that does not work well (sw 2020)
If anyone has a lead, I've been drying up on the subject for too long!
PI_200416-test. SLDPRT (580.9 KB)
PI_200416-test. SLDDRW (287.8 KB)