- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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![]()
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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 SubIf you still have issues, please respond here with your complete rule and any error messages you receive.
Cheers,
Alex.
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you very much. I'm new to ilogic and code. So how can i choose the desired workplane?
Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm trying to understand your code:
Dim LookAt As ControlDefinition = InventorApp.CommandManager.ControlDefinitions("AppLookAtCmd")Where did U find this command "AppLookAtCmd" ?