automate the creation of individual part drawings

automate the creation of individual part drawings

SergeyStenberg
Contributor Contributor
169 Views
2 Replies
Message 1 of 3

automate the creation of individual part drawings

SergeyStenberg
Contributor
Contributor

Hi everyone,

I’m looking to automate the creation of individual part drawings from an assembly in Autodesk Inventor using iLogic.

The goal is to loop through all components in the assembly and generate a .dwg or .idw drawing for each part, using a standard drawing template. Ideally, each drawing should include basic views (e.g., front, top, isometric) and automatically be saved as both DWG and PDF.

Here’s what I’d like to achieve:

 

Loop through all unique parts in an assembly

Create a new drawing for each part using a specified template

Place standard views and possibly auto-dimension (if possible)

Save each drawing as DWG and export to PDF automatically

Has anyone built a working iLogic rule for this?
Any tips, examples, or known pitfalls would be really helpful.

Thanks in advance!

0 Likes
170 Views
2 Replies
Replies (2)
Message 2 of 3

jwoodhouseD8XAE
Contributor
Contributor

This should get you started on the right path. As far as auto-dimensioning, there are a few ways to do this, many of which can get very complicated very fast. Retrieving the model annotations is probably the easiest way, although you won't really have much control over how the individual dimensions are displayed, such as if you want to add some tolerancing to a couple, without looping back through all the dimensions to find the ones you want. This snippet hasn't been tested, but I have used all the functionality other than saving as .pdf and .dwg in other rules I've made, so hopefully it all works smoothly for you.

Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument

Dim fileTemplate As String = "C:\Path\To\Template.idw"

For Each oLeaf As ComponentOccurrence In oDoc.ComponentDefinition.Occurrences.AllLeafOccurrences
	
	
	Dim oDDoc1 As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, fileTemplate, True)
	oDDoc1.Activate()
	
	Dim oSheet As Sheet = oDDoc1.Sheets.Item(1)
	
	Dim xPos As Double = oSheet.Width / 2 
	Dim yPos As Double = oSheet.Height / 2
	
	Dim oPartDoc As PartDocument = oLeaf.Definition.Document
	Dim oPos As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(xPos, yPos) 'adjust as needed
	Dim oScale As Double = 1 'full scale
	Dim oViewOrient As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kFrontViewOrientation
	Dim oViewStyle As DrawingViewStyleEnum = DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle 'change as necessary
	
	Dim oView As DrawingView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPos, oScale, oViewOrient, oViewStyle)
	
	Dim oTopViewPos As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(xPos, yPos + oView.Height*1.5) 'adjust as needed
	
	Dim oTopView As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, oTopViewPos, oViewStyle)
	
	'auto-dimension
	
	oSheet.RetrieveAnnotations(oView)
	oSheet.RetrieveAnnotations(oTopView)
	
	'save as .idw, .dwg, .pdf
	
	Dim fileName As String = oPartDoc.DisplayName
	
	oDDoc1.SaveAs("C:\Path" & fileName & ".idw", False)
	
	Dim oFilePath As String = ThisDoc.Path
	Dim oFileName As String = ThisDoc.FileName
	
	Dim oSavePath As String = oFilePath & "\" & oFileName
	
	oDDoc1.SaveAs(oSavePath & ".pdf", True)
	oDDoc1.SaveAs(oSavePath & ".dwg", True)
	
Next 

 

Message 3 of 3

SergeyStenberg
Contributor
Contributor

thanks will try

0 Likes