Setting view cube orientation with iLogic

Anonymous

Setting view cube orientation with iLogic

Anonymous
Not applicable

I am looking to have an iLogic rule run in the background that will set the model front view to be normal to a work plane i have in the model. This is part of a parametric model and the view in the drawings will rotate when the parameters are edited. This moves my dimensions and alters the values to be unrepresented. I am still new to inventor iLogic and could really use some help. I have tried locking the view but that has not worked. Thank you in advance.

0 Likes
Reply
Accepted solutions (1)
2,000 Views
6 Replies
Replies (6)

AlexFielder
Advisor
Advisor

Here's a method for this I wrote a while back:

 

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

🙂

0 Likes

Anonymous
Not applicable

This is giving me an error 

"Rule Compile Errors in Rule0, in 005 - SUPPORT ARM DETAIL

Error on Line 1 : Statement cannot appear within a method body. End of method assumed.
Error on Line 13 : 'End Sub' must be preceded by a matching 'Sub'."

I am trying to do this in a part level, if that changes the way the code is written.

0 Likes

AlexFielder
Advisor
Advisor
Accepted solution

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.

Anonymous
Not applicable

That worked perfectly. Thank You.

0 Likes

ngoclebkdn
Explorer
Explorer

Thank you very much. I'm new to ilogic and code. So how can i choose the desired workplane?

Thank you very much.

0 Likes

l_cecelon
Explorer
Explorer

Hi, I'm trying to understand your code:

Dim LookAt As ControlDefinition = InventorApp.CommandManager.ControlDefinitions("AppLookAtCmd")

Where did U find this command "AppLookAtCmd" ?

 

0 Likes