Delete Assembly Sketch

 

I am trying to delete sketches from an assembly.  I found the assembly sketches that I want to delete in SolidEdgeAssembly.ComponentLayouts (using Solid Edge Spy), but my code doesn’t work for deleting the sketches.

 

The error message I get is : “Unable to cast COM object of type ‘System._ComObject’ to interface type ‘SolidEdgeAssembly.ComponentLayout’.  This operation failed because the QueryInterface call on the COM component for the interface with IID…”

 

Anybody know how to do this?  My code is the following:

 

 

Dim objApp1 As SolidEdgeFramework.Application

Dim objDoc1 As SolidEdgeAssembly.AssemblyDocument

 

deletecounter = 0

SKETCHDELETER(objDoc1, objApp1, "NOZZ1FC", deletecounter)

 

Sub SKETCHDELETER(ByVal Dobjdoc, ByVal Dobjapp, ByVal sketchname, ByVal deletecounter)

        Try

            ForEach ObjComponent As SolidEdgeAssembly.ComponentLayout In Dobjdoc.ComponentLayouts

                If ObjComponent.Name = sketchname Then

                    ObjComponent.Delete()

                EndIf

            Next

 

        Catch ex As Exception

            ' looks like we failed, so try again

            If deletecounter Then

                deletecounter = deletecounter + 1

                SKETCHDELETER(Dobjdoc, Dobjapp, sketchname, deletecounter)

            EndIf

        EndTry

    EndSub

 

 

Posted by: Danny Bansch
Post date: 6/25/2008 11:11:26 AM

1 REPLY

RE: Delete Assembly Sketch

Got it to work. Same code except Layouts/Layout instead of ComponentLayouts/ComponentLayout.

 

Posted by: Danny Bansch
Post date: 6/26/2008 5:09:25 AM