I have a problem about the cylinder
I can get the surface wich is a cylinder
Is there any way that can distinguish this cylinder is a hole or entity just like the figure below?
Try this code:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFace As SldWorks.Face2
Dim i As Long
Dim bRet As Boolean
Dim swSurf As Surface
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swFace = swSelMgr.GetSelectedObject5(1)
Set swSurf = swFace.GetSurface
If swSurf.IsCylinder Then
bRet = swFace.FaceInSurfaceSense
If bRet = True Then swApp.SendMsgToUser "Cylindrical surface is hole"
If bRet = False Then swApp.SendMsgToUser "Cylindrical surface is not hole"
I haven't tested this but it should work.
A possible path would be to set the entity name of the two cylinder faces. Right click on the cylinder face then click face properties to add a name.
Get an entity by name: 2013 SOLIDWORKS API Help - GetEntityName Method (IModelDoc2)
The method you provide is worked and executed successfully.
The FaceInSurfaceSense method's detailed description is in the link
2016 SOLIDWORKS API Help - FaceInSurfaceSense Method (IFace2)
I'm glad that you solve my problem.
Thank you very much.
2016 SOLIDWORKS API Help - Determine Type of Face Example (VBA)
Retrieving data ...