×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

API Table Feature

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

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

RE: API Table Feature

(OP)
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.

RE: API Table Feature

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

RE: API Table Feature

(OP)
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.

RE: API Table Feature

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.

I could be the world's greatest underachiever, if I could just learn to apply myself.
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: API Table Feature

(OP)
'***********************************************************
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
'***********************************************************

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources