Need help with code for looping through the IDW and plotting a PDF per sheet.

Need help with code for looping through the IDW and plotting a PDF per sheet.

Anonymous
Not applicable
440 Views
1 Reply
Message 1 of 2

Need help with code for looping through the IDW and plotting a PDF per sheet.

Anonymous
Not applicable

Hi all,

I create IDW's with multiple sheets and I need to create seperate PDF's of each sheet.  I'm confused on the code to loop thru each sheet and create the PDF.

 

From there I should be able to create code to export each sheet as a DWG.

 

At an older company I know we had something like that.  Click to button and the program would cycle through all sheets and plot to PDF.  And save it to the currect IDW location.

0 Likes
441 Views
1 Reply
Reply (1)
Message 2 of 2

MechMachineMan
Advisor
Advisor
Imports System.Diagnostics
Imports System.Threading

Sub Main

Dim oTextSave As String = "C:\Users\Filename"                            'Create a text doc and make this location match for post-processing info

Dim stopWatch As New Stopwatch()
	stopWatch.Start()

oWrite = System.IO.File.CreateText(oTextSave)
oWrite.WriteLine("References")	

Dim oDwgDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oDrawingView As DrawingView
Dim oModelDoc As Document

Dim oMultiList As New List(Of String)
	oMultiList=FBrowseMulti
	For j=0 To oMultiList.Count-1
		'MsgBox(oMultiList.Item(j))
		oDoc=ThisApplication.Documents.Open(oMultiList.Item(j), False)


For Each oSheet In oDwgDoc.Sheets
	oSheet.Activate	
	oDrawingView = oSheet.DrawingViews.Item(1)
	oModelDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
	oWO = oModelDoc.PropertySets.Item("Inventor User Defined Properties").Item("WO#").Value

	
Next

Next ' Multi	
	
	stopWatch.Stop()
Dim ts As TimeSpan = stopWatch.Elapsed
Dim elapsedTime As String = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)
MsgBox("RunTime " & elapsedTime)

oWrite.Close
ThisDoc.Launch(oTextSave)
End Sub 'Main


Private Function FBrowseMulti
	Dim oMultiList As New List(Of String)
    Dim oFileDlg As FileDialog

    Call ThisApplication.CreateFileDialog(oFileDlg)

    With oFileDlg
        .FilterIndex = 1
        .MultiSelectEnabled = True
        .CancelError = True
           On Error Resume Next

            .Filter = "Inventor Files (*.idw;)|*.idw|All Files (*.*)|*.*"
            .DialogTitle = "Select .idw Files To Include In Drawing List"
            .ShowOpen
    End With
    If Err.Number <> 0 Then
        MsgBox("Error Exists")

   ElseIf Not oFileDlg.FileName = "" Then
        Dim fNames As Object
        fNames = Split(oFileDlg.FileName, "|")
        Dim curName As Object

        For Each curName In fNames
            oMultiList.Add(curName)
        Next curName
    End If
Return oMultiList
End Function

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes