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

Jul 20, 2006 3 Replies

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



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

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

snipped-for-privacy@phnet.fi =E5=AF=AB=E9=81=93=EF=BC=9A

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

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

hi, thanks so much, it works, great thanks

snipped-for-privacy@phnet.fi =E5=AF=AB=E9=81=93=EF=BC=9A

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

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

hi, thanks so much, it works, great thanks

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required