AnsweredAssumed Answered

Select Named Entity of Assembly Component

Question asked by A. T. on Apr 7, 2020
Latest reply on Apr 8, 2020 by A. T.

Hello to everyone, I want to create a macro for automating the creation of an assembly document and the mating of two simple parts. So far I've managed to do the following:

1. Create an assembly document

2. Open the necessary parts

3. Import the parts to the assembly as components

 

At this point I want to select an already named edge of part No1 and an already named edge of part No2. I know I can use GetEntityByName and Select4 methods for selecting faces, edges and vertices inside a part document (example in code below), but I do not know how to apply the aforementioned methods for selecting a named entity of a component inside an assembly. 

I would appreciate any help.

 

With regards,

Tasos

---------------------------------------------------------------------------------------------------------------------------------------------------------------

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc

Dim swEdge As SldWorks.Edge
Dim swEnt As SldWorks.Entity

Dim swSelectData As SldWorks.SelectData

 

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swPart = swModel

 

Set swEdge = swPart.GetEntityByName("Edge1", swSelEDGES)
Set swEnt = swEdge

swEnt.Select4 True, swSelectData

End Sub

Outcomes