I recorded a macro which makes an assembly of two parts. but when i try to read it i have a runtime error 13 at the line: << Create ConcentricMateFeatureData Set MateData = Part.CreateMateData (1) >>. what does this mean and how to fix this error? I put t

I recorded a macro which makes an assembly of two parts. but when i try to read it i have a runtime error 13 at the line:
<< Create ConcentricMateFeatureData
Set MateData = Part.CreateMateData (1) >>.
what does this mean and how to fix this error?
I put the macro and the 2 pieces I want to assemble.

SolidworksApi/macros
Answers 3
FR
FR 2021-04-08 Best Answer

Hello, It's likely that the selection of faces, before this line, is not correct.

You shouldn't use SelectByRay anywhere in the macro, since the result will never be accurate.

Take a look at 2015 SOLIDWORKS API Help - Add and Mate Component Example (VBA) 

for a better way to add a component and add mate

FR
FR 2021-04-08

To use SelectByID2: record a macro, select the face, stop the macro, open the macro, copy the SelectByID2 line

However the best way to select a face, is to loop through all the faces to find the one you want by comparing their area and/or the face's normal vector. With 2016 SOLIDWORKS API Help - GetFirstFace Method (IBody2) and 2016 SOLIDWORKS API Help - GetNextFace Method (IFace2) 

ID
ID 2021-04-08

thank you a lot. but when i use SelectByID2 how do I select the face? especially the left side which is not shown? thank you