Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
AlexFielder
in reply to: Anonymous

Being in a part shouldn't matter.

 

You would need to call this from another method like this (this was written from memory so I can't say for certain it'll work 100%!):

Sub Main()
dim partDoc as partdocument = thisapplication.activedocument 'gets the activedocument in partdocument form
dim partDef as partcomponentdefinition = partdoc.componentdefinition 'gets the part file definition.
dim selectedworkplane as workplane = partDef.workplanes(1) 'gets the XY plane so swap this with whatever your object is
SetFrontViewToWorkplane(ThisApplication, partDoc, selectedworkplane)

End Sub

Public Shared Sub SetFrontViewToWorkplane(ByVal InventorApp As Inventor.Application, ByVal partDoc As PartDocument, ByVal selectedWorkPlane As WorkPlane)
    partDoc.SelectSet.Clear()
    partDoc.SelectSet.[Select](selectedWorkPlane)
    Dim selSet As SelectSet = partDoc.SelectSet
    Dim LookAt As ControlDefinition = InventorApp.CommandManager.ControlDefinitions("AppLookAtCmd")
    LookAt.Execute()
    selSet.Clear()
    Dim activeView As View = InventorApp.ActiveView
    activeView.SetCurrentAsFront()
End Sub

If you still have issues, please respond here with your complete rule and any error messages you receive.

Cheers,

Alex.