Message 1 of 2
Punches tables for part drawing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all , I have the below code which is working fine for assembly , how can I modify it to be applicable to parts level so table will be in part drawing instead of assembly , also is it possible to link it so it will come to sheet metal part table with length width thickness , thanks.
Dim oDrawing As DrawingDocument = ThisDrawing.Document Dim oSheet As Sheet = oDrawing.ActiveSheet Dim oHoles As New List(Of KeyValuePair(Of String, Integer)) Dim oPunches As New List(Of KeyValuePair(Of String, Integer)) Dim oAsm As AssemblyDocument = oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument Dim oCustomProps As PropertySet = oAsm.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") For Each oProp As Inventor.Property In oCustomProps If oProp.Name.StartsWith("Hole: ") Then oHoles.Add(New KeyValuePair(Of String, Integer)(oProp.Name.Replace("Hole: ", ""), oProp.Value)) ElseIf oProp.Name.StartsWith("Punch: ") Then oPunches.Add(New KeyValuePair(Of String, Integer)(oProp.Name.Replace("Punch: ", ""), oProp.Value)) End If Next Dim oHoleTable As CustomTable Dim oPunchTable As CustomTable Dim oTG As TransientGeometry = ThisApplication.TransientGeometry If oHoles.Count > 0 Dim colTitles(1) As String colTitles(0) = "Diameter" colTitles(1) = "Number" oHoleTable = oSheet.CustomTables.Add("Holes", oTG.CreatePoint2d(10, 10), 2, oHoles.Count, colTitles) oHoleTable.Columns.Item(1).ValueHorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter For i = 1 To oHoles.Count oHoleTable.Rows(i).Item("Diameter").Value = oHoles(i - 1).Key oHoleTable.Rows(i).Item("Number").Value = oHoles(i - 1).Value Next End If If oPunches.Count > 0 Dim colTitles(1) As String colTitles(0) = "Name" colTitles(1) = "Number" oPunchTable = oSheet.CustomTables.Add("Punches", oTG.CreatePoint2d(If (oHoleTable Is Nothing, 10, 10 + oHoleTable.RangeBox.MaxPoint.X - oHoleTable.RangeBox.MinPoint.X) _ , 10), 2, oPunches.Count, colTitles) oPunchTable.Columns.Item(1).ValueHorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter For i = 1 To oPunches.Count oPunchTable.Rows(i).Item("Name").Value = oPunches(i - 1).Key oPunchTable.Rows(i).Item("Number").Value = oPunches(i - 1).Value Next End If