How to make the export dialog disappear when using the saveas4 function in API?

Discussion in 'SolidWorks' started by syshieley, Jul 20, 2006.

  1. syshieley

    syshieley Guest

    Dear all,
    i want to save a created model into the STL format and used the
    function of saveas4,
    everything goes well, just when i am running the add-in in solidworks
    2006, there is always a dialog of export jumping out and requiring me
    to choose to save the selected bodies or all bodies. I want to use the
    option of all bodies, but hope the dialog will not jump out any more,
    who knows how to do it?

    thanks so much

    best regards
    SY
     
    syshieley, Jul 20, 2006
    #1
  2. syshieley

    samu.niveri Guest

    I think it could be possible to save model as STL without that
    dialogbox if you select model before saveas4. Here is example code of
    it. Hope it helps.

    ----------------------------------------------------------------------------------------------------------

    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim boolstatus As Boolean
    Dim ModelName As String
    Dim ParseParams(1 To 3) As String
    Dim nErrors As Long
    Dim nWarnings As Long
    Sub main()

    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc

    If swModel Is Nothing Then
    MsgBox "Try again when you something open!"
    Exit Sub
    End If

    If swModel.GetType = 3 Then
    MsgBox "this does not work with drawings!"
    Exit Sub
    End If

    ModelName = swModel.GetPathName

    For p = Len(ModelName) To 1 Step -1
    If Mid(ModelName, p, 1) = "\" Then Exit For
    Next

    ParseParams(1) = Left(ModelName, p)
    ParseParams(2) = Trim(Right(ModelName, (Len(ModelName) - p)))
    ParseParams(3) = ParseParams(1) & Left(ParseParams(2),
    (Len(ParseParams(2)) - 7)) & ".stl"
    swModel.ClearSelection2 True
    boolstatus = swModel.Extension.SelectByID2(ParseParams(2), "COMPONENT",
    0, 0, 0, False, 0, Nothing, 0)
    boolstatus = swModel.SaveAs4(ParseParams(3), swSaveAsCurrentVersion,
    swSaveAsOptions_Silent, nErrors, nWarnings)
    swModel.ClearSelection2 True

    End Sub
    ----------------------------------------------------------------------------------------------------------
     
    samu.niveri, Jul 20, 2006
    #2
  3. syshieley

    syshieley Guest

    寫é“:
    hi, thanks so much, it works, great
    thanks
     
    syshieley, Jul 20, 2006
    #3
  4. syshieley

    syshieley Guest

    寫é“:
    hi, thanks so much, it works, great
    thanks
     
    syshieley, Jul 20, 2006
    #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.