Export Rule - PDF, DXF & iLogic using message box

Export Rule - PDF, DXF & iLogic using message box

GKPByDesign
Advocate Advocate
958 Views
3 Replies
Message 1 of 4

Export Rule - PDF, DXF & iLogic using message box

GKPByDesign
Advocate
Advocate

Hello, 

 

I require a more efficient manner to export my files, I want code to the do the following.

 

- Run rule

- message box appears with 5 tick boxes and an export button or cancel

 

1. Export PDF (all pages) in colour, removed line weights, 400dpi, with the name based on the main drawing into a PDF folder within the project.

2. Export PDF (all drawings as single pages) - I have logic below for this that works fine, refer to iLogic note below. 

3. Export DXF (all drawings) in a DXF folder called DXFs in the same project location named as sheet name, will accept the use of an " _ " at the start of the drawing, as my dxf files get called "__drawing 1.dxf" because inventor calls DXF files by "file name" "_" "Sheet Name"

4. Export DXF (1 file) on the active page - file name from sheet name

5.  Export PDF (1 file) on the active page - file name from sheet name

Bonus button - Make all view precise - right click on the drawing and click precise can take ages! If there is a better code for this. This should run first.

 

 

iLogic Note - PDF separate sheets into multiple PDF files - The iLogic code i have works really well but I think it will need tweaking for this.

 

- Currently the code is written to close the drawing, I would rather the code end and nothing happen to the drawing

- Creates a folder called Single PDFs in the project location

 

'['Sub Variables
oRefDocs = ThisApplication.ActiveDocument.AllReferencedDocuments
Dim oDoc As Document
oFolder = ThisDoc.Path
oAddIns = ThisApplication.ApplicationAddIns
oTG = ThisApplication.TransientObjects']
'['PDF Export
'['PDF Options
PDFAddIn = oAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oContext = oTG.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = oTG.CreateNameValueMap
oDataMedium = oTG.CreateDataMedium
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 4800
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet']
For Each oDoc In oRefDocs
	idwPathName = Left(oDoc.FullDocumentName, Len(oDoc.FullDocumentName) -3) & "idw"
	If System.IO.File.Exists(idwPathName) Then
		oDrawDoc = ThisApplication.Documents.Open(idwPathName, True)
		For Each oSheet As Sheet In oDrawDoc.Sheets
			NameUnique = False
			Count = 1
			oSheet.Activate
			oDataMedium.FileName = oFolder & "\" & Left(oSheet.Name,Len(oSheet.Name) - (Len(oSheet.Name) - InStr(oSheet.Name, ":")) - 1) & ".pdf"
			TempName = oDataMedium.FileName
			Do Until NameUnique = True
				If System.IO.File.Exists(TempName) Then 
					TempName = Left(oDataMedium.FileName,Len(oDataMedium.FileName)-4) & Count & ".pdf"
					Count = Count + 1
						If count > 100 Then NameUnique = True 'stop infinite loop
				Else
					NameUnique = True
					oDataMedium.FileName = TempName
				End If
			Loop
			'MessageBox.Show("oDataMedium.FileName = " & oDataMedium.FileName, "Title")

			'oDataMedium.FileName = oFolder & "\" & Replace(oSheet.Name, ":","-") & ".pdf"
			Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium)
		Next
		oDrawDoc.Close(False)
	End If
Next']
MessageBox.Show("PDF Export completed.", "PDF Export", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)

 

 

0 Likes
959 Views
3 Replies
Replies (3)
Message 2 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@GKPByDesign,

 

InputListBox function in iLogic can be used to list all 5 parameters. For more details, refer below help documentation on iLogic.

 

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2015...

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 4

jamesVM3XN
Contributor
Contributor

Did you ever get this to work? This is exactly what I am looking to achieve? 

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Hi @jamesVM3XN.  This is a pretty complex scenario to set-up.

To start with, a dialog is mentioned that has 5 check boxes, an export button, and a cancel button.  And those check boxes are to control which of the various processes will be ran on the active document.  This dialog would have to be independent of any document, so it can be used on any document.  If this were to use a simple iLogic global form, you would need to have 5 boolean type user parameters injected into the active document, to provide the 5 check boxes.  Then when you check a box, it would set the parameter to True, then your rules would have to check the values of those parameters.  This is definitely not ideal.  So your next two options are either using a VBA UserForm or a Windows Form.  Both of those options are far more complicated to create than the iLogic global form, but you would not need to use document parameters for the check boxes.

 

Then there are all the external iLogic rules (or VBA codes) you would need.  One would be needed to direct traffic, so to speak.  It would get the results of the form, then determine which rules to run in response to make the various export processes happen.  Then you would need a separate rule for each of the 5 different export processes.  If using a VBA UserForm, you will have a special form type module that will contain the code for the forms functionality, and the code to react to the forms results will most likely be included in that.  If using a Windows Form, it will be similar to the VBA form module, and the forms design, functionality, and reactions to results of the form will all likely be in one rule.  It's a lot of detail and a lot of code.  And will likely need to be personalized to your wants/needs/style/workflow.  You can likely find examples of most of the export type iLogic codes around the forums, but the form and the codes that accompany it are another story.  You can check out some of my contribution posts (Link1, Link2, Link3) about creating your own personalized Windows Form within an iLogic rule, and how to react to events if you want.  You will likely just have to put the whole project together piece by piece to get everything the way you want it.  Good luck.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes