Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

End of Statement Expected & Math issue

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Ktomberlin
577 Views, 4 Replies

End of Statement Expected & Math issue

I know this is something very easy, i've searched and tried several things and can't find the solution.

 

I get the "End of Statement Expected" error for the Dim lines with following ilogic but it might be related to the first line because that line on its own results in a EarlyRev value of -1 no matter what value is stored in oRevNum.  There might be a better solution but all i really want to do is move the previous revision to the obsolete folder prior to making the pdf.   Also, how do i set the saveas command to overwrite if the existing file already exists?

 

       

      oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

'Move Prior Rev to Obsolete

If oRevNum>=1 Then

Dim EarlyRev AsString= oRevNum - 1

 

MessageBox.Show("Did it work"&EarlyRev)

 

Dim FileCurrent AsString="P:\" & PDF_Folder "\" & FileName & " REV" & EarlyRev & ".pdf"

Dim FileObs AsString= "P:\" & PDF_Folder & "\Obsolete\" FileName & " REV" & EarlyRev & ".pdf"

System.IO.File.Move(FileCurrent, FileObs)

EndIf

4 REPLIES 4
Message 2 of 5

Dim FileCurrent As String = "P:\" & PDF_Folder & "\" & FileName & " REV" & EarlyRev & ".pdf"
Dim FileObs As String = "P:\" & PDF_Folder & "\Obsolete\" & FileName & " REV" & EarlyRev & ".pdf"

 try these changes please.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 5
Ktomberlin
in reply to: Ktomberlin

That did get rid of the statement errors, Thank you.  I see the missing "&"s.  I'm still having issues when the pdf file already exists for the current Rev.  It doesn't overwrite a new copy of the pdf.  Anyone have thoughts on this?  I thought the intial version of post PDF creation ilogic did over write or at least gave you a yes/no dialog.

 

I did solve my Earlyrev variable issue, within the if statment i had to define the the oRevNum again (oRevNum=iProperties.Value("Project", "Revision Number") since apparently how i've got it defined above isn't global.

 

I've also got it moving the old rev file now with.

 

oRevNum=iProperties.Value("Project", "Revision Number")
oFileName=ThisDoc.FileName(False)
If
oRevNum>=1ThenDimEarlyRevAsString=oRevNum-1
' Debug MessageBox.Show("Did it work? " & EarlyRev)DimFileCurrentAsString="P:\"&PDF_Folder&"\"&oFileName&" REV"&EarlyRev&".pdf"
DimFileObsAsString="P:\"&PDF_Folder&"\OBSOLETE\"&oFileName&" REV"&EarlyRev&".pdf"
System.IO.File.Move(FileCurrent, FileObs)

 

Message 4 of 5
jdkriek
in reply to: Ktomberlin


@Ktomberlin wrote:

Also, how do i set the saveas command to overwrite if the existing file already exists?


 

You would need to delete the old file first. Like so.

 

Dim FileCurrent As String = "P:\" & PDF_Folder & "\" & FileName & " REV" & EarlyRev & ".pdf"
Dim FileObs As String = "P:\" & PDF_Folder & "\Obsolete\" & FileName & " REV" & EarlyRev & ".pdf"
If System.IO.File.Exists(FileCurrent) Then
	System.IO.File.Delete(FileCurrent)
End If
System.IO.File.Move(FileCurrent, FileObs)
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 5
Ktomberlin
in reply to: Ktomberlin

I figured out that since I had windows explorer open to the folder I was creating the pdf's in.  It was failing due to windows explorer accessing the file for the preview.  Since closing windows explorer it now works.  I'm just now adding the code to check to make sure the file can be rewritten and post a msgbox if it can't instead of crashing.  I'm sure its not the cleanest code but its working as desired.  Thank you for the help today.

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

Post to forums  

Autodesk Design & Make Report