Greetings,
I thought I might start a new post as it is more direct to the issue. Most posts concerning selecting a face have either users select the face but in my case I have the feature in my grasp and getting the child face. I have not seen any examples of this yet.
Original post here:
https://forum.solidworks.com/message/651921#comment-651921
This is the core of the issue as I see it and I am at a loss. There is no reason this is not working:
holeface = the_hole.GetFaces(0)
holesurf = holeface.IGetSurface
MsgBox(holesurf.IsCylinder)
sel_entity = holeface
boolstat = sel_entity.Select2(False, 1)
MsgBox(boolstat)
The first message box reports True which means I have the correct face in my grasp but the second message box reports False which means it did not select.
Any help is GREATLY appreciated.
SolidworksApi macros
Why aren't you using holeface.GetSurface?
What are the variable types of holeface, holesurf and sel_entity?
Select2 is for selecting features, don't you need Select4?
Greetings Amen,
I gave that a try and I had no better luck. I will try that again and if it does not work I will post that code for your review.
Dim boolstat As Boolean
Dim holeface As Face2 = Nothing
Dim holesurf As ISurface = Nothing
Dim sel_entity As Entity
I have run through Select through Select4 with no luck. I was not aware that the different selects were for different types.
With these two posts I will change to Select4 and GetSurface.
Thanks to all!
Here is the new code with igetserface used and Select4. Once again the first messagebox says true and all debugging shows I have the surface, but the Select4 still does not work.
holeface = the_hole.GetFaces(0)
holesurf = holeface.GetSurface
sel_entity = holesurf
boolstat = sel_entity.Select4(False, Nothing)
MsgBox(holesurf.IsCylinder)
MsgBox(boolstat)
I know I am missing something simple. Your time and help is greatly appreciated.
I have made much progress and I think I see my error but I am still not quite there yet. I have realized that I need my selection manager to be against my component that owns the face to select, not the assembly.
sel_entity = holeface
Dim sel_entity2 As IEntity = sel_entity.GetSafeEntity
Dim swcomp1 As Component2 = swcomp_holes
Dim swmodel2 As ModelDoc2 = swcomp1.IGetModelDoc
Dim swSelMgr2 As SelectionMgr = swmodel2.ISelectionManager
Dim swSelData As SelectData = swSelMgr2.CreateSelectData
boolstat = sel_entity2.Select4(False, swSelData)
I am getting a serious memory error when I hit that last step. It actually did select the face one time just before hitting this error.
Any ideas to get me past this error is greatly appreciated.
Memory access violation errors are caused by a bad configuration of SolidWorks. Do you have existing any other SolidWorks versions?