How to open all ipt. files in directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am currently working on some drawing automation and need help. I have figured out how to make a new sheet, place multiple views, size them and orientate them. The issue I am having now is scaling this up to do it for every piece part in my part folder. Is there a way to loop through my part folder so it will do this for every piece part and avoid assembly files?? And any suggestion on how to properly loop this would be greatly appreciated. I'm new to iLogic and coding still, thankyou.
Here is what my code looks like so far
Sub Main() PlaceView DrawingViewScale DrawingViewScale2 DrawingViewScale3 Page1 End Sub Sub PlaceView() 'Set a reference to the drawing document. 'This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument 'Set a reference to the sheet format named "Custom D, 5 View" Dim oFormat As SheetFormat Try oFormat = oDrawDoc.SheetFormats.Item("Custom D, 5 View") Catch MessageBox.Show("Error: C size, 4 view might not exist.", "iLogic") Return End Try 'Open the model document invisible Dim oModel As Document oModel = ThisApplication.Documents.Open("X:\My Documents\LOCAL PROJECTS\CONFIGURATORS\SC-SERIES_U20D\Parts\RIGHT.ipt", False) 'Create a new sheet based on the sheet format using the specified model Dim oSheet As Sheet oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat, oModel) End Sub Sub DrawingViewScale() Dim oDwgDoc As Document oDwgDoc = ThisApplication.ActiveDocument 'assuming you are running it from the current document, otherwise reference the correct file here. Dim oSheet As Sheet oSheet = oDwgDoc.Sheets.Item(2) 'assuming we are working on the first sheet Dim oView As DrawingView oView = oSheet.DrawingViews.Item("1") 'assuming the base view is the first view oView.ScaleString = ".85:1" Dim ViewWide As Double ViewWide = 5 'change this to how wide you want your view to be Dim DrawingScale As String DrawingScale = CStr(ViewWide / oView.Width) oView.ScaleString = DrawingScale End Sub Sub DrawingViewScale2() Dim oDwgDoc As Document oDwgDoc = ThisApplication.ActiveDocument 'assuming you are running it from the current document, otherwise reference the correct file here. Dim oSheet As Sheet oSheet = oDwgDoc.Sheets.Item(2) 'assuming we are working on the first sheet Dim oView As DrawingView oView = oSheet.DrawingViews.Item("2") 'assuming the base view is the first view oView.ScaleString = ".75:1" Dim ViewWide As Double ViewWide = 5 'change this to how wide you want your view to be Dim DrawingScale As String DrawingScale = CStr(ViewWide / oView.Width) oView.ScaleString = DrawingScale End Sub Sub DrawingViewScale3() Dim oDwgDoc As Document oDwgDoc = ThisApplication.ActiveDocument 'assuming you are running it from the current document, otherwise reference the correct file here. Dim oSheet As Sheet oSheet = oDwgDoc.Sheets.Item(2) 'assuming we are working on the first sheet Dim oView As DrawingView oView = oSheet.DrawingViews.Item("3") 'assuming the base view is the first view oView.ScaleString = ".75:1" Dim ViewWide As Double ViewWide = 5 'change this to how wide you want your view to be Dim DrawingScale As String DrawingScale = CStr(ViewWide / oView.Width) oView.ScaleString = DrawingScale End Sub