Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Set Section view orientation in iLogic

Дата публикации: 21-09-2026 10:39:06

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 buggy09.5821-09-2026
2[BUG] "Align to" on a UCS plane orients the view to the Default Coordinate System instead of UCS06.9425-07-2026
3Shared View does not respect the redefined ViewCube Top orientation05.1602-08-2026
4Can I change the 3D shape of the elevator bank?08.9121-09-2026
5Autodesk Desktop Connector file update/upload errors015.205-08-2026
6How to Create Louvers with Curtain Panel family, and slanted on top05.621-09-2026
7Re: Symbol Builder No Generic In Horizontal Parent0518-07-2026
8The option to flip the orientation of the construction plane is suddenly not there any more05.4521-09-2026
9Configuration Inventor 2026 part for export to pcf file.07.6521-09-2026
10IFC exporter011.921-09-2026

Классификация: . Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 6.66. Источник: forums.autodesk.com.