
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm in the process of writing VBA/iLogic for creating a custom inspection dimension table to be placed on a drawing. I've been able to get the inspection dimensions data and fill in the table, but want to limit the table rows to the number of inspection dimensions. Right now the code counts the number of general dimenions and the custom table uses the number of general dimensions to create the number of table rows. (The Count property only appears to be included for DrawingDimensions, General Dimensions, and other dimension collections, but not inspection dimensions, because there is no collection for them.) So this count results in empty table rows if the general dimension is not an inspection dimension. I've also tried to delete rows that are empty without success. And I've also looked into creating an InspectionDimensions class or collection to include a Count property, but I have limited knowledge of how this is done. So, what is the best way to limit the table rows to only the number of inspection dimensions in the drawing and that I'm listing in the table? Thank you!
Public Sub CreateInspectionDimsTable() ' Set a reference to the drawing document. oDocType = ThisApplication.ActiveDocumentType If oDocType <> kDrawingDocumentObject Then MsgBox "This is not a drawing document." + vbCrLf + "Please open a drawing document.", vbOKOnly, "Drawing Document Error" Exit Sub End If Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument ' Set a reference to the active sheet. Dim oSheet As Sheet Set oSheet = oDrawDoc.ActiveSheet If oSheet.CustomTables.Count > 0 Then oSheet.CustomTables.Item(1).Delete End If 'Set the column titles & Create the custom table Dim oInspTblTitle As String oInspTblTitle = "INSPECTION DIMENSIONS" Dim oTitles(1 To 3) As String oTitles(1) = "DIMENSION NUMBER" oTitles(2) = "DESIGN" oTitles(3) = "ACTUAL" oDrawDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.TableStyle.HeadingGap = 0.125 oDrawDoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.TableStyle.ColumnValueHorizontalJustification = kAlignTextCenter oGenDimCount = oSheet.DrawingDimensions.GeneralDimensions.Count Debug.Print "General Dims Count = " + CStr(oGenDimCount) Debug.Print "Drawing Dims Count = " + CStr(oSheet.DrawingDimensions.Count) Debug.Print "Inspection Dims Count = " + "?" Dim oInspDimTable As CustomTable Set oInspDimTable = oSheet.CustomTables.Add(oInspTblTitle, ThisApplication.TransientGeometry.CreatePoint2d(1.5, 27), 3, oGenDimCount, oTitles) 'Get Inspection Dimension Data Dim oInspDim As DrawingDimension Dim oInspDimShape As InspectionDimensionShapeEnum Dim oInspDimText As DimensionText Dim oInspDimText2 As Variant Dim oInspDimNumber As String Dim oInspDimRate As String Dim i As Integer Dim oCellInspDimNum As Cell Dim oCellInspDim As Cell i = 1 For Each oSheet In oDrawDoc.Sheets For Each oInspDim In oSheet.DrawingDimensions If oInspDim.IsInspectionDimension Then oInspDim.GetInspectionDimensionData oInspDimShape, oInspDimNumber, oInspDimRate Set oInspDimText = oInspDim.Text oInspDimText2 = ThisApplication.UnitsOfMeasure.GetPreciseStringFromValue(oInspDim.ModelValue, kInchLengthUnits) Debug.Print oInspDimNumber Debug.Print oInspDimText.Text Debug.Print oInspDimText2 Debug.Print "" Set oCellInspDimNum = oInspDimTable.Rows.Item(i).Item("DIMENSION NUMBER") oCellInspDimNum.Value = oInspDimNumber Set oCellInspDim = oInspDimTable.Rows.Item(i).Item("DESIGN") oCellInspDim.Value = oInspDimText2 i = i + 1 End If Next Next oInspDimTable.Sort "DIMENSION NUMBER", True Dim oRow As Row For Each oRow In oInspDimTable.Rows If oCellInspDimNum.Value <> oInspDimNumber Then oRow.Delete End If Next End Sub
Solved! Go to Solution.