iLogic: Rotating Section Views – Guest Post

By Dutt Thakar

I’ve written 2 iLogic utilities that I hope you will find useful. The first one rotates a section line at a specified angle.

To get it to work, you simply need to edit your section sketch, then add in an angled dimension. In my example this dimension is controlled by parameter “d0”. The iLogic utility makes “d0” equal to a user parameter called “NozzleAngle“, which you can control via a form (sample files attached at bottom of post) .

Here’s a video showing how the code works:

Here is the iLogic code

'iLogic code By Dutt Thakar 'Originally posted on https://clintbrown.co.uk/ilogic-rotating-section-views---guest-post

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oSketch As Sketch = oView.Sketches("Sketch1")

oSketch.Edit
For Each oConstraint In oSketch.DimensionConstraints
If oConstraint.Parameter.Name = "d0" Then
	oConstraint.Parameter.Value = Parameter.Param("NozzleAngle").Value
End If
Next
oSketch.Solve
oSketch.ExitEdit

RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate

The second iLogic utility links parameter “d0” in the drawing, to a user parameter called “NozzleAngle” from the part file. Here is a video showing how the code works:

Here is the iLogic code:

'iLogic code By Dutt Thakar 'Originally posted on https://clintbrown.co.uk/ilogic-rotating-section-views---guest-post

modelName = IO.Path.GetFileName(ActiveSheet.View("VIEW1").ModelDocument.FullFileName)


Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oSketch As Sketch = oView.Sketches("Sketch1")
Parameter("NozzleAngle") = Parameter(modelName & ".NozzleAngle")
oSketch.Edit
For Each oConstraint In oSketch.DimensionConstraints
If oConstraint.Parameter.Name = "d0" Then
	oConstraint.Parameter.Value = Parameter.Param("NozzleAngle").Value
End If
Next
oSketch.Solve
oSketch.ExitEdit


RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate

Download the sample Inventor 2021 Part and Drawing file here.

Notes:

This version of the code was briefly tested in Inventor 2021.

As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!

About the Author:

Dutt Thakar has been using Inventor and Vault since 2014 . He works for a company that creates food and dairy processing plants and equipment. Dutt’s career has been spent mostly working as a Mechanical Design Engineer. In his current role, Dutt creates automated models and drawings using Inventor and iLogic (apart from doing regular projects). He also uses VBA and VB.Net to create automation using the Inventor API.

LinkedIn | Blog