Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an iLogic rule in an assembly file which shrinkwraps the model and is triggered by the Close Document event.
Problem is the message box also appears when the drawing sheet containing views of this model is closed.
Can an iLogic be written to only run the rule when the active document in the graphics is the same document that contains the rule?
I have been able to write an iLogic which runs the rule only when the active document is an assembly file but I would like to change this to be the specific file that contains the rule.
My current rule is as follows:
Sub Main() Try Dim oDoc As Document = ThisApplication.ActiveDocument If oDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub Else Question = MessageBox.Show("Do you wish to shrinkwrap the Fan Drive Assembly now for use in the General Arrangement?", "Fan Drive Assembly",MessageBoxButtons.YesNo) If Question = vbYes Then Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("GA - FAN ASSEMBLY VIEW").Activate Try Dim g_App As Inventor.InventorServer = ThisApplication Dim AssDoc as Inventor.AssemblyDocument= ThisDoc.Document ' Create a new part document that will be the shrinkwrap substitute Dim oPartDoc As PartDocument oPartDoc = g_App.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , True) Dim oPartDef As PartComponentDefinition oPartDef = oPartDoc.ComponentDefinition Dim oDerivedAssemblyDef As DerivedAssemblyDefinition oDerivedAssemblyDef = oPartDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(AssDoc.FullDocumentName) ' Set various shrinkwrap related options oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll oDerivedAssemblyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll oDerivedAssemblyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll Call oDerivedAssemblyDef.SetHolePatchingOptions(DerivedHolePatchEnum.kDerivedPatchNone) Call oDerivedAssemblyDef.SetRemoveByVisibilityOptions(DerivedGeometryRemovalEnum.kDerivedRemoveNone) Dim oDerivedAss As DerivedAssemblyComponent oDerivedAss = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef) Call oDerivedAss.BreakLinkToFile() ' Save the part Dim partname As String=ThisDoc.PathAndFileName(False)& " (SHRINKWRAPPED).ipt" ThisApplication.ActiveView.Fit ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute Call oPartDoc.SaveAs(partname , False) Catch ex As Exception ErrorMessage = "Error creating ipt file." End Try oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Default").Activate Else 'Do Nothing End If End If Catch End Try End Sub
Solved! Go to Solution.