Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

API Table Feature

Status
Not open for further replies.

mcguirepm

Mechanical
Oct 9, 2002
33
0
0
US
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.
 
Replies continue below

Recommended for you

You will have to be more specific. What happens when you run the code? What error messages do you get? Post your code so others can look at it.

Regards,

Regg
 
Using the example from the HELP file for TablePatternFeatureData I added a couple lines:

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.
 
I have never used TablePatternFeatureData calls. I only have SW2004 at home and cannot seem to find the example you refer to. Is this example in SW2005? What is it's exact title on the help screens?

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

 
No errors are reported. It just doesn't work. The Debug.Print retuens a flase statement so I know that the SavePointsToFile command isn't working.

The name of the help page is TablePatternFeatureData.
 
Post more code. It would be helpful to see how you are setting up various objects such as swApp and TableFeaureData.

Put a "Stop" statement in your code and open the "Locals Window" when the code breaks to see if your objects getting assigned properly.

[bat]I could be the world's greatest underachiever, if I could just learn to apply myself.[bat]
-SolidWorks API VB programming help
 
'***********************************************************
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
'***********************************************************

 
Status
Not open for further replies.
Back
Top