Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all, I'm having a error in the code I'm working on and I cant figure out what the issue is. I think its something easy but I'm very new to using ilogic. Ill attach a screenshot of the error and paste the code below. Any help is appreciated, Thank you
Sub Main Dim sheetNames As New List(Of String) sheetNames.Add("MAIN") Dim sheetSize As DrawingSheetSizeEnum = 9988 Dim invDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = Nothing For index As Integer = 1 To oSheets.Count oSheet = invDoc.Sheets.Add(sheetSize, , sheetNames(index - 1)) Next For Each oSheet In invDoc.Sheets IfoSheet.Name = "Sheet:1" Then oSheet.Delete End If Next For Each oSheet In invDoc.Sheets If oSheet.Name = oSheets(0) & ":1" Then oSheet.Activate End If Next End Sub Sub Main Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = oDoc.ActiveSheet DeleteView(oSheet) Dim sheetCenterVertical As Double = ((oSheet.Height / 2) -1.5) Dim baseViewHorizontal As Double = (oSheet.Width * .17) Dim projViewHorizontal As Double = (oSheet.Width * .4) Dim modelReference As Document = ThisApplication.Documents.Open(SharedVariable("C:\Users\rredekop\Documents\Inventor\New folder") & "\" & "WE" & ".ipt", False) Dim oScale As Double = 1 Dim oPoint(2) As Point2d oPoint(1) = ThisApplication.TransientGeometry.CreatePoint2d(baseViewHorizontal, sheetCenterVertical) oPoint(2) = ThisApplication.TransientGeometry.CreatePoint2d(projViewHorizontal, sheetCenterVertical) Dim viewOrientation(2) As ViewOrientationTypeEnum viewOrientation(1) = 10764 viewOrientation(2) = 10759 Dim viewStyle(2) As DrawingViewStyleEnum viewStyle(1) = 32258 viewStyle(2) = 32258 Dim oBaseView As DrawingView = Nothing Dim oProjView As DrawingView = Nothing For x = 1 To 2 If i = 1 Then oBaseView = oSheet.DrawingViews.AddBaseView(modelReference, oPoint(x), oScale, viewOrientation(x), viewStyle(x)) oBaseView.Name = "BaseView" & x SetViewScale(oSheet, oBaseView) ElseIf i = 2 Then oProjView = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint(x), viewStyle(x)) oProjView.Name = "ProjView" & x End If Next End Sub Function DeleteView(oSheet As Sheet) For Each view As DrawingView In oSheet.DrawingViews View.Delete() Next End Function Function SetViewScale(oSheet As Sheet, oView As DrawingView) Dim viewScale As Double = Nothing Dim trueViewHeight As Double = Nothing Dim viewName As String = oView.Name Dim viewHeight As Double = Nothing If Not viewName.Contains("ISO") Then viewHeight = (oSheet.Height * .6) Else viewHeight = (oSheet.Height * .45) End If trueViewHeight = oView.Height viewScale = (viewHeight / trueViewHeight) oView.Scale = viewScale End Function
Solved! Go to Solution.