ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
MOMichael Oswald16/09/2009

I have a macro to generate STL files, but it seems to be ignoring the Angle and Tolerance preferences I set.  Here is the relevant code:

            silent = swModel.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swSTLQuality, swSTLQuality_Custom)
            silent = swModel.SetUserPreferenceDoubleValue(swUserPreferenceDoubleValue_e.swSTLAngleTolerance, 5)
            silent = swModel.SetUserPreferenceDoubleValue(swUserPreferenceDoubleValue_e.swSTLDeviation, 0.002)

            ' output as STL file
            Save2Name = Left(swModel.GetPathName, Len(swModel.GetPathName) - 7) & ".stl"
            silent = swModel.SaveAs4(Save2Name, 0, swSaveAsOptions_Silent + swSaveAsOptions_Copy, Empty, Empty)

I figure this must be just a simple thing I'm overlooking.  Anyone have any suggestions?  Thanks for your help!

Michael

Edit:

One other thing to mention.  Yesterday I upgraded from 32-bit to 64-bit, and I lost all of my settings.  VB called out missing reference libraries when I first tried to run the macro, and I fixed those.  But maybe I missed something else?  Because it seems to be completely ignoring the lines above and simply using whatever tolerance and angle settings are present when the component is opened...

Edit#2:

Just ran the macro in debug mode, and the 'silent' variable is 'false' for each of the 3 statements.  Do I have the incorrect syntax?

Edit#3:

(last edit because I've completely run out of ideas)

Changed swModel to swApp in the SetUserPreferences commands, and now 'silent' is 'true'.  I also added GetUserPreferences statements, and the parameters are really being set.  I added Error and Warning variables to the SaveAs4 command, and I don't get any errors.  Finally, I tried using the SaveAs3 statement instead, but no difference.  Please help!  I have A LOT of files to convert... today...