I appreciate the help you are giving me, but i still cant wrap my head around how to make subs work.
The changes you made previously worked well and made that part of the rule very reliable.
My goal for my rule is to place a baseview of a pre determined part on a drawing sheet, at a location specified by the user.
Some of my code works and some doesn't.
It will get and report the location properly but will not place the baseview.
The sub also runs in an infinite loop until escape is pressed.
would you mind having a look at this code?
Sub Main()
_doc = ThisDoc.Document
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim DrawingViewScale As Double = 0.1
Dim myWorkSpace = ThisApplication.FileLocations.Workspace
Dim placepart As String = myWorkSpace +"\Test1-P001.ipt"
MessageBox.Show(placepart,"test1")'works
oInteraction = ThisApplication.CommandManager.CreateInteractionEvents
oMouse = oInteraction.MouseEvents
AddHandler oMouse.OnMouseClick, AddressOf oMouse_OnMouseDown
oInteraction.Start
End Sub
Private _doc As DrawingDocument
Private oInteraction As InteractionEvents
Private oMouse As MouseEvents
Private oSheet As Sheet
Private placepart As String 'THIS DOES NOT WORK, I LACK THE UNDERSTANDING
Sub oMouse_OnMouseDown(Button As MouseButtonEnum, ShiftKeys As ShiftStateEnum, ModelPosition As Point, ViewPosition As Point2d, View As Inventor.View)
Dim DrawingViewScale As Double = 0.1
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oPoint1 As Point2d = oTG.CreatePoint2d(ModelPosition.X, ModelPosition.Y) 'works
MessageBox.Show("X coord: " +oPoint1.X.ToString +vbCrLf+"Y coord: " +oPoint1.Y.ToString , "Title") 'works
MessageBox.Show(placepart, "test2") 'THIS DOES NOT WORK
'Create the Base View 'THIS DOES NOT WORK
oBaseViw = oSheet.DrawingViews.AddBaseView(placepart, oPoint1, DrawingViewScale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
End Sub