I converted an Inventor API sample for creating detail views to iLogic. Initially it took me 2 minutes, and I had the code working well, but the sample code is for a detail view with a rectangular boundary, as shown below.
I don’t use the rectangular version, so I spent a good 30 minutes figuring out how to get a circular boundary as shown in the animated GIF below.
You may be wondering what the secret was. The CircularFence option is listed as a Boolean in the API help. This means that it’s set to “True” for circular and “False” for rectangular.
My iLogic code contains both circular and rectangular options, I have commented out the rectangular part. As the code is mostly from the Inventor API sample, it is quite well commented.
Here is the iLogic code:
'This version of iLogic code by @ClintBrown3D, based on Inventor API sample 'Originally Published at https://clintbrown.co.uk/automating-detail-views-with-ilogic ' Set a reference to the drawing document - This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument ' Select a drawing view. Dim oDrawingView As DrawingView oDrawingView = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Select a drawing view.") 'Set a reference to the active sheet. Dim oSheet As Sheet oSheet = oDrawingView.Parent ' Set a reference to the center of the base view. Dim oPoint As Point2d oPoint = oDrawingView.Center ' Translate point by a distance equal to the width of the view. This will be the placement point of the detail view. oPoint.X = oPoint.X + oDrawingView.Width ' Arbitrarily find an arc within the selected drawing view. The detail view will include this arc. Dim oCurve As DrawingCurve Dim oArcCurve As DrawingCurve For Each oCurve In oDrawingView.DrawingCurves If oCurve.CurveType = kCircularArcCurve Then oArcCurve = oCurve Exit For End If Next If Not oArcCurve Is Nothing Then ' Use the range of the arc in sheet space to calculate the detail view box. Dim oCornerOne As Point2d oCornerOne = oArcCurve.Evaluator2D.RangeBox.MinPoint oCornerOne.X = oCornerOne.X - 1 oCornerOne.Y = oCornerOne.Y - 1 Dim oCornerTwo As Point2d oCornerTwo = oArcCurve.Evaluator2D.RangeBox.MaxPoint oCornerTwo.X = oCornerTwo.X' + 1 oCornerTwo.Y = oCornerTwo.Y' + 1 Dim oDetailView As DetailDrawingView ' Create the detail view with a Circular cutout oDetailView = oSheet.DrawingViews.AddDetailView(oDrawingView, oPoint, kFromBaseDrawingViewStyle, True, oCornerTwo, 1, , oDrawingView.Scale * 2, True,,False) ' Create the detail view with a rectangular box. ' oDetailView = oSheet.DrawingViews.AddDetailView(oDrawingView, oPoint,kFromBaseDrawingViewStyle, False, oCornerOne, oCornerTwo, , oDrawingView.Scale * 2) Else MsgBox("No arc was found in the selected drawing view.") End If
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!