
This blog post is something that I have been wanting to share for some time, it is definitely a topic that should be given some serious consideration when creating iLogic configurations.
What exactly am I on about? When creating Assembly and Drawing files in Inventor, there is the potential to create several thousand files every time a variation of a configured product is made. But generally the only output that needs to be saved, is a 2D drawing (often a PDF will suffice), as long as we can record the recipe for creating that specific configuration (in case we need to go back to it).
XML to the rescue:
As an example, Inventor’s BoM interface has long been able to manually import and export XML configurations of the BoM Columns (or setup). But in this example, we are going to import and export the model parameters using XML’s via iLogic.

As XML files are text based, they are tiny in size, taking up very little disc space (see image below). These tiny files contain all of the information necessary to build a complex configuration of an assembly.

The good news is that we can automate the export of XML files with iLogic, giving the file a suitable name, saving it in a specific location, meaning that we can easily refer back to it later. Similarly, we can automate the XML import process using iLogic.
XML Export – Import in Action:
In the Animated GIF below, you can see that 2 complex configurations (one Red and one Blue) are exported out to XML, they are then re-imported and the model updates. No additional Inventor files are created the only files used are the master assembly.

Here is the iLogic code, there are 2 Rules, and XML export, and an XML import
XML EXPORT Rule:
'XML EXPORT rule 'iLogic code by @ClintBrown3D 'originally posted at https://clintbrown.co.uk/using-xml-to-drive-ilogic-configurations oDirectory = "C:\TEMP\XML\" oName = ThisDoc.FileName(False) 'without extension oHour = Now.Hour : oMin = Now.Minute: oSec = Now.Second oTime = oHour & "-" & oMin & "-" & oSec oDay = Now.Day: oMonth = Now.Month: oYear = Now.Year oDate = oDay & "-" & oMonth & "-" & oYear oSaver = oDirectory & oName oXMLname = oTime & " (" & oDate & ").xml" oSaverXML = oDirectory & oName & "\" & oXMLname 'Create Directory Try: MkDir(oSaver): Catch: End Try iLogicVb.Automation.ParametersXmlSave(ThisDoc.Document, oSaverXML)
XML IMPORT Rule:
'XML IMPORT rule 'Code by @ClintBrown3d originally posted at https://clintbrown.co.uk/using-xml-to-drive-ilogic-configurations 'Special thanks to Curtis for sharing his File save code, which I have adapted for opeing XML's 'https://inventortrenches.blogspot.com/2012/10/ilogic-adding-save-as-dialog-box.html oDoc = ThisDoc.Document Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) oFileDlg.Filter = "XML Files (*.xml)|*.xml" oFileDlg.DialogTitle = "Unofficial Inventor - XML input dialogue" 'set the directory to open the dialog at oFileDlg.InitialDirectory = "C:\TEMP\XML\" & ThisDoc.FileName(False) 'without extension oFileDlg.ShowOpen()'Show File Open Dialogue ClintBrown3D = oFileDlg.FileName If ClintBrown3D = "" Then: Return: End If 'Open the selected file On Error GoTo ClintsErrorTrapper 'to handle an exit without selecting a file ' ThisDoc.Launch(ClintBrown3D) iLogicVb.Automation.ParametersXmlLoad(ThisDoc.Document, ClintBrown3D) 'Update the file iLogicVb.UpdateWhenDone = True Return ClintsErrorTrapper:
These versions of the code (both utilities) were briefly tested with Inventor 2020.2.
Please note that I cannot offer any additional support, this blog post is offered as-is, and is aimed at the more advanced user.
As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!
This site takes absolutely no responsibility for how you use this code in production (see disclaimer).
You must be logged in to post a comment.