Hi,I have an issue with the automatic creation of sections in a drawing.The script I created will create a section when I click on the main view and draws it at a defined position on the sheet. The next section will then be placed a few centimeters away.This works as intended, but after a few sections the orientation of the sections will suddely switch (from left to right for example).As shown in this picture. Section C should also show to the left.How can I set it up, the sections are always view to the left side of the sheet.Here my code:Sub Main
Dim oInvApp As Inventor.Application = ThisApplication
Dim oDDoc As DrawingDocument = TryCast(oInvApp.ActiveDocument, Inventor.DrawingDocument)
If oDDoc Is Nothing Then
MessageBox.Show("Rule named '" & iLogicVb.RuleName & "' did not run because no Drawing obtained!", _
"No Active Drawing", MessageBoxButtons.OK, MessageBoxIcon.Stop)
'Logger.Debug("Rule named '" & iLogicVb.RuleName & "' did not run because no Drawing obtained!")
Return
End If
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oDViews As Inventor.DrawingViews = oSheet.DrawingViews
For Each oView As DrawingView In oSheet.DrawingViews
If oView.ViewType = DrawingViewTypeEnum.kSectionDrawingViewType Then
Try : oView.Delete : Catch : End Try
End If
Next
For Each oView As DrawingView In oSheet.DrawingViews
For Each oSketchold As DrawingSketch In oView.Sketches
Try : oView.Sketches.Item(oSketchold.Name).Delete : Catch : End Try
Next
Next
Dim oFrontView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oModelDocBase As Inventor.Document = oFrontView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oXYPlaneBase As Inventor.WorkPlane = oModelDocBase.ComponentDefinition.WorkPlanes.Item(3)
oFrontView.SetVisibility(oXYPlaneBase, True)
Dim i As Integer
Dim m As Integer
Dim n As Integer
Dim x As Integer
m = 7 'Y coordinate on sheet for section placement
n = 5
x = 1
For i = 1 To 6
'prompt the user to 'Pick' the 'Parent View'
Dim oParentView As Inventor.DrawingView = oInvApp.CommandManager.Pick( _
SelectionFilterEnum.kDrawingViewFilter, "Pick Parent Drawing View")
'if nothing was selected, then exit this rule
If oParentView Is Nothing Then Return
'here we are creating an 'instance' of the custom Class
'and supplying a reference to the currently running Inventor.Application object
Dim oMouseClick As New MouseClickCls(oInvApp)
'here we are calling its Public Function to run
'it will pause this rule, allow manual click, capture it, and return it, and unpause this rule
Dim oP3D As Inventor.Point = oMouseClick.GetMouseClickModelPoint()
'it returns a 3D point in model space, so convert it to a 2D point by eliminating the Z coordinate
Dim oP2D As Inventor.Point2d = oInvApp.TransientGeometry.CreatePoint2d(oP3D.X, oP3D.Y)
Dim oCent As Point2d
Dim oDist As Point2d
oDist = ThisApplication.TransientGeometry.CreatePoint2d(oP2D.X - oParentView.Center.X, oP2D.Y - oParentView.Center.Y )
Dim oSketch As Inventor.DrawingSketch
Dim oDC As Inventor.DrawingCurve
oSketch = oParentView.Sketches.Add
oSketch.Edit
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Dim oConv As Double = 1 / oParentView.Scale
Dim oCenter As Double = oParentView.Center.Y
Dim oHeight As Double = oParentView.Height / 1
Dim oX As Double = oDist.X * oConv
Dim oY1 As Double = oHeight * oConv - 20
Dim oY2 As Double = - oHeight * oConv + 20
Dim oPointA As Point2d
oPointA = ThisApplication.TransientGeometry.CreatePoint2d(oX, oY1)
Dim oPointB As Point2d
oPointB = ThisApplication.TransientGeometry.CreatePoint2d(oX, oY2)
Dim oLine As SketchLine
oLine = oSketch.SketchLines.AddByTwoPoints(oPointA, oPointB)
oSketch.ExitEdit
Dim DPPV As Double = (m)
Dim DPPH As Double = (n)
Dim oDPP As Point2d
oDPP = ThisApplication.TransientGeometry.CreatePoint2d(DPPH, DPPV)
Dim oLPP = ThisApplication.TransientGeometry.CreatePoint2d(DPPH, 12.5) 'Height of Lable for section
Dim oScale = 1 / 30
Dim SectionView As Inventor.SectionDrawingView
SectionView = oSheet.DrawingViews.AddSectionView(oParentView, oSketch, oDPP, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, oScale, , SectionViewName, , False, 50)
SectionView.Aligned = False
SectionView.Center = oDPP
SectionView.Label.ConstrainToBorder = False
SectionView.ReverseDirection
Dim oModelDoc As Inventor.Document = SectionView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oXYPlane As Inventor.WorkPlane = oModelDoc.ComponentDefinition.WorkPlanes.Item(3)
SectionView.SetVisibility(oXYPlane, True)
Dim SheetY As Double = 6.0 'height of ground plane of section from bottom of sheet
Dim Y1 As Double = SectionView.ModelToSheetSpace(oXYPlane.Plane.RootPoint).Y
SectionView.Position = ThisApplication.TransientGeometry.CreatePoint2d(SectionView.Position.X, SectionView.Position.Y + (SheetY - Y1))
SectionView.Label.Position = oLPP
SectionView.Name = num2Letter(x)
SectionView.ViewOrientationFromBase
'SectionView.Label.Text
n = n + 5
x = x + 1
Next
m = m - 5
n = 5
Exit Sub
End Sub
| # | Наименование новости | Тональность | Информативность | Дата публикации |
|---|---|---|---|---|
| 1 | "shaded" model views are buggy | 0 | 9.58 | 21-09-2026 |
| 2 | [BUG] "Align to" on a UCS plane orients the view to the Default Coordinate System instead of UCS | 0 | 6.94 | 25-07-2026 |
| 3 | Shared View does not respect the redefined ViewCube Top orientation | 0 | 5.16 | 02-08-2026 |
| 4 | Can I change the 3D shape of the elevator bank? | 0 | 8.91 | 21-09-2026 |
| 5 | Autodesk Desktop Connector file update/upload errors | 0 | 15.2 | 05-08-2026 |
| 6 | How to Create Louvers with Curtain Panel family, and slanted on top | 0 | 5.6 | 21-09-2026 |
| 7 | Re: Symbol Builder No Generic In Horizontal Parent | 0 | 5 | 18-07-2026 |
| 8 | The option to flip the orientation of the construction plane is suddenly not there any more | 0 | 5.45 | 21-09-2026 |
| 9 | Configuration Inventor 2026 part for export to pcf file. | 0 | 7.65 | 21-09-2026 |
| 10 | IFC exporter | 0 | 11.9 | 21-09-2026 |