iLogic rule not working with Inventor 2019

iLogic rule not working with Inventor 2019

drafting03_AR
Contributor Contributor
833 Views
1 Reply
Message 1 of 2

iLogic rule not working with Inventor 2019

drafting03_AR
Contributor
Contributor

I managed to cobble together some code that takes the current open drawing and exports it as an ACAD 2000 .dwg file into a certain folder. However, after updating from Inventor 2017 to Inventor 2019, it no longer works. The particular line of code that has the error is:

 

DWGAddIn.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium)

The full code is here:

' This rule will publish the currently open Inventor drawing to an AutoCAD .dwg (2000). Note that it will also publish non-sheet metal dwgs
Imports SysIO = System.IO
Sub Main()
	'See if there are any open views
	If (ThisApplication.Views.Count > 0) Then
		'Setup Translator to dwg
		Dim DWGAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
	
		Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
		oContext.Type = kFileBrowseIOMechanism
	
		' Create a NameValueMap object
		Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
	
		' Create a DataMedium object
		Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
	
				
		'Go through each view and save if it's a drawing document
		Dim oDoc = ThisDoc.Document
			If oDoc.DocumentType = kDrawingDocumentObject Then
				'Get the directory file is saved in. Can replace this with specific directory
				'Dim dwgDir = SysIO.Path.GetDirectoryName(view.Document.FullFileName)
				Dim dwgDir = "\\ARD-ad01\CompanyData\ACUTE AND LASER CUTTING DWG DXF STEP PDF\"

				'Get name of file without the extension and add _acad2k to it.
				oDataMedium.MediumType = kFileNameMedium
				oDataMedium.FileName = dwgDir & "\\" & _
                                    SysIO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) & _
                                     ".dwg"
				' Check whether the translator has 'SaveCopyAs' options
				If DWGAddIn.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
					'Use Export To DWG to save drawing configuration and set here
					Dim strIniFile As String = "C:\\Temp\\DWGOut.ini"
					' Create the name-value that specifies the ini file to use.
					oOptions.Value("Export_Acad_IniFile") = strIniFile
					' Set the DWG version. 
        			' 23 = ACAD 2000 
        			' 25 = ACAD 2004 
        			' 27 = ACAD 2007 
        			' 29 = ACAD 2010  
        			oOptions.Value("DwgVersion") = 23
					'Save File
					ThisApplication.[_LibraryDocumentModifiable] = True
					DWGAddIn.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium)
					question = MsgBox("AutoCAD DWG Created:" & vbLf & vbLf & oDataMedium.FileName & vbLf & vbLf & "Would you like to open it?", MsgBoxStyle.YesNo, "Ausroad iLogic")
					If question = vbYes Then
						ThisDoc.Launch(oDataMedium.FileName)
					End If
				End If
			Else
				MsgBox("File must be a DWG", MsgBoxStyle.OKOnly, "Ausroad iLogic")
			End If
	End If
End Sub

The error message is:

Error in rule: ExportDWG, in document: 50034A.dwg

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

More Info:

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Inventor.TranslatorAddIn.SaveCopyAs(Object SourceObject, TranslationContext Context, NameValueMap Options, DataMedium TargetData)
   at ThisRule.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

Anyone have any idea how I can fix this? We went from Inventor 2017 to 2019, OS is Windows 7 Pro x64.

Or is there a simpler way to achieve an ACAD 2000 .dwg export with a rule? I'm pretty sure I have some redundant code in there but it worked, so I just left it alone.

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

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Something is wrong with the path on your server!

 

if you test this line of code it works:

Dim dwgDir = "c:\temp\"

and not using this string
'"\\ARD-ad01\CompanyData\ACUTE AND LASER CUTTING DWG DXF STEP PDF\"

did you change your server name or paths!?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes