I didn't say it wasn't possible, just that I didn't have a code for that situation yet. Here's a copy of the external iLogic rule's code that I mentioned. It will give you some good ideas of how to do what you want. This code is specifying a PartDocument at the start, but could easily be converted to work for an AssemblyDocument too. Again this code is starting from the model file, to check if a drawing exists for it yet, and if not, it generates the drawing with 4 common views. No dimensions or annotations or other complications.
But the portion of the code that retrieves the size of the model, then uses that info, along with given available drawing space, to determine the scale & orientation of each of the 4 views for the drawing it creates, could most likely be reused in your situation.
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
If System.IO.File.Exists(ThisDoc.PathAndFileName(False) & ".idw") Then
oOverWrite = MsgBox("A Drawing for this model already exists." & vbNewLine &
"Do you want to over-write it?", vbYesNo + vbQuestion, "DRAWING EXISTS!")
If oOverWrite = vbNo Then
Return
End If
End If
Dim oTPath As String = ThisApplication.FileOptions.TemplatesPath
Dim oTName As String = "B-SIZE STANDARD DRAWING TEMPLATE.idw"
Dim oDDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, oTPath & "\" & oTName, True)
'Using Measure (instead of RangeBox)
Dim oXDim As Long = Measure.ExtentsLength
Dim oYDim As Long = Measure.ExtentsWidth
Dim oZDim As Long = Measure.ExtentsHeight
''Using RangeBox for size
'Dim oRangeBox As Box = oPDef.RangeBox
'Dim oXDim As Long = (oRangeBox.MaxPoint.X - oRangeBox.MinPoint.X)
'Dim oYDim As Long = (oRangeBox.MaxPoint.Y - oRangeBox.MinPoint.Y)
'Dim oZDim As Long = (oRangeBox.MaxPoint.Z - oRangeBox.MinPoint.Z)
'MsgBox("RangeBox Size of Model = " & vbNewLine &
'oXDim & " along X Axis" & vbNewLine &
'oYDim & " along Y Axis" & vbNewLine &
'oZDim & " along Z Axis")
Dim oModelWidth As Long = MaxOfMany(oXDim, oYDim, oZDim)
Dim oModelHeight As Long = MinOfMany(oXDim, oYDim, oZDim)
'MsgBox("Longest Dim = " & oModelWidth & vbCrLf &
'"This will be used to calculate scale & view width in drawing.")
Dim oViewRotation As Double
Dim oViewOrientation As ViewOrientationTypeEnum
If oModelWidth = oXDim And oModelHeight = oYDim Then
oViewOrientation = ViewOrientationTypeEnum.kFrontViewOrientation
oViewRotation = 0
ElseIf oModelWidth = oXDim And oModelHeight = oZDim Then
oViewOrientation = ViewOrientationTypeEnum.kTopViewOrientation
oViewRotation = 0
ElseIf oModelWidth = oYDim And oModelHeight = oXDim Then
oViewOrientation = ViewOrientationTypeEnum.kFrontViewOrientation
oViewRotation = (PI/2)
ElseIf oModelWidth = oYDim And oModelHeight = oZDim Then
oViewOrientation = ViewOrientationTypeEnum.kRightViewOrientation
oViewRotation = (PI/2)
ElseIf oModelWidth = oZDim And oModelHeight = oXDim Then
oViewOrientation = ViewOrientationTypeEnum.kTopViewOrientation
oViewRotation = (PI/2)
ElseIf oModelWidth = oZDim And oModelHeight = oYDim Then
oViewOrientation = ViewOrientationTypeEnum.kRightViewOrientation
oViewRotation = 0
End If
'Get the size of the Active Sheet
Dim oSheetWidth As Double = oDDoc.ActiveSheet.Width
Dim oSheetHeight As Double = oDDoc.ActiveSheet.Height
'Get size of area within border available for views (used for scaling views)
Dim oSideBorderOffset As Double = (.5 * 2.54)
Dim oTopBottomBorderOffset As Double = (.5 * 2.54)
Dim oTitleBlockHeight As Double = (2.5 * 2.54)
Dim oBorderWidth As Double = oSheetWidth-(oSideBorderOffset*2)
Dim oBorderHeight As Double = oSheetHeight - (oTopBottomBorderOffset * 2)
Dim oAreaAboveTitleBlock As Double = (oBorderHeight - oTopBottomBorderOffset) - oTitleBlockHeight
'Set view scale, based on model width
Dim oBViewScale As Double
If oModelWidth > (oBorderWidth/2) Then
oBViewScale = ((oBorderWidth/2) / oModelWidth)
ElseIf oModelWidth < (oBorderWidth/2) Then
oBViewScale = (oModelWidth / (oBorderWidth/2))
End If
inc = 1/32
oBViewScale = Round(Round((oBViewScale/2.54),5) / inc) * inc
'Try creating & placing each view at 1:1 scale, then scale to needed factor.
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oViews As DrawingViews = oDDoc.ActiveSheet.DrawingViews
Dim oFullScale As Double = 1
Dim oOriginPoint As Point2d = oTG.CreatePoint2d(0, 0)
Dim oBaseView As DrawingView = oViews.AddBaseView(oPDoc, oOriginPoint, oFullScale, _
oViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
'Locations of view centerpoint columns & rows
Dim o1stColumn As Double = oSideBorderOffset + (oBorderWidth / 4)
Dim o2ndColumn As Double = oSideBorderOffset + ((oBorderWidth / 4) * 3)
Dim o1stRow As Double = oTopBottomBorderOffset + oTitleBlockHeight + (oAreaAboveTitleBlock/4)
Dim o2ndRow As Double = oTopBottomBorderOffset + oTitleBlockHeight + ((oAreaAboveTitleBlock/4)*3)
'Base View center point location
Dim oBaseViewLocation As Point2d = oTG.CreatePoint2d(o1stColumn, o1stRow)
'Dim oBaseView As DrawingView = oViews.AddBaseView(oPDoc, oBaseViewLocation, oBViewScale, _
'oViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
oBaseView.Rotation = oViewRotation
oBaseView.Position = oBaseViewLocation
oBaseView.Scale = oBViewScale
oBaseView.ScaleString = RoundToFraction(oBViewScale,1/32,RoundingMethod.Round)
'oBaseView.Center = oBaseViewLocation
'oBaseView.RotateByAngle =
oBaseView.IncludeMeshBodies = True
oBaseView.IncludeSurfaceBodies = True
'oBaseView.Top
'oBaseView.Height
'oBaseView.Left
'oBaseView.Width
oBaseView.Name = "BASE VIEW"
InventorVb.DocumentUpdate()
'MsgBox("Center Of View Is At: " & oBaseView.Center.X & " , " & oBaseView.Center.Y)
'MsgBox("oBViewScale = " & oBaseView.ScaleString)
Dim oUpperViewInsPoint As Point2d = oTG.CreatePoint2d(o1stColumn, o2ndRow)
Dim oUpperView As DrawingView = oViews.AddProjectedView(oBaseView, oUpperViewInsPoint, _
DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
oUpperView.Name = "UPPER VIEW"
oUpperView.IncludeMeshBodies = True
oUpperView.IncludeSurfaceBodies = True
Dim oRightViewInsPoint As Point2d = oTG.CreatePoint2d(o2ndColumn, o1stRow)
Dim oRightView As DrawingView = oViews.AddProjectedView(oBaseView, oRightViewInsPoint, _
DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
oRightView.Name = "RIGHT VIEW"
oRightView.IncludeMeshBodies = True
oRightView.IncludeSurfaceBodies = True
Dim oISOViewInsPoint As Point2d = oTG.CreatePoint2d(o2ndColumn, o2ndRow)
Dim oISOView As DrawingView = oViews.AddProjectedView(oBaseView, oISOViewInsPoint, _
DrawingViewStyleEnum.kShadedDrawingViewStyle)
oISOView.Name = "ISO VIEW"
oISOView.IncludeMeshBodies = True
oISOView.IncludeSurfaceBodies = True
Wesley Crihfield

(Not an Autodesk Employee)