@andrew_canfield
I did a little work on a very similar idea using a regular iLogic external rule, a while back, but never finished it.
It was just going to create a seperate part file with the box created in it, and save it with the same name, and location as the main assembly file.
It's probably a good start for someone to pick up where I left off though.
I seem to remember not finding an easy way to use an in-memory IPictureDisp (without saving the image to disk) to use it for the images on the Faces of the resulting box. I also played around with just going ahead and saving the BMP images to the C:\Temp folder, then using them later to paste on the faces, then to delete them, when done.
But as I stated before, it's not a working code at this point.
Here it is.
Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
AddReference "stdole.dll"
AddReference "System.Drawing"
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oBox As Box = oADef.RangeBox
Dim oMinPoint As Point = oBox.MinPoint
Dim oMaxPoint As Point = oBox.MaxPoint
Dim oXDist As Double = oMaxPoint.X - oMinPoint.X
Dim oYDist As Double = oMaxPoint.Y - oMinPoint.Y
Dim oZDist As Double = oMaxPoint.Z - oMinPoint.Z
MessageBox.Show("The RangeBox of this AssemblyDocument is:" & vbNewLine &
oXDist & " along X-Axis" & vbNewLine &
oYDist & " along Y-Axis" & vbNewLine &
oZDist & " along Z-Axis")
'Front View
Dim oFrontView As Inventor.View = oADoc.Views.Add()
oFrontView.Caption = "FRONT VIEW"
oFrontView.DisplayMode = DisplayModeEnum.kRealisticRendering
oFrontView.Fit(True)
oFrontView.Visible = True
Dim oFVCamera As Camera = oFrontView.Camera
oFVCamera.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
oFVCamera.Fit
oFVCamera.Apply
Dim oFViewPic As IPictureDisp = oFVCamera.CreateImage(Int(oXDist)*10, Int(oYDist)*10) 'oWidth & oHeight are pixel counts
'Right View
Dim oRightView As Inventor.View = oADoc.Views.Add()
oRightView.Caption = "RIGHT VIEW"
oRightView.DisplayMode = DisplayModeEnum.kRealisticRendering
oRightView.Fit(True)
oRightView.Visible = True
Dim oRVCamera As Camera = oRightView.Camera
oRVCamera.ViewOrientationType = ViewOrientationTypeEnum.kRightViewOrientation
oRVCamera.Fit
oRVCamera.Apply
Dim oRViewPic As IPictureDisp = oRVCamera.CreateImage(Int(oYDist)*10, Int(oZDist)*10) 'oWidth & oHeight are pixel counts
'Left View
Dim oLeftView As Inventor.View = oADoc.Views.Add()
oLeftView.Caption = "LEFT VIEW"
oLeftView.DisplayMode = DisplayModeEnum.kRealisticRendering
oLeftView.Fit(True)
oLeftView.Visible = True
Dim oLVCamera As Camera = oLeftView.Camera
oLVCamera.ViewOrientationType = ViewOrientationTypeEnum.kLeftViewOrientation
oLVCamera.Fit
oLVCamera.Apply
Dim oLViewPic As IPictureDisp = oLVCamera.CreateImage(Int(oYDist)*10, Int(oZDist)*10) 'oWidth & oHeight are pixel counts
'Back View
Dim oBackView As Inventor.View = oADoc.Views.Add()
oBackView.Caption = "BACK VIEW"
oBackView.DisplayMode = DisplayModeEnum.kRealisticRendering
oBackView.Fit(True)
oBackView.Visible = True
Dim oBKVCamera As Camera = oBackView.Camera
oBKVCamera.ViewOrientationType = ViewOrientationTypeEnum.kBackViewOrientation
oBKVCamera.Fit
oBKVCamera.Apply
Dim oBKViewPic As IPictureDisp = oBKVCamera.CreateImage(Int(oXDist)*10, Int(oYDist)*10) 'oWidth & oHeight are pixel counts
'Top View
Dim oTopView As Inventor.View = oADoc.Views.Add()
oTopView.Caption = "TOP VIEW"
oTopView.DisplayMode = DisplayModeEnum.kRealisticRendering
oTopView.Fit(True)
oTopView.Visible = True
Dim oTVCamera As Camera = oTopView.Camera
oTVCamera.ViewOrientationType = ViewOrientationTypeEnum.kTopViewOrientation
oTVCamera.Fit
oTVCamera.Apply
'Dim oTopViewPic As IPictureDisp = oTVCamera.CreateImage(Int(oXDist) * 10, Int(oZDist) * 10) 'oWidth & oHeight are pixel counts
Dim oBMP_Path As String = "C:\Temp\"
Dim oBMP_Name As String = "TOP VIEW IMAGE.bmp"
oTVCamera.SaveAsBitmap(oBMP_Path & oBMP_Name,Int(oXDist) * 10,Int(oZDist) * 10)
'Bottom View
Dim oBottomView As Inventor.View = oADoc.Views.Add()
oBottomView.Caption = "BOTTOM VIEW"
oBottomView.DisplayMode = DisplayModeEnum.kRealisticRendering
oBottomView.Fit(True)
oBottomView.Visible = True
Dim oBTVCamera As Camera = oBottomView.Camera
oBTVCamera.ViewOrientationType = ViewOrientationTypeEnum.kBottomViewOrientation
oBTVCamera.Fit
oBTVCamera.Apply
Dim oBTViewPic As IPictureDisp = oBTVCamera.CreateImage(Int(oXDist)*10, Int(oZDist)*10) 'oWidth & oHeight are pixel counts
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
'Create a Part File to create the physical box in.
Dim oBoxDoc As PartDocument
Dim oPTPath As String = ThisApplication.FileOptions.TemplatesPath
oBoxDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject,oPTPath & "PART.ipt",True)
Dim oBoxDef As PartComponentDefinition = oBoxDoc.ComponentDefinition
Dim oSketches As PlanarSketches = oBoxDef.Sketches
Dim oBaseSketch As PlanarSketch = oSketches.Add(oBoxDef.WorkPlanes.Item("XZ Plane"))
oBaseSketch.Name = "Simplified Part Base Sketch"
oBaseSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(oMinPoint.X, oMinPoint.Z), oTG.CreatePoint2d(oMaxPoint.X, oMaxPoint.Z))
oBaseSketch.Profiles.AddForSolid
Dim oExtFeats As ExtrudeFeatures = oBoxDef.Features.ExtrudeFeatures
Dim oExtFeatDef As ExtrudeDefinition = oExtFeats.CreateExtrudeDefinition(oBaseSketch.Profiles.Item(1), PartFeatureOperationEnum.kNewBodyOperation)
oExtFeatDef.SetDistanceExtent(oYDist, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
Dim oExtFeat As ExtrudeFeature = oExtFeats.Add(oExtFeatDef)
oExtFeat.Name = oADoc.DisplayName & " - Simplified"
'Start identifying the faces & setting the images
Dim oDecals As DecalFeatures = oBoxDef.Features.DecalFeatures
Dim oDecal As DecalFeature
Dim oFaceProfile As PlanarSketch
Dim oNE = iLogicVb.Automation.GetNamedEntities(oBoxDoc)
Dim oTopFace As Face = oExtFeat.EndFaces.Item(1)
oNE.SetName(oTopFace,"TOP FACE")
oFaceProfile = oSketches.Add(oTopFace, True)
oFaceProfile.Name = "TOP FACE PROFILE SKETCH"
For Each oEntity As SketchEntity In oFaceProfile.SketchEntities
oEntity.Construction = False
Next
'The following line tries to use the IPictureDisp defined above in place of the FullFileName of an Image File.
'Dim oTopPic As SketchImage = oFaceProfile.SketchImages.Add(oTopViewPic, oTG.CreatePoint2d(oMinPoint.X, oMinPoint.Z), False)
Dim oTopPic As SketchImage = oFaceProfile.SketchImages.Add(oBMP_Path & oBMP_Name, oTG.CreatePoint2d(oMinPoint.X, oMinPoint.Z), False)
oTopPic.Width = oXDist
oTopPic.Height = oZDist
oDecal = oDecals.Add(oTopPic, oTopFace, False, False)
oDecal.Name = "TOP FACE DECAL"
Dim oBottomFace As Face = oExtFeat.StartFaces.Item(1)
For Each oFace As Face In oExtFeat.SideFaces
'If oFace.
'oFaceProfile = oSketches.Add(oFace, True)
'oFaceProfile.Name = ""
' oFace.AppearanceSourceType = AppearanceSourceTypeEnum.kOverrideAppearance
' oFace.Appearance =
Next
I hope this helps you on your way. Post back if you get it working. Good luck.
Wesley Crihfield

(Not an Autodesk Employee)