Drawing View Selection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have written a little code that places 3 drawing views of a part onto a sheet and positions them relative to one another. Is there a way to automatically select these 3 views (oViewB, oViewR, oViewT) so I can quickly move them into place manually. Also is there a way to move the projected views accordingly when the scale is changed?
Public Class Form1
Dim invApp As Inventor.Application
Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oModel As PartDocument
Dim oTG As TransientGeometry
Dim oViewOrientationB As ViewOrientationTypeEnum
Dim oViewB As DrawingView
Dim oViewR As DrawingView
Dim oViewT As DrawingView
Public Sub New()
' This call is required by the designer.
InitializeComponent()
Try
invApp = Marshal.GetActiveObject("Inventor.Application")
Catch ex As Exception
MsgBox("There is no active session, please open a DWG file.")
End Try
End Sub
Private Sub BTN_PFC_Click(sender As Object, e As EventArgs) Handles BTN_PFC.Click
' Open the part document invisibly
oModel = invApp.Documents.Open("C:\PART1.ipt", False)
' Create the view orientation of object.
oViewOrientationB = ViewOrientationTypeEnum.kLeftViewOrientation
PlaceView()
End Sub
Public Sub PlaceView()
' Set a reference to the drawing document.
' This assumes a drawing document is active.
oDoc = invApp.ActiveDocument
'Set a reference to the active sheet.
oSheet = oDoc.ActiveSheet
oTG = invApp.TransientGeometry
Dim XPos As Integer = 21
Dim YPos As Integer = 15
Dim oPointB As Point2d
Dim oPointLBL As Point2d
Dim oViewStyleB As DrawingViewStyleEnum
' Base View
' Create the placement point of object and label.
oPointB = oTG.CreatePoint2d(XPos, YPos)
' Create the view style of object.
oViewStyleB = DrawingViewStyleEnum.kHiddenLineDrawingViewStyle
' Create a base view.
' Rotate BaseView
oViewB = oSheet.DrawingViews.AddBaseView(oModel, oPointB, 0.1, oViewOrientationB, oViewStyleB, "Default")
oViewB.RotateByAngle(270 * (Math.PI / 180), True)
oPointLBL = oTG.CreatePoint2d(XPos, YPos - (oViewB.Height / 2) - 0.75)
oViewB.Label.Position = oPointLBL
Dim oPointR As Point2d
' Right View
' Create the placement point of object with orientation.
oPointR = oTG.CreatePoint2d(XPos + oViewB.Width / 2 + 2, YPos)
oViewR = oSheet.DrawingViews.AddProjectedView(oViewB, oPointR, ViewStyle:=DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
Dim oPointT As Point2d
' Top View
' Create the placement point of object with orientation.
oPointT = oTG.CreatePoint2d(XPos, YPos + oViewB.Height / 2 + 2)
oViewT = oSheet.DrawingViews.AddProjectedView(oViewB, oPointT, ViewStyle:=DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
End Sub