Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub WriteSomeStuffToATextFile()
Dim fso As Scripting.FileSystemObject
Dim sFilePath As String
Dim myOutFile As Scripting.TextStream
Dim i As Long
Set fso = CreateObject("Scripting.FileSystemObject")
sFilePath = "C:\TEMP\OutFile.txt"
Set myOutFile = fso.OpenTextFile(sFilePath, ForWriting, Create:=True)
myOutFile.WriteLine "Here is the first line"
myOutFile.WriteLine "Here is the second line"
For i = 3 To 9
myOutFile.WriteLine "Here is line number " & i
Next i
myOutFile.Write "All of this text is on one line"
myOutFile.Write " because we used ""Write"" instead of ""WriteLine"""
myOutFile.WriteBlankLines 4
myOutFile.WriteLine "This last line comes after 4 blank lines."
myOutFile.Close
Set myOutFile = Nothing
Set fso = Nothing
End Sub
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFace As SldWorks.Face2
Dim swSurf As SldWorks.Surface
Dim Feature As SldWorks.Feature
Dim MathPoint As SldWorks.MathPoint
Dim RefPoint As SldWorks.RefPoint
Dim vRefPointFeatureArray As Variant
Dim XYZ As Variant
Dim fso As Scripting.FileSystemObject
Dim sFilePath As String
Dim myOutFile As Scripting.TextStream
Dim Msg As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swFace = swSelMgr.GetSelectedObject5(1)
Set fso = CreateObject("Scripting.FileSystemObject")
sFilePath = "C:\TEMP\OutFile.txt"
Set swSurf = swFace.GetSurface
vRefPointFeatureArray = swModel.FeatureManager.InsertReferencePoint(4, 0, 0.01, 1)
Set Feature = vRefPointFeatureArray(0)
Set RefPoint = Feature.GetSpecificFeature2
Set MathPoint = RefPoint.GetRefPoint
XYZ = MathPoint.ArrayData
Set MathPoint = Nothing
Set RefPoint = Nothing
Set Feature = Nothing
Msg = " Center of selected surface: " _
& vbCrLf _
& vbCrLf & " X = " & XYZ(0) * 1000 & " mm" _
& vbCrLf & " Y = " & XYZ(1) * 1000 & " mm" _
& vbCrLf & " Z = " & XYZ(2) * 1000 & " mm"
swApp.SendMsgToUser Msg
Set myOutFile = fso.OpenTextFile(sFilePath, ForWriting, Create:=True)
myOutFile.WriteLine Msg
myOutFile.Close
Set myOutFile = Nothing
Set fso = Nothing
End Sub