Hi All,
I am creating a macro whose function is to select the part file's axis system and mate with the other part which is already there in the assembly environment. The macro firstly opens the part files from the folder after that it selects the reference axis of the part file and then mate with the already open part in assembly. The following is the code which i have written for this function:
Sub main()
Set swcomp = swApp.OpenDoc6(filename, swDocPART, 0, "", longstatus, longwarnings)
Set components = swAssy.AddComponent5(Partname, swAddComponentConfigOptions_CurrentSelectedConfig, "", False, "", 0, 0, 0)
AssemblyTitle = swAssy.GetTitle
' Split the title into two strings using the period (.) as the delimiter
strings = Split(AssemblyTitle, ".")
' You'll use AssemblyName when mating the component with the assembly
AssemblyName = strings(0)
strCompName = components.Name2()
Set swcomp = swApp.ActiveDoc
Set swDocExt = swcomp.Extension
matename = "Align" + strCompName
FirstSelection = "Axis_System@" + strCompName & "@ " + AssemblyName
SecondSelection = strCompName & "_Axis@ Tool_Spec_System " & "@" + AssemblyName
boolstatus = swDocExt.SelectByID2(FirstSelection, "AXIS", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = swDocExt.SelectByID2(SecondSelection, "AXIS", 0, 0, 0, False, 0, Nothing, 0)
If Not boolstatus Then MsgBox "Selection Error:" & refx
Set matefeature = swAssy.AddMate3(swMateType_e.swMateCOORDINATE, swMateAlign_e.swMateAlignALIGNED, False, 0, 0, 0, 0, 0, 0, 0, 0, False, longstatus)
swApp.DocumentVisible False, swDocPART
End sub.
I am getting boolstatus = false and then it does not execute the matefeature command.
Any kind fo help is highly appreciated.
Thanks,
Raj Dave.
SolidworksApi macros