Hi,
Try this rule, it will allow you to click mouse where you want to place each view or it will place in the middle of active sheet.
Class thisrule
Dim responce As MsgBoxResult
Dim posx, posy As Double
Dim bstillselecting As Boolean = True
Dim oInteraction As InteractionEvents
Dim oMouse As MouseEvents
Sub Main()
Dim oFileDlg As Inventor.FileDialog
Call ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Inventor Files (*.ipt)|*.ipt|All Files (*.*)|*.*"
oFileDlg.FilterIndex = 1
Dim sInitialDirectory As String
oFileDlg.MultiSelectEnabled = True
oFileDlg.ShowOpen()
Dim files() As String = Split(oFileDlg.FileName, "|")
responce = MessageBox.Show("Do you want to choose views locations by mouse click?", "Views", MessageBoxButtons.YesNoCancel)
If responce = vbYes Then
oInteraction = ThisApplication.CommandManager.CreateInteractionEvents
oMouse = oInteraction.MouseEvents
AddHandler oMouse.OnMouseDown, AddressOf oMouse_OnMouseDown
oInteraction.Start()
End If
Dim draw As DrawingDocument = ThisDoc.Document
For i = 0 To files.Length - 1
If files(i) <> "" Then
bstillselecting = True
Dim oBaseViewOptions As NameValueMap
oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
Call oBaseViewOptions.Add("SheetMetalFoldedModel", False)
' Create the placement point object.
Dim oPoint As Point2d
If responce = vbYes Then
Do While bstillselecting
ThisApplication.UserInterfaceManager.DoEvents
Loop
End If
If responce = vbYes Then
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(posx, posy)
Else
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(draw.ActiveSheet.Width/2, draw.ActiveSheet.Height/2)
End If
Dim oModel As Document
oModel = ThisApplication.Documents.Open(files(i), False)
' Create a base view.
Dim oBaseView As DrawingView
oBaseView = draw.ActiveSheet.DrawingViews.AddBaseView(oModel, oPoint, 1,
ViewOrientationTypeEnum.kDefaultViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle,
, , oBaseViewOptions)
End If
Next
oInteraction.Stop
oInteraction = Nothing
oMouse = Nothing
End Sub
Sub oMouse_OnMouseDown(Button As MouseButtonEnum, ShiftKeys As ShiftStateEnum, ModelPosition As Point, ViewPosition As Point2d, View As Inventor.View)
posx = ModelPosition.X
posy = ModelPosition.Y
bstillselecting = False
End Sub
End Class