View Face Method

View Face Method

Anonymous
Not applicable
901 Views
6 Replies
Message 1 of 7

View Face Method

Anonymous
Not applicable

Hi, Does view face feature can be done through customize program? I cannot find its method in object browser. Please help me on this. Please see attached file for reference. ..

0 Likes
902 Views
6 Replies
Replies (6)
Message 2 of 7

Vladimir.Ananyev
Alumni
Alumni

Could you try this:

Sub AppLookAtCmd()
   Dim oControlDef As ControlDefinition
   Set oControlDef = ThisApplication.ControlDefinitions.Item("AppLookAtCmd")
   oControlDef.Execute
End Sub

Look here for more informaton on running Inventor commands using API

http://modthemachine.typepad.com/my_weblog/2009/03/running-commands-using-the-api.html

Cheers

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hi Vladimir,

 

Using the code you provided, an error will occur ("Object doesn't support this property or method"). I check ControlDefinition object but I cannot find it in the object browser. By the way I'm using Inventor 2011 and VBA.

 

 

0 Likes
Message 4 of 7

Vladimir.Ananyev
Alumni
Alumni

Sorry, I lost CommandManager while edited line breaks 😞

Private Sub AppLookAtCmd()
   Dim oControlDef As ControlDefinition
   Set oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppLookAtCmd")
   oControlDef.Execute
End Sub

ControlDefinition object was introduced in Inventor version 6.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 7

Anonymous
Not applicable

Hi Vladimir,

 

The code is now fine but sorry I don't know what's the use of the code. Is this in relation to view face feature? All I want is to have a code that will view a particular face of a part then set the view to front view. The program I have now is on how to set a view to front view.

0 Likes
Message 6 of 7

Vladimir.Ananyev
Alumni
Alumni

Command "AppLookAtCmd" shows you the selected entity.

So you need to add the reference to the desired face to the empty  SelectSet collection just before the execution of the "AppLookAtCmd" command.

The following sample do this operation with the first face in the active part document: 

Private Sub LookAtSelectedFace()

  Dim oDoc As Inventor.PartDocument
  Set oDoc = ThisApplication.ActiveEditDocument 

  Dim oSSet As SelectSet
  Set oSSet = oDoc.SelectSet
  Call oSSet.Clear  ‘ make SelectSet empty 

  ' Select the 1st face in the 1st surface body
  Dim oFace As Face
  Set oFace = oDoc.ComponentDefinition.SurfaceBodies.Item(1).Faces.Item(1)

  Call oSSet.Select(oFace) 

  ‘change active view camera orientation
  Dim oControlDef As ControlDefinition
  Set oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppLookAtCmd")
  oControlDef.Execute
  Beep
End Sub

  

If you plan to work in the assembly context then you should select not Face but corresponding  FaceProxy object.  You may find the overview on proxies in  the Inventor API Help.  The following posts could be useful as well:

http://adndevblog.typepad.com/manufacturing/2013/07/occurrences-contexts-definitions-proxies.html

http://modthemachine.typepad.com/my_weblog/2009/04/positioning-assembly-occurrences.html

 

The alternative approach is a bit more complicated because you have to manipulate the active view Camera object. Here are useful links:

http://modthemachine.typepad.com/my_weblog/2013/09/working-with-cameras-part-1.html

http://modthemachine.typepad.com/my_weblog/2013/09/working-with-cameras-part-2.html

Hope this helps.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 7 of 7

Anonymous
Not applicable

Hi Vladimir,

 

AppLookAtCmd would not work in my add-in. I already tried the code you've given and it works fine with VBA. We are now upgrading our VBA project to add-in. Do you have an idea with this?

 

0 Likes