- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good Morning,
i am trying to create an executable that launches Inventor, draws a few lines on a sketch and then save the part it created.
I wrote the following code in VBA using Visual Studio 2019.
The code compile but when launched i have the following Exception: System.InvalidOperationException
The error is the public member 'TransientGeomtry' of 'PartDocument' type can be founded:
(in french below)
The code i wrote is the following:
Public Sub Triangle()
Dim oTG As TransientGeometry
Dim oDoc As PartDocument
oDoc = _invApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, _invApp.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject))
Dim oSketch As PlanarSketch
oSketch = oDoc.ComponentDefinition.Sketches.Add(oDoc.ComponentDefinition.WorkPlanes.Item(3))
oTG = oDoc.TransientGeometry
Dim ocord(0 To 3) As Point2d
ocord(1) = oTG.CreatePoint2d(0, 0)
ocord(2) = oTG.CreatePoint2d(1, 0)
ocord(3) = oTG.CreatePoint2d(1, 1)
Dim oLines(0 To 4) As SketchLine
oLines(1) = oSketch.SketchLines.AddByTwoPoints(ocord(1), ocord(2))
oLines(2) = oSketch.SketchLines.AddByTwoPoints(ocord(2), ocord(3))
oLines(3) = oSketch.SketchLines.AddByTwoPoints(oLines(2).EndSketchPoint, oLines(1).StartSketchPoint)
I made the following Import:
Imports System.Type
Imports System.Activator
Imports System.Runtime.InteropServices
Imports Inventor
Does anyone know where the problem comes from ?
Thank you for your answers.
Solved! Go to Solution.