Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
ashish.patilSP94R
316 Views, 4 Replies

ERROR COMING IN INVENTOR I-LOGIC

ashishpatilSP94R_1-1717747352984.png

 

MY CODE IS BELOW

 

Try
    ' Ensure the active document is a PartDocument
    If TypeOf ThisDoc.Document Is PartDocument Then
        Dim oPartDoc As PartDocument
        oPartDoc = TryCast(ThisDoc.Document, PartDocument)
        If oPartDoc IsNot Nothing Then
            ' Specify the path to your custom drawing template
            Dim templatePath As String
            templatePath = "O:\PROJECT\INVENTOR LIBRARY\07-TEMPLATES\ATS_A3.idw"

            ' Create a new drawing document using the custom template
            Dim oDrawingDoc As DrawingDocument
            oDrawingDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templatePath)

            ' Verify if the drawing document is created successfully
            If oDrawingDoc Is Nothing Then
                MessageBox.Show("Failed to create the drawing document.")
                Exit Try
            End If

            ' Reference to the first sheet in the drawing
            Dim oSheet As Sheet
            oSheet = oDrawingDoc.Sheets.Item(1)

            ' Define the position for the base view
            Dim baseViewPosition As Point2d
            baseViewPosition = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)

            ' Create base view with correct parameters
            Dim oBaseView As DrawingView
            oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc.ComponentDefinition, _
                baseViewPosition, 1, _
                ViewOrientationTypeEnum.kFrontViewOrientation, _
                DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)

            ' Verify if the base view is created successfully
            If oBaseView Is Nothing Then
                MessageBox.Show("Failed to create the base view.")
                Exit Try
            End If

            ' Define the position for the projected views
            ' (Code for adding projected views...)

            ' Save the drawing to a specified path
            Dim savePath As String
            savePath = "O:\R&D\PRODUCT\CHANGES\030. A-KART WITH ROLLER CONVEYOR\3D DESIGN\OPTION 2\expansion joint related things\part1.idw"
            oDrawingDoc.SaveAs(savePath, False)

            MessageBox.Show("Drawing saved successfully at " & savePath)
        Else
            MessageBox.Show("Failed to cast active document as PartDocument.")
        End If
    Else
        MessageBox.Show("No active PartDocument found.")
    End If

Catch ex As Exception
    ' Display the error message
    MessageBox.Show("An error occurred: " & ex.Message)
End Try