Is it possible to delete a sheet using API code?

Discussion in 'SolidWorks' started by SW Monkey, Jan 10, 2007.

  1. SW Monkey

    SW Monkey Guest

    I have a DXF macro that creates a sheet, then exports it in DXF format.
    I would like to delete the sheet after the DXF is saved.

    Is this possible? I dont see this option in API help.
     
    SW Monkey, Jan 10, 2007
    #1
  2. SW Monkey

    fcsuper Guest

    Well, this is one of those RARE times when Macro Recorder works 100%!
    The following code could be modified to give you control over which
    sheet to delete on the fly or have the same one (same name) deleted
    everytime.




    Dim swApp As Object
    Dim Part As Object
    Dim boolstatus As Boolean
    Dim longstatus As Long, longwarnings As Long
    Dim FeatureData As Object
    Dim Feature As Object
    Dim Component As Object
    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    boolstatus = Part.Extension.SelectByID2("Sheet2", "SHEET", 0, 0, 0,
    False, 0, Nothing, 0)
    Part.EditDelete
    End Sub
     
    fcsuper, Jan 10, 2007
    #2
  3. SW Monkey

    SW Monkey Guest

    Ill try your code out. I did try the macro recorder route, but it
    didnt give any good code (like most of the time). This is the code I
    recieved.

    Dim swApp As Object
    Dim Part As Object
    Dim SelMgr As Object
    Dim boolstatus As Boolean
    Dim longstatus As Long, longwarnings As Long
    Dim Feature As Object
    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    Set SelMgr = Part.SelectionManager
    Part.EditDelete
    End Sub
     
    SW Monkey, Jan 10, 2007
    #3
  4. SW Monkey

    fcsuper Guest

    It's funny, I tried to replicate the creation of code your macro
    recorder came up with and I can't figure out how to do it. I guess I'm
    glad of that. lol I tried deleting from the bottom tabs (produced
    useless, but not the same code as you), and by going to the sheet,
    selecting it and deleting (which did produce functioning code). The
    original (and cleanest) method was selecting the sheet from the feature
    manager.

    What version of S/W are you running? I'm on 2005.

    Matt
     
    fcsuper, Jan 10, 2007
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.