ERROR COMING IN INVENTOR I-LOGIC

ERROR COMING IN INVENTOR I-LOGIC

ashish.patilSP94R
Participant Participant
401 Views
4 Replies
Message 1 of 5

ERROR COMING IN INVENTOR I-LOGIC

ashish.patilSP94R
Participant
Participant

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

 

 

0 Likes
Accepted solutions (2)
402 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor
Accepted solution

change this:

 

            oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc, baseViewPosition, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 5

ashish.patilSP94R
Participant
Participant
oTopView = oSheet.DrawingViews.AddProjectedView(oBaseView, topViewPosition, 1, ViewOrientationTypeEnum.kTopViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)

error in above line

ashishpatilSP94R_0-1717757013956.png

@bradeneuropeArthur 

0 Likes
Message 4 of 5

bradeneuropeArthur
Mentor
Mentor
Accepted solution
 ' Define the position for the base view
            Dim baseViewPosition As Point2d
            baseViewPosition = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
			
			 Dim topViewPosition As Point2d
            topViewPosition = ThisApplication.TransientGeometry.CreatePoint2d(20, 10)

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

			Dim oTopView As DrawingView
			oTopView = oSheet.DrawingViews.AddProjectedView(oBaseView, topViewPosition , DrawingViewStyleEnum.kHiddenLineDrawingViewStyle,1)

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes