Hello Everyone,
I am trying to implement a linear pattern in X and Y direction using FeatureLinearPattern4. I had a cube with a hole in it. I implemented a code which will traverse the part find the hole and select. it. The code will then select the 2 perpendicular edges for direction.
The problem was i was using swEntity.Select4(False, swSelData) for selecting my edges and Select2 for my feature. That did not work. So i looked up the interned and found an example which used a SelectbyID2 method and it worked (code below). The problem was SelectbyID2 method has this option called Mark which is used by other functions that require ordered selection.
I am not sure how to get the data for SelectbyID2 (majorly the selection point) to able to implement linearpatter4. I am not sure if there is some other way to implement linear pattern without using SelectbyID2. I would appreciate any help or suggestions on this.
EXAMPLE for SelectbyiD2 which worked
'This example shows how to create a linear-pattern feature using an offset reference.
'----------------------------------------------------------------------------
' Preconditions: Open install_dir\\samples\\tutorial\\api\\varyinstance.sldprt.
'
' Postconditions: Creates LPattern1 in the FeatureManager design tree.
'
' NOTE: Because the model is used elsewhere, do not save any changes.
'----------------------------------------------------------------------------
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim myFeature As SldWorks.Feature
Dim boolstatus As Boolean
Option Explicit
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
' Select feature to pattern
boolstatus = Part.Extension.SelectByID2("Cut-Extrude1", "BODYFEATURE", 0, 0, 0, False, 4, Nothing, swSelectOptionDefault)
' Select Direction 1 reference
boolstatus = Part.Extension.SelectByID2("", "EDGE", -1.43804142453519E-04, 6.90197499537817E-02, 3.70101655861568E-02, True, 1, Nothing, swSelectOptionDefault)
' Select Direction 2 reference
boolstatus = Part.Extension.SelectByID2("", "EDGE", 8.50674319963218E-06, -5.07775663234327E-02, 0.14947002782122, True, 2, Nothing, swSelectOptionDefault)
' Create linear-pattern feature calling IFeatureManager::FeatureLinearPattern4
Set myFeature = Part.FeatureManager.FeatureLinearPattern4( _
3, _
0.02, _
4, _
0.02, _
False, _
False, _
"", _
"", _
False, _
False, _
False, _
False, _
False, _
False, _
True, _
True, _
False, _
False, _
0.19, _
0.01 _
)
End Sub
Regards,
Prashant Mohan
SolidworksApi macros