Create individual .idw for each Part in Assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i have this rule tha creates a idw from a part.
i whant to make a rule that runs on the Assembly to create individual .idw for each Part in Assembly.
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, scale1, kCurrentViewOrientation, kHiddenLineDrawingViewStyle)
'Bottom Right View
oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, 32260)
' Dims only placed if Left Hand View NOT active
'oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView3)
'Top Left View
'oView4 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, 32260)
'oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView4)
oView5 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint5, scale1,kFlatBacksideViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions)
''Top Right Hand ISO View
oView6 = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint4, scale1, kIsoTopLeftViewOrientation, kHiddenLineDrawingViewStyle)
''*** NO Dims on this View ***
'Created by Ben Smeaton 16/05/2023, bensmeaton@gmail.com.
End Sub
Function New_Sheet (SheetName As Integer)
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
oSheet = oDoc.Sheets(1)
oSheet.Activate
Dim oCommandMgr As CommandManager
oCommandMgr = ThisApplication.CommandManager
' Get control definition for the line command.
Dim oControlDef As ControlDefinition
oControlDef = oCommandMgr.ControlDefinitions.Item("DrawingNewSheetCtxCmd")
' Execute the command.
Try
oControlDef.Execute
Dim oSheet2 As Sheet
oSheet2 = ThisDoc.Document.ActiveSheet
oSheet2.Name ="Sheet:" & SheetName
Catch
End Try
End Function
Function get_size(oRefDoc As PartDocument, X_Pos_Max As Decimal, X_Pos_Min As Decimal, Y_Pos_Max As Decimal, Y_Pos_Min As Decimal)
Try
' Get the TransientBRep and TransientGeometry objects.
Dim transBRep As TransientBRep = ThisApplication.TransientBRep
Dim transGeom As TransientGeometry = ThisApplication.TransientGeometry
' Combine all bodies in Part into a single transient Surface Body.
Dim combinedBodies As SurfaceBody = Nothing
For Each surfBody As SurfaceBody In oRefDoc.ComponentDefinition.SurfaceBodies
If combinedBodies Is Nothing Then
combinedBodies = transBRep.Copy(surfBody)
Else
transBRep.DoBoolean(combinedBodies, surfBody, BooleanTypeEnum.kBooleanTypeUnion)
End If
Next
' Get the oriented mininum range box of all bodies in Part.
' NOTE: "OrientedMinimumRangeBox" was added in Inventor 2020.3/2021.
Dim minBox As OrientedBox = combinedBodies.OrientedMinimumRangeBox
' Get length of each side of mininum range box.
Dim dir1 As Double = minBox.DirectionOne.Length
Dim dir2 As Double = minBox.DirectionTwo.Length
Dim dir3 As Double = minBox.DirectionThree.Length
' Sort lengths from smallest to largest.
Dim lengths As New List(Of Double) From {dir1, dir2, dir3 }
lengths.Sort
Dim minLength As Double = lengths(0)
Dim midLength As Double = lengths(1)
Dim maxLength As Double = lengths(2)
scale1 = (((Min(X_Pos_Max - X_Pos_Min, Y_Pos_Max - Y_Pos_Min)) / 2) * 0.33) / maxLength
Return scale1
Catch
scale1 = 1 / 50
Return scale1
End Try
End Function
Function get_sizeassy(oRefDoc As AssemblyDocument, X_Pos_Max As Decimal, X_Pos_Min As Decimal, Y_Pos_Max As Decimal, Y_Pos_Min As Decimal)
Dim oADoc As AssemblyDocument = oRefDoc
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oBox As Box = oADef.RangeBox
Dim oMinP As Point = oBox.MinPoint
Dim oMaxP As Point = oBox.MaxPoint
Dim dX As Double = oMaxP.X - oMinP.X
Dim dY As Double = oMaxP.Y - oMinP.Y
Dim dZ As Double = oMaxP.Z - oMinP.Z
Dim lengths As New List(Of Double) From {dX, dY, dZ}
lengths.Sort
Dim minLength As Double = lengths(0)
Dim midLength As Double = lengths(1)
Dim maxLength As Double = lengths(2)
scale1 = (((Min(X_Pos_Max - X_Pos_Min, Y_Pos_Max - Y_Pos_Min)) / 2) * 0.33) / maxLength
Return scale1
End Function
Function view_label(oView As DrawingView)
oView.ShowLabel = True
oDescription = "<StyleOverride FontSize='0.35'><StyleOverride Underline='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride></StyleOverride>"
oPartNumber = "<Br/><StyleOverride FontSize='0.35'><StyleOverride Underline='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride></StyleOverride>"
oStringScale = "<Br/><StyleOverride FontSize='0.35'>(Scale <DrawingViewScale/>)</StyleOverride>"
' oView.Label.FormattedText = oDescription & oPartNumber & oStringScale
End Function