- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It looks like:
Imports System
Imports System.Runtime.InteropServices
Imports Inventor
Public Class Form1
Dim invApp As Inventor.Application
Dim partDoc As Inventor.PartDocument
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
invApp = Marshal.GetActiveObject("Inventor.Application")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
partDoc = invApp.ActiveDocument
Dim body As SurfaceBody
body = invApp.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select the body.")
Dim bndBox As Box = calculateTightBoundingBox(body)
Dim sk As Sketch3D = partDoc.ComponentDefinition.Sketches3D.Add()
Dim lines As SketchLines3D = sk.SketchLines3D
Dim tg As TransientGeometry = invApp.TransientGeometry
Dim minXYZ As Point = bndBox.MinPoint
Dim minXYmaxZ As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MinPoint.Y, bndBox.MaxPoint.Z)
Dim minXmaxYZ As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MaxPoint.Y, bndBox.MaxPoint.Z)
Dim minXZmaxY As Point = tg.CreatePoint(bndBox.MinPoint.X, bndBox.MaxPoint.Y, bndBox.MinPoint.Z)
Dim maxXYZ As Point = bndBox.MaxPoint
Dim maxXYminZ As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MaxPoint.Y, bndBox.MinPoint.Z)
Dim maxXZminY As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MinPoint.Y, bndBox.MaxPoint.Z)
Dim maxXminYZ As Point = tg.CreatePoint(bndBox.MaxPoint.X, bndBox.MinPoint.Y, bndBox.MinPoint.Z)
lines.AddByTwoPoints(minXYZ, minXYmaxZ)
lines.AddByTwoPoints(minXYZ, minXZmaxY)
lines.AddByTwoPoints(minXZmaxY, minXmaxYZ)
lines.AddByTwoPoints(minXYmaxZ, minXmaxYZ)
lines.AddByTwoPoints(maxXYZ, maxXYminZ)
lines.AddByTwoPoints(maxXYZ, maxXZminY)
lines.AddByTwoPoints(maxXYminZ, maxXminYZ)
lines.AddByTwoPoints(maxXZminY, maxXminYZ)
lines.AddByTwoPoints(minXYZ, maxXminYZ)
lines.AddByTwoPoints(minXYmaxZ, maxXZminY)
lines.AddByTwoPoints(minXmaxYZ, maxXYZ)
lines.AddByTwoPoints(minXZmaxY, maxXYminZ)
End Sub
End Class
Autodesk User