Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iPart indivdual drawings

Anonymous

iPart indivdual drawings

Anonymous
Not applicable

I have an iPart factory with 612 different plates. I am using the iPart to control the length, width, and height of each in the table. What would the workflow be to quickly create an individual drawing per part? I want a material block on the drawing and LxWxH dims. I was recommended to come to the customization forum for an answer to this. What sort of rules or iLogic would I need to create this?

 

Thank,

Zach L

0 Likes
Reply
411 Views
4 Replies
Replies (4)

AlexFielder
Advisor
Advisor

You would need to step through the ipart table like this rule which checks whether Inventor can compute each row in the iPart/iAssembly table - FWIW I'm not sure I ever properly test the iAssembly section of this rule! Buyer-beware:

 

Sub Main()
CheckiPartTableForErrors()
End Sub
Sub CheckiPartTableForErrors()
    Dim oErrorManager As ErrorManager = ThisApplication.ErrorManager

    If TypeOf (ThisApplication.activedocument) Is partdocument Then
        Dim oDoc As PartDocument = ThisApplication.ActiveDocument
        Dim oiPart As iPartFactory = oDoc.ComponentDefinition.iPartFactory
        Dim oTop As BrowserNode = oDoc.BrowserPanes("Model").TopNode
        Dim bHasErrorOrWarning As Boolean
        Dim i As Integer
        InventorVb.DocumentUpdate()
        ThisApplication.SilentOperation = True
        For i = 1 To oiPart.TableRows.Count 'use first 10 rows only for debugging purposes!
            ' Highlight the 3rd iPart table row which has invalid data
            oTop.BrowserNodes("Table").BrowserNodes.Item(i).DoSelect

            ' Activate the iPart table row
            Dim oCommand As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd")
            oCommand.Execute

            ThisApplication.SilentOperation = False
            ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute
            If oErrorManager.HasErrors Or oErrorManager.HasWarnings Then
                MessageBox.Show(oErrorManager.LastMessage, "Title")
            End If
        Next i
        MessageBox.Show("No errors shown = None found!", "Title")
    ElseIf TypeOf (ThisApplication.activedocument) Is assemblydocument Then
        Dim odoc As assemblydocument = ThisApplication.activedocument
        Dim iAssy As iAssemblyFactory = odoc.componentdefinition.iassemblyfactory
        Dim oTop As BrowserNode = odoc.BrowserPanes("Model").TopNode
        Dim bHasErrorOrWarning As Boolean
        Dim i As Integer
        InventorVb.DocumentUpdate()
        ThisApplication.SilentOperation = True
        For rowIndex = 1 To iAssy.tablerows.count
            oTop.BrowserNodes("Table").BrowserNodes.Item(i).DoSelect
            Dim oCommand As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions("PartComputeiPartRowCtxCmd")
            oCommand.Execute
            ThisApplication.SilentOperation = False
            ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute
            If oErrorManager.HasErrors Or oErrorManager.HasWarnings Then
                MessageBox.Show(oErrorManager.LastMessage, "Title")
            End If

        Next
    End If
End Sub

And working with the above you could (in theory) populate a new drawing template with a view that contains the currently active table row configuration.

0 Likes

Anonymous
Not applicable

How would you go about changing the model references in iLogic? I am pretty new to using iLogic. I also have future projects that will be able to use the same iLogic it will just be a different iPart.

Thanks

0 Likes

Anonymous
Not applicable

I cant find a way to make the information in your code work with what i am trying to do. I am trying to change the model reference on a drawing. What i am trying to accomplish is step thru each member of the iPart on a drawing and save as part# then export it to a PDF. i already have the code for PDF.

0 Likes

AlexFielder
Advisor
Advisor

The best thing you can do is share what you have code-wise.

 

As far as switching view-referenced models, the best answer I can find here is this:

 

https://forums.autodesk.com/t5/inventor-customization/how-to-replace-model-reference-in-idw-file/m-p... by @MechMachineMan :slightly_smiling_face:

 

EDIT: This rule of mine (should) also do this:

AddReference "System.Core"
AddReference "System.Linq"
Imports System.LINQ
Imports System.Collections.Generic
'doesn't run in iLogic - WHAT A SURPRISE!?!?!?
Private Sub Main()
            Dim sw As New Stopwatch()
            sw.Start()
            Dim rootFolder As String = IO.Path.GetDirectoryName(ThisApplication.ActiveDocument.FullFileName)
            Dim selectedfile As String = String.Empty
            Dim filedlg As Inventor.FileDialog = Nothing
            ThisApplication.CreateFileDialog(filedlg)
            filedlg.Filter = "txt files (*.txt)|*.txt|Other files (*.*)|*.*"
            filedlg.InitialDirectory = rootFolder
            filedlg.CancelError = True
            filedlg.MultiSelectEnabled = False
            Try
                filedlg.ShowOpen()
                selectedfile = filedlg.FileName
            Catch ex As Exception
                Return
            End Try

            Dim filelisttoreplace As New List(Of String)
            Dim filelisttosaveas As New List(Of String)
            Dim filereader As IO.StreamReader = Nothing
            filereader = My.Computer.FileSystem.OpenTextFileReader(selectedfile)
            Do While filereader.Peek >= 0
                filelisttoreplace.Add(filereader.ReadLine)
            Loop

            For Each filename As String In filelisttoreplace
                filelisttosaveas.Add(IO.Path.GetDirectoryName(filename) & "\" &
                                     IO.Path.GetFileNameWithoutExtension(filename) & ".dwg")

            Next

            If TypeOf ThisApplication.ActiveDocument Is DrawingDocument Then
                For Each dwgfile As String In filelisttosaveas
                    Dim dwgdoc As DrawingDocument = ThisApplication.ActiveDocument
                    dwgdoc.SaveAsInventorDWG(dwgfile, False)
'                    Dim filedescr As FileDescriptor = dwgdoc.ReferencedFileDescriptors(1)
'                    Dim filetoreplace As String = (
'                        From f As String In filelisttoreplace
'                        Where IO.Path.GetFileNameWithoutExtension(f) = IO.Path.GetFileNameWithoutExtension(dwgdoc.FullFileName)).FirstOrDefault()
'                    If Not filetoreplace Is Nothing Then
'                        filedescr.ReplaceReference(filetoreplace)
'                        dwgdoc.Save()
'                    End If
                Next
            End If
            sw.Stop()
            MessageBox.Show("Operation took: " & sw.Elapsed.Seconds.ToString() & " seconds to complete.")
        End Sub

:slightly_smiling_face:

 

 

0 Likes