Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Drawing Checking Code

1 REPLY 1
Reply
Message 1 of 2
OkieWolf
350 Views, 1 Reply

iLogic Drawing Checking Code

I have an iLogic rule (I got from "From the Trenches with Autodesk Inventor" then modified slightly) that cycles through all dimensions on a drawing and if it finds a dimension that has been overridden it will turn that dimension green. I also want to do the same thing with a parts list on a drawing and with tags on a drawing. But I'm having difficulty figuring out how to find the parts list and then how to cycle through it to find overridden items. Same thing with tags.

 

below is the rule for cycling through dims and turning overridden ones green....

 

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
 
Dim oDrawingDims As DrawingDimension
 
Dim oColor As Color
 
For Each oDrawingDims In oDoc.ActiveSheet.DrawingDimensions
   oColor = ThisApplication.TransientObjects.CreateColor(0, 255, 0)
 
   If oDrawingDims.HideValue = True _
   Or oDrawingDims.ModelValueOverridden = True Then
   oDrawingDims.Text.Color = oColor
   Else
   oColor = ThisApplication.TransientObjects.CreateColor(0, 0, 0)
   oColor.ColorSourceType = ColorSourceTypeEnum.kLayerColorSource
   oDrawingDims.Text.Color = oColor
   End If
 
Next

1 REPLY 1
Message 2 of 2
Vladimir.Ananyev
in reply to: OkieWolf

Here is the sample from the Inventor API Help that illustrates access to PartsList content.

Public Sub PartListEdit()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
   
    ' Set a reference to the first parts list on the active sheet.
    ' This assumes that a parts list is on the active sheet.
    Dim oPartList As PartsList
    Set oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
   
    ' Iterate through the contents of the parts list.
    Dim i As Long
    For i = 1 To oPartList.PartsListRows.Count
        ' Get the current row.
        Dim oRow As PartsListRow
        Set oRow = oPartList.PartsListRows.Item(i)
       
        ' Iterate through each column in the row.
        Dim j As Long
        For j = 1 To oPartList.PartsListColumns.Count
            ' Get the current cell.
            Dim oCell As PartsListCell
            Set oCell = oRow.Item(j)
           
            ' Check that the column isn't the quantity column.
            If oPartList.PartsListColumns.Item(j).Title  "QTY" Then
                ' Change the current value in the part list.
                oCell.Value = i & "," & j
            End If
        Next
    Next
   
    ' This changes a specific column by name.
    Dim ItemNumber As Long
    ItemNumber = oPartList.PartsListRows.Count
    For i = 1 To oPartList.PartsListRows.Count
        Set oCell = oPartList.PartsListRows.Item(i).Item("ITEM")
        oCell.Value = ItemNumber
        ItemNumber = ItemNumber - 1
    Next
End Sub

When the value of a cell is overridden, the cell is marked as static. 
PartsListCell.Static property specifies if the content of this cell is static or not. 

Hope this helps.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report