Imports System.Runtime.InteropServices
Public Class Form1
Dim oApp As Inventor.Application
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
oApp = GetObject(, "Inventor.Application")
oApp = Marshal.GetActiveObject("Inventor.Application")
MessageBox.Show("Inventor is found", "WinFormTestApp", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Inventor is not found", "WinFormTestApp", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Create_Botton(sender As Object, e As EventArgs) Handles Botton.Click
Call createExtrudedPart_1()
End Sub
Sub createExtrudedPart_1()
''СОЗДАНИЕ НОВОГО ДОКУМЕНТА ДЕТАЛИ, ВИДИМЫЙ РЕЖИМ
Dim oDoc As Inventor.PartDocument = oApp.Documents.Add(Inventor.DocumentTypeEnum.kPartDocumentObject,
oApp.FileManager.GetTemplateFile(Inventor.DocumentTypeEnum.kPartDocumentObject), True)
''ОПРЕДЕЛЕНИЕ ДОКУМЕНТА ДЕТАЛИ
Dim oDocDef As Inventor.PartComponentDefinition = oDoc.ComponentDefinition
''СОЗДАНИЕ НОВОГО ЭСКИЗА В ПЛОСКОСТИ XY
Dim oSketch As Inventor.PlanarSketch = oDocDef.Sketches.Add(oDocDef.WorkPlanes(3))
''ССЫЛКА НА ВСПОМОГАТЕЛЬНУЮ ГЕОМЕТРИЮ
Dim oTG As Inventor.TransientGeometry = oApp.TransientGeometry
''ПРЯМОУГОЛЬНИК
Dim oRectangel As Inventor.SketchEntitiesEnumerator = oSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(0, 0),
oTG.CreatePoint2d(6, 4))
''СОЗДАДИМ ПРОФИЛЬ ДЛЯ ВЫДАВЛИВАНИЯ ПРЯМОУГОЛЬНИКА
Dim oProfile As Inventor.Profile = oSketch.Profiles.AddForSolid
''ВЫДАВЛИВАНИЕ ПРЯМОУГОЛЬНИКА
Dim oExtrusion As Inventor.ExtrudeFeature = oDocDef.Features.ExtrudeFeatures.AddByDistanceExtent(
oProfile, 4, Inventor.PartFeatureExtentDirectionEnum.kPositiveExtentDirection,
Inventor.PartFeatureOperationEnum.kJoinOperation)
'' СОЗДАНИЕ НОВОЙ РАБОЧЕЙ ПЛОСКОСТИ
Dim oWorkPlaneCircle As Inventor.WorkPlane = oDocDef.WorkPlanes.AddByPlaneAndOffset(oDocDef.WorkPlanes(3), 2)
''СОЗДАНИЕ ЭСКИЗА НА НОВОЙ ПЛОСКОСТИ
Dim oSketchCircle As Inventor.PlanarSketch = oDocDef.Sketches.Add(oWorkPlaneCircle)
'' ОКРУЖНОСТЬ
Dim oCircle As Inventor.SketchCircle = oSketchCircle.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(3, 2), 0.5)
'' ВЫЧИТАНИЕ ОКРУЖНОСТИ
oProfile = oSketchCircle.Profiles.AddForSolid
oExtrusion = oDocDef.Features.ExtrudeFeatures.AddByDistanceExtent(
oSketchCircle, 2, Inventor.PartFeatureExtentDirectionEnum.kSymmetricExtentDirection,
Inventor.PartFeatureOperationEnum.kCutOperation)
End Sub
End Class