API Table Feature
API Table Feature
(OP)
I hope someone can help me. I am trying to use TablePatternFeatureData and can't seem to get the sintax to work. I want to use PointArray or LoadPointsFromFile, but neither will work even if a copy the code from the SolidWorks help file.






RE: API Table Feature
Regards,
Regg
RE: API Table Feature
retval = swTableFeatData.SavePointsToFile("C:\Stuff.SLDTAB")
Debug.Print "retval = " & retval
swTableFeatData.PointArray = Array(0.37445, 0.0254, 0.37445, 0.15006, 0.37445, 0.27472, 0.37445, 0.39998, 0.22, 0.0254, 0.22, 0.15006, 0.22, 0.27472)
I was using "SavePointsToFile" to get a sample file format and I was experimenting with the PointArray command.
I have sheetmeal part that has a 4-hole pattern in it that I need to repeat 0-7 times for a max total 8 occurances of the pattern. I can load the array points either from a file (preferred method) or set the array directly.
Any insights would be a appreciated.
RE: API Table Feature
You still did not specify what does not work. Do you get any error messages or does nothing happen when you run the code?
Regards,
Regg
RE: API Table Feature
The name of the help page is TablePatternFeatureData.
RE: API Table Feature
Put a "Stop" statement in your code and open the "Locals Window" when the code breaks to see if your objects getting assigned properly.
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: API Table Feature
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.modelDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swTableFeatData As SldWorks.TablePatternFeatureData
Dim swRefPt As SldWorks.Vertex
Dim swCoordSys As SldWorks.Feature 'Object
Dim vBasePt As Variant
Dim vFace As Variant
Dim vFeat As Variant
Dim vPt As Variant
Dim nPtType As Long
Dim vRefPtParam As Variant
Dim bRet As Boolean
Dim i As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swFeat = swSelMgr.GetSelectedObject5(1)
Set swTableFeatData = swFeat.GetDefinition
' Roll back to get the reference point
bRet = swTableFeatData.AccessSelections(swModel, Nothing): Debug.Assert bRet
' Set swRefPt = swTableFeatData.ReferencePoint
Set swCoordSys = swTableFeatData.CoordinateSystem
vBasePt = swTableFeatData.GetBasePoint
vFace = swTableFeatData.PatternFaceArray
vFeat = swTableFeatData.PatternFeatureArray
vPt = swTableFeatData.PointArray
Debug.Print swFeat.Name
Debug.Print " Coord sys = " & swCoordSys.Name
Debug.Print " FaceCount = " & swTableFeatData.GetPatternFaceCount
Debug.Print " FeatureCount = " & swTableFeatData.GetPatternFeatureCount
Debug.Print " PointCount = " & swTableFeatData.GetPointCount
Debug.Print " ReferencePointType = " & swTableFeatData.GetReferencePointType
Debug.Print " BasePt = (" & vBasePt(0) * 1000# & ", " & vBasePt(1) * 1000# & ", " & vBasePt(2) * 1000# & ") mm"
Debug.Print " GeometryPattern = " & swTableFeatData.GeometryPattern
Debug.Print " UseCentroid = " & swTableFeatData.UseCentroid
retval = swTableFeatData.SavePointsToFile("C:\Stuff.SLDTAB")
Debug.Print "retval = " & retval
swTableFeatData.PointArray = Array(0.37445, 0.0254, 0.37445, 0.15006, 0.37445, 0.27472, 0.37445, 0.39998, 0.22, 0.0254, 0.22, 0.15006, 0.22, 0.27472)
If Not swRefPt Is Nothing Then
' Is NULL if centroid used
vRefPtParam = swRefPt.GetPoint
Debug.Print " RefPt = (" & vRefPtParam(0) * 1000# & ", " & vRefPtParam(1) * 1000# & ", " & vRefPtParam(2) * 1000# & ") mm"
End If
' Roll forward
swTableFeatData.ReleaseSelectionAccess
End Sub
'***********************************************************