Hi @Curtis_Waguespack and everyone.
I'm working on creating a section view using the code below. However, I need to crop it in a specific way, as shown in the attached images.
Does anyone know how I can make this crop in the section view?
I was considering using a work point that I already have in one of the parts (Point2), which is located exactly in the center of the connection I want to section.
I appreciate any suggestions or ideas. Thanks!
Class Detalles
Public oDrawDoc As DrawingDocument
Public oTG As TransientGeometry
'get the sheet
Public oSheet As Sheet
'get base view
Public oBaseView As DrawingView
Public SketchName As String
Public SectionViewName As String
Public oPartDoc As AssemblyDocument
Sub Main()
oDrawDoc = ThisApplication.ActiveDocument
oTG = ThisApplication.TransientGeometry
oSheet = oDrawDoc.ActiveSheet
oBaseView = oSheet.DrawingViews.Item(3)
SketchName = "Section Sketch"
SectionViewName = "Z"
'VistaDetalle()
VistaSeccion()
End Sub
' Sub VistaDetalle()
' End Sub
Sub VistaSeccion()
'[ delete section view if it already exits
For Each View As DrawingView In oSheet.DrawingViews
'delete view from previous try if it exists
If View.name = SectionViewName Then
Try : View.Delete : Catch : End Try
End If
'delete sketch if it already exits
Try : oBaseView.Sketches.Item(SketchName).Delete : Catch : End Try
Next
']
Dim SectionSketch As DrawingSketch = oBaseView.Sketches.Add
SectionSketch.Edit
viewExtendPercent = 0.05
Dim angulo As Double = 170
X = oBaseView.Center.X + (6 * Cos((3.1416/180)*angulo))
Y = oBaseView.Center.Y + (6 * Sin((3.1416/180)*angulo))
Dim SectionPoint_L As Point2d = oTG.CreatePoint2d(oBaseView.Center.X, oBaseView.Center.Y)
Dim SectionPoint_R As Point2d = oTG.CreatePoint2d(X, Y)
Dim SheetPoint_L As Point2d = SectionSketch.SheetToSketchSpace(SectionPoint_L)
Dim SheetPoint_R As Point2d = SectionSketch.SheetToSketchSpace(SectionPoint_R)
Dim SketchLine As Inventor.SketchLine = SectionSketch.SketchLines.AddByTwoPoints(SheetPoint_L, SheetPoint_R)
SectionSketch.ExitEdit
SectionSketch.Name = SketchName
'section view placement point
'the X is intially ignored because of the view alignment, but we reuse this point after alignment is broken
Dim ViewCenterPoint As Point2d = oTG.CreatePoint2d(oBaseView.Center.X + 10, oBaseView.Center.Y + oBaseView.Height)
Dim SectionView As Inventor.SectionDrawingView
SectionView = oSheet.DrawingViews.AddSectionView(oBaseView, SectionSketch, ViewCenterPoint,
DrawingViewStyleEnum.kFromBaseDrawingViewStyle, , , SectionViewName)
SectionView.Aligned = False 'break alignement
SectionView.Center = ViewCenterPoint 'move view
SectionView.ReverseDirection
Dim rotacion As Double
If angulo > 37 And angulo < 270 Then
rotacion = (3.1416 / 180) * (angulo - 180)
Else
rotacion = (3.1416 / 180) * (angulo)
End If
SectionView.RotateByAngle(rotacion, True)
End Sub
End Class

