Hello, I have developed an Inventor rule that performs the following workflow:
It prompts the user to select a master drawing (a drawing that must be created in advance, containing all the required dimensions and annotations, and which will serve as the reference for the other drawings).
It then asks the user to select parts that are similar to the one used in the master drawing.
The rule automatically creates a drawing for each selected part and, using the “Replace Model Reference” functionality, replaces the referenced model and generates an IDW file for each part in the same folder as the master drawing.
This workflow works very well for highly similar parts or for components created using iParts.
Is it possible to implement this functionality directly in Inventor?
I am attaching images and a video showing the rule workflow.
Best regards
' Generacion automatica de planos basado en referencia Daniel C.C- 2024-07-09 ' Ejecute esta regla en cualquier entorno de inventor. ' Esta regla hace lo siguiente. Solicita un plano de referencia, luego basado en este plano hace un copiar y reeemplazar de las referencias que seleccionemos. ' Paso 1: Seleccionar el plano de referencia (IDW) WinForms.MessageBox.Show("Seleccionar plano de referencia", "Paso 1", WinForms.MessageBoxButtons.OK, WinForms.MessageBoxIcon.Information) Dim openFileDialogIDW As New WinForms.OpenFileDialog() openFileDialogIDW.Filter = "Archivos de plano (*.idw)|*.idw" openFileDialogIDW.Title = "Seleccionar plano de referencia (IDW)" Dim refDrawing As String = "" If openFileDialogIDW.ShowDialog() = WinForms.DialogResult.OK Then refDrawing = openFileDialogIDW.FileName ' Obtener la carpeta del plano de referencia para guardar los nuevos planos Dim saveFolder As String = IO.Path.GetDirectoryName(refDrawing) ' Paso 2: Seleccionar las piezas (IPT o IAM) para las cuales se realizarán los planos WinForms.MessageBox.Show("Seleccionar piezas para generar planos", "Paso 2", WinForms.MessageBoxButtons.OK, WinForms.MessageBoxIcon.Information) Dim openFileDialogParts As New WinForms.OpenFileDialog() openFileDialogParts.Filter = "Archivos de pieza (*.ipt;*.iam;.Step)|*.ipt;*.iam;.Step" openFileDialogParts.Title = "Seleccionar piezas para los planos (IPT o IAM)" openFileDialogParts.Multiselect = True Dim selectedParts As New List(Of String) If openFileDialogParts.ShowDialog() = WinForms.DialogResult.OK Then For Each File As String In openFileDialogParts.FileNames selectedParts.Add(File) Next ' Paso 3: Generar una copia del plano seleccionado con el nombre del archivo seleccionado For Each part As String In selectedParts Dim partFileName As String = IO.Path.GetFileName(part) ' Abrir temporalmente la pieza para obtener el Part Number Dim partDoc As Document = ThisApplication.Documents.Open(part, True) Dim partNumber As String = partDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value partDoc.Close(True) ' Usar el Part Number como nombre del nuevo plano Dim newDrawing As String = saveFolder & "\" & partNumber & ".idw" IO.File.Copy(refDrawing, newDrawing, True) ' Abrir el nuevo plano Dim newDrawingDoc As Document = ThisApplication.Documents.Open(newDrawing, True) ' Paso 4: Cambiar la referencia del modelo en cada una de las vistas del dibujo en los planos generados Dim sheets As sheets = newDrawingDoc.Sheets For Each Sheet As Sheet In sheets Dim views As DrawingViews = Sheet.DrawingViews For Each View As DrawingView In views Dim viewObj As DrawingView = TryCast(View, DrawingView) If viewObj IsNot Nothing Then viewObj.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference(part) End If Next Next ' Guardar y cerrar el nuevo plano newDrawingDoc.Save() newDrawingDoc.Close(True) Next WinForms.MessageBox.Show("Se generaron los planos exitosamente.", "DONE", WinForms.MessageBoxButtons.OK, WinForms.MessageBoxIcon.Information) Else WinForms.MessageBox.Show("No se seleccionaron piezas (IPT o IAM).", "Error", WinForms.MessageBoxButtons.OK, WinForms.MessageBoxIcon.Error) End If Else WinForms.MessageBox.Show("No se seleccionó ningún plano de referencia (IDW).", "Error", WinForms.MessageBoxButtons.OK, WinForms.MessageBoxIcon.Error) End If
Can't find what you're looking for? Ask the community or share your knowledge.