- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there,
I'm writing some simple code for the stress analysis enviroment. I want to launch the local mesh option, select all the faces of a component occurrence so that i don't have to pick them all individually.
I launch the stress analysis feature using the following code:
Dim oCtrlDef As ControlDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("FeaCreateLocalMeshControlCtxCmd")
oCtrlDef.Execute
But I don't know how to select all the faces. I've tried this:
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisDoc.Document 'ThisApplication.ActiveDocument()
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition
' Create the Enumerator to catch all the leaf occurrences of the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator
oLeafOccs = oAsmCompDef.Occurrences.AllLeafOccurrences
Dim oCompDef as AssemblyComponentDefinition
oCompDef = oAsmDoc.ComponentDefinition
Dim oSBodies As Inventor.SurfaceBodies
oSBodies = oCompDef.SurfaceBodies
Dim oSBody As SurfaceBodyProxy
Dim oFaceProxy As FaceProxy
Dim oFace As Face
Dim faceCol as FaceCollection
faceCol = ThisApplication.TransientObjects.CreateFaceCollection
Dim oSelectSet As SelectSet
oSelectSet = oAsmDoc.SelectSet
oSelectSet.Clear
For Each oOcc In oLeafOccs
If oOcc.Name = "test:1" Then
oSBodies = oOcc.SurfaceBodies
For Each oSBody In oSBodies
j = j + 1
For Each oFaceProxy In oSBody.faces
'For Each oFace In oSBody.faces
'oFace = oFaceProxy.NativeObject
oSelectSet.select(oFaceProxy)
'oSelectSet.select(oFaceProxy.parent)
'oSelectSet.select(oFace)
Next
Next
End If
Next
The commented out bits show other things i've tried. I can select the faces when the local mesh window is not open. But nothing seems to work when it is.
Any help would be greatly appreciated.
thanks,
John
Solved! Go to Solution.