iLogic Rule to save STEP file from drawing - inconsistent results
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Our process here is to create a STEP file at the same time we create dxf's and pdfs of our drawings, to pass on to our suppliers. We don't have Vault, so to speed things up, I've created a rule. (I can't take all the credit - most of this has been robbed from other posts on here). However, we only create STEP files of folded sheet metal items, so I have a separate rule just for those.
You'll see below, that the rule opens the part from the base view on the drawing. It then saves as a STEP file to a location and then closes the part.
My rule seems to work most of the time, but it can be sporadic. For instance, today, I've opened around 40 drawings at once and started to create the files and the STEP rule has been fine for the first 16 files that needed it and then I've started to see problems. What happens is the rule runs, without giving me an error. The part opens from the drawing and I get my message to say it has been saved (although this is superficial). However, I've got no STEP file in the folder. Since some have saved, it's not a location issue.
I thought maybe it was all down to the type of base view. Some of my colleagues place a flat pattern view first, rather than the folded. However, on some I've had issue with today, this has not been the case.
Could it be the quantity of files I'm opening at once? Not sure if that could have an impact. I'll try closing all and starting again to see what difference it makes.
Could it just be an inefficient rule? Can anyone see any glaring errors in my code?
Could it be the speed that the rules run at? A separate issue that I see on another rule is where it doesn't have enough time to process correctly and I have to run it twice to get the result. Could this be happening here? I haven't been able to find a snippet of code for adding a pause anywhere, so I'd be grateful if anyone could point me at some please, just to rule this out.
SyntaxEditor Code Snippet
'Dim statement: Declares and allocates storage space for variables Dim oPart As Inventor.PartDocument 'Takes the part shown in the 1st view 'of the current sheet's DrawingViews collection oDrawingDoc = ThisDrawing.Document oSheet = ActiveSheet.Sheet oDrawingView = oSheet.DrawingViews(1) oPart = ActiveSheet.View(oDrawingView.Name).ModelDocument 'Activate part for creating STEP file NewFileName = ThisDoc.ChangeExtension(".ipt") ThisApplication.Documents.Open(NewFileName, True) If oPart.DocumentType = kPartDocumentObject Then 'Confirm part If oPart.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then ' Get the STEP translator Add-In. Dim oSTEPTranslator As TranslatorAddIn oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap oStepFileName = iProperties.Value("Project", "Part Number") If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then ' Set application protocol. ' 2 = AP 203 - Configuration Controlled Design ' 3 = AP 214 - Automotive Design oOptions.Value("ApplicationProtocolType") = 2 ' Other options... 'oOptions.Value("Author") = "" 'oOptions.Value("Authorization") = "" 'oOptions.Value("Description") = "" 'oOptions.Value("Organization") = "" oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oData As DataMedium oData = ThisApplication.TransientObjects.CreateDataMedium strFolder = "R:\3D Data\DXF\Design Office dxfs - Steves\" oData.FileName = strFolder & "\" & oStepFileName & ".stp" oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData) End If Else 'Confirm Standard MessageBox.Show("Not a sheet metal part - No STEP file saved", "Check: Is this sheet metal?") End If End If ThisApplication.CommandManager.ControlDefinitions.Item("AppFileCloseCmd").Execute 'Gives Feedback to User MessageBox.Show("STEP format saved", "File Save")
I look forward to hearing what you all think...
Many thanks
Steve
Running Inventor Pro 2019.1.2