Weird behavior: running through Inventor works correctly, but when run through a C# application, it doesn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have a very strange issue. I've written rules in iLogic that, based on user-provided parameters, create a new model, generate drawings, replace the reference model in the drawings, and then check in the model and drawings into the vault.
The problem is that if I run the rules through Inventor, it works correctly. However, if I run these rules through my WPF application in C#, Inventor doesn't wait for the completion of the check-in process, i.e., until the check-in progress window closes. Instead, while the check-in window is still open, Inventor proceeds to open the next drawing.
This window is open when next drawing is opening:
I should mention that if I run the rule manually in Inventor, it properly waits for the check-in window to close before opening the next drawing. Do you know why this is happening?
I just send only part of my rules code:
DrawingOpenSaveAndChangeReferencedDocument(LuftDrawingPath, luftName, iamExtension, idwExtension) DrawingOpenSaveAndChangeReferencedDocument(L1BlachaDrawingPath, L1BlachaSavePathWithoutExtension, iptExtension, idwExtension) DrawingOpenSaveAndChangeReferencedDocument(L2BlachaDrawingPath, L2BlachaSavePathWithoutExtension, iptExtension, idwExtension) DrawingOpenSaveAndChangeReferencedDocument(L3BlachaDrawingPath, L3BlachaSavePathWithoutExtension, iptExtension,idwExtension) If countReferencedDocuments = 4 DrawingOpenSaveAndChangeReferencedDocument(L4BlachaDrawingPath, L4BlachaSavePathWithoutExtension, iptExtension, idwExtension) End If ThisApplication.Documents.Open(currentPath, True) oDoc.Close() End Sub Public Sub DrawingOpenSaveAndChangeReferencedDocument(drawingPath As String, newDrawingPath As String, extension As String, idwExtension As String) Dim oDrawToCopy As DrawingDocument Dim oDraw As DrawingDocument oDrawToCopy = ThisApplication.Documents.Open(drawingPath, False) oDrawToCopy.SaveAs(newDrawingPath + idwExtension, True) oDrawToCopy.Close(True) oDraw =ThisApplication.Documents.Open(newDrawingPath + idwExtension, True) oDraw.ReferencedDocumentDescriptors.Item(1).ReferencedFileDescriptor.ReplaceReference(newDrawingPath & extension) oDraw.Save() oDraw.Save() Dim oControlDef As Inventor.ControlDefinition oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("VaultCheckinTop") oControlDef.Execute2(False) System.Windows.Forms.SendKeys.SendWait("" & Chr(9) & vbCrLf) ' PublishPDF(oDraw,newDrawingPath) ' oDraw.Close() End Sub
My app looks like:
It seems like Inventor has started to work asynchronously.