Select Face for Local Mesh Inventor Stress Analysis

Select Face for Local Mesh Inventor Stress Analysis

johnster100
Collaborator Collaborator
582 Views
4 Replies
Message 1 of 5

Select Face for Local Mesh Inventor Stress Analysis

johnster100
Collaborator
Collaborator

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

 

0 Likes
Accepted solutions (1)
583 Views
4 Replies
Replies (4)
Message 2 of 5

ekinsb
Alumni
Alumni
Accepted solution

Unfortunately, it's not possible.  Inventor doesn't support the ability for a program to interace with a running command.  You can execute a command, like you're doing but you can't interact with it while it's running.  When some commands are executed that require some selection, they'll first check to see what is currently selected and will use it.  For example, the fillet command does this.  The "Local Mesh" command could do that too but unfortunately does not and without being able to seed the set of faces when the command is executed you can't automate the face selection.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 5

johnster100
Collaborator
Collaborator

Hi Brian,

I assume that's the same for a vb.net driving Inventor and not just ilogic?

 

thanks again,

John

0 Likes
Message 4 of 5

ekinsb
Alumni
Alumni

That's a correct assumption.  It doesn't matter what you're using.  The Local Mesh command needs to be enhanced to support the current selection. 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 5 of 5

johnster100
Collaborator
Collaborator

Cheers Brian,

The help is very much appreciated.

 

thanks,

John

0 Likes