zubaj
Bioengineer
- Jul 31, 2007
- 40
Does anyone know how to get a point cloud of a surface from an existing solid model? I don't have Solidworks Premium, so unfortunately, I don't have the Scan 2 3D function.
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.
Const OUTFILEPATH As String = "C:\OutTest.txt"
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim myBody As SldWorks.Body2
Dim myVertexArray As Variant
Dim myVertex As SldWorks.Vertex
Dim myBodyArray As Variant
Dim myBodyFolder As SldWorks.BodyFolder
Dim myFeature As SldWorks.Feature
Dim XYZ As Variant
Dim fso As Scripting.FileSystemObject
Dim OutFile As Scripting.TextStream
Dim i As Long
Dim j As Long
Sub main()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set myFeature = swDoc.FirstFeature
Set fso = CreateObject("Scripting.FileSystemObject")
Set OutFile = fso.OpenTextFile(OUTFILEPATH, ForWriting, True)
While Not (myFeature Is Nothing)
If (myFeature.GetTypeName = "SolidBodyFolder") Or _
(myFeature.GetTypeName = "SurfaceBodyFolder") Or _
(myFeature.GetTypeName = "CutListFolder") Or _
(myFeature.GetTypeName = "SubWeldFolder") Or _
(myFeature.GetTypeName = "SubAtomFolder") Then
Set myBodyFolder = myFeature.GetSpecificFeature2
If myBodyFolder.GetBodyCount > 0 Then
myBodyArray = myBodyFolder.GetBodies
For i = 0 To UBound(myBodyArray)
Set myBody = myBodyArray(i)
If myBody.GetVertexCount > 0 Then
myVertexArray = myBody.GetVertices
For j = 0 To UBound(myVertexArray)
Set myVertex = myVertexArray(j)
XYZ = myVertex.GetPoint
OutFile.WriteLine XYZ(0) & vbTab & XYZ(1) & vbTab & XYZ(2)
Next j
End If
Next i
End If
End If
Set myFeature = myFeature.GetNextFeature
Wend
OutFile.Close
MsgBox "Point data output to:" & vbCrLf & vbCrLf & OUTFILEPATH
End Sub