Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Loop and iLogic Rule till no Error

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ccoomes
1517 Views, 2 Replies

Loop and iLogic Rule till no Error

I am new to this so sorry if this has already been asked, but I could not find the answer.

 

I am trying to setup some rules to print various pdf files which we have managed to do without any problems.

 

The bit I am stuck on is when one of the PDF files being saved is open by another user.

 

We have been able to error trap it when it is open by shopwing a message box on error asking them to close the file befopre continuing.  The current message box being used is the Retry / Cancel box.

 

When the user clicks Retry we would like it to re-run the rule, or loops through the rule and check is the file is still open.  If the file is open return the same error, and if the file has been closed save the pdf file.  When Cancel is pressed it ends the rule (This Bit has been done).

 

My questions is how do I get the rule to re-run / loop through when the retry button is pressed.

Is it also possible to show the user who has the file open (or Previewing it in a Window Explorer)?

 

I have attached the Code currenlty Being used but I can post it here of preferred?

2 REPLIES 2
Message 2 of 3
Curtis_Waguespack
in reply to: ccoomes

Hi ccoomes,

 

Here's an example of how you might do this. Keep in mind that it's probably not best to state that the file is open, unless you've pragmatically checked for that status. Instead you might suggest that as the likely issue.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'Save PDF with options
path_and_namePDF = ThisDoc.PathAndFileName(False) ' without extension
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
oFileName = path_and_namePDF & ".pdf"

If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
End If

'Set the destination file name
oDataMedium.FileName = oFileName

PDF_Out:
Try
	'Publish document.
	Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
Catch
	oFile = MessageBox.Show("The PDF might be open." & vbCr & _
	"Close the file and click Retry to continue or Cancel to quit.", _
	"Unable to Save PDF",MessageBoxButtons.RetryCancel,MessageBoxIcon.Exclamation)

	If oFile = vbRetry Then
		Goto PDF_Out
	Else oFile = vbCancel
		Return
	End If
End Try

 

Message 3 of 3
ccoomes
in reply to: Curtis_Waguespack

Hi Curtis,

 

Many thanks for the excellent code.  This acheives what we will need it to do.

 

I will change the wording on the Message box about the file 'Might' be open.

 

I had a strange feeling it would be something as simple as the try method, but I could not quite get me head around how to get it to work.

 

Thanks again.

 

Clive.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report