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: 

invalid conversion.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
danny
256 Views, 2 Replies

invalid conversion.

Hi all, why is this code returning a fault? Conversion from type DataMedium to Type String is invalid... But when used with pdf extension it works fine. Dim oRevNum, oDwgName, oTekNr, oSubTitle, oNewFolder, oStatus, oPartNr As String '------start of iLogic------- oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oRevNum = iProperties.Value("Project", "Revision Number") oPDFAddIn = 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 oTekNr = iProperties.Value("Custom", "Tekening Nummer") oNewFolder = iProperties.Value("Custom", "ExportMap") oStatus = iProperties.Value("Status", "Status") oSubTitle = iProperties.Value("Summary", "Title") oDwgName = iProperties.Value("Project", "Description") oPartNr = iProperties.Value("Project", "Part Number") If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'Check For the DXF folder And create it If it does Not exist If Not System.IO.Directory.Exists(oNewFolder) Then System.IO.Directory.CreateDirectory(oNewFolder) End If 'Set the DXF target file name oDataMedium.FileName = oNewFolder & "\" & oTekNr & "_" & oPartNr & "_" & oDwgname & oSubTitle & " Rev" & oRevNum & "_" & oStatus & ".dxf" If iProperties.Value("Custom", "DxfOnSave") = True Then ThisDoc.Document.SaveAs(oDatamedium , True) iProperties.Value("Custom", "DxfOnSave") = False 'Show in Explorer Shell("explorer.exe " & oNewFolder,vbNormalFocus) End If '------end of iLogic-------
Regards
Danny

Inventor 2014 sp1 | Vault basic 2014 | HP Elitebook 8670W | win7 64b | 8Gb | GMT +1
2 REPLIES 2
Message 2 of 3
danny
in reply to: danny

Hi, because on my desktop, this website still doesn't work, here again:

 

Hi all, why is this code returning a fault? Conversion from type DataMedium to Type String is invalid... But when used with pdf extension it works fine.

 

Dim oRevNum, oDwgName, oTekNr, oSubTitle, oNewFolder, oStatus, oPartNr As String '------start of iLogic------- oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oRevNum = iProperties.Value("Project", "Revision Number") oPDFAddIn = 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 oTekNr = iProperties.Value("Custom", "Tekening Nummer") oNewFolder = iProperties.Value("Custom", "ExportMap") oStatus = iProperties.Value("Status", "Status") oSubTitle = iProperties.Value("Summary", "Title") oDwgName = iProperties.Value("Project", "Description") oPartNr = iProperties.Value("Project", "Part Number") If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'Check For the DXF folder And create it If it does Not exist If Not System.IO.Directory.Exists(oNewFolder) Then System.IO.Directory.CreateDirectory(oNewFolder) End If 'Set the DXF target file name oDataMedium.FileName = oNewFolder & "\" & oTekNr & "_" & oPartNr & "_" & oDwgname & oSubTitle & " Rev" & oRevNum & "_" & oStatus & ".dxf" If iProperties.Value("Custom", "DxfOnSave") = True Then ThisDoc.Document.SaveAs(oDatamedium , True) iProperties.Value("Custom", "DxfOnSave") = False 'Show in Explorer Shell("explorer.exe " & oNewFolder,vbNormalFocus) End If '------end of iLogic------- 

 

Regards
Danny

Inventor 2014 sp1 | Vault basic 2014 | HP Elitebook 8670W | win7 64b | 8Gb | GMT +1
Message 3 of 3
danny
in reply to: danny

I figured it out myself:

 

The code:

 

oDataMedium.FileName =

Needs to be:

oDataMedium =

For saveas DXF command; For saveas PDF, the code is oDataMedium.Filename.

 

 

Regards
Danny

Inventor 2014 sp1 | Vault basic 2014 | HP Elitebook 8670W | win7 64b | 8Gb | GMT +1

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

Post to forums  

Autodesk Design & Make Report