I use Solidworks 2013 SP5.
I want to pattern a part in assembly by Macro.
It doesn't work.
-----------------------------------------------------------------------------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Windows.Forms
Module Module8
Public Sub Process(ByVal swApp As SldWorks, ByVal swDoc As ModelDoc2, ByVal AssyName As String, ByVal PartName1 As String, ByVal PartName2 As String, ByVal PartName3 As String, ByVal BodyFaceName As String)
Dim myfeature As Feature
Dim swComp As Component2
Dim swSelMgr As SelectionMgr
Dim swSelData As SelectData
Dim swPart As PartDoc
Dim swFace As Face2
Dim swEnt As Entity
Dim swEnt2 As Entity
Dim bRet As Boolean
Dim swModelDocExt As ModelDocExtension
Dim swAssy As AssemblyDoc
Dim filename As String = swDoc.GetTitle
swAssy = swDoc
swModelDocExt = swDoc.Extension
swComp = swAssy.GetComponentByName(PartName3 & "-1")
swPart = swComp.GetModelDoc2()
swSelMgr = swDoc.SelectionManager
swSelData = swSelMgr.CreateSelectData
swFace = swPart.GetEntityByName(BodyFaceName, 2)
swEnt = swFace
swEnt2 = swComp.GetCorrespondingEntity(swEnt)
swDoc.ClearSelection2(True)
bRet = swDoc.Extension.SelectByID2(PartName1 & "-1@" & AssyName, "COMPONENT", 0, 0, 0, True, 1, Nothing, 0)
bRet = swDoc.Extension.SelectByID2(PartName2 & "-1@" & AssyName, "COMPONENT", 0, 0, 0, True, 1, Nothing, 0)
bRet = swEnt2.Select4(True, swSelData) ' the selected face is reference face for circular pattern
myfeature = swDoc.FeatureManager.FeatureCircularPattern3(8, 2 * 4 * Math.Atan(1), False, "NULL", False, True)
End Sub
End Module
SolidworksApi macros