
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Why am I getting this error? This happens after my code creates the rule, and it runs the rule. The rule has nothing to do with Vault, at least not directly.
Error in rule: ClearanceCalcs, in document: C-16000-01.iam
Failed to create VaultAccess object.
System.InvalidOperationException: Failed to create VaultAccess object. ---> System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'VaultAddInLib.IVaultApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6796EC03-5DAB-4B0B-849B-41195C3429E8}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at iLogic.VaultApplication..ctor(InventorServerObject app)
at iLogic.VaultAccess..ctor(InventorServerObject app)
at iLogic.ComponentInRule..ctor(Document rootDoc, InventorServerObject server)
--- End of inner exception stack trace ---
at iLogic.ComponentInRule..ctor(Document rootDoc, InventorServerObject server)
at iLogic.RuleEvalContainer.GetOrCreateNamedProperty(NamedProperty property)
at iLogic.RuleEvalContainer.GetCadComponent()
at LmiRuleScript.SetHost(IRulesHost host)
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Dim strRuleClearanceCalcs As String = String.Empty ''create the ilogic rule below as ClearanceCalcs and add to save event strRuleClearanceCalcs = "Sub Main" & vbCrLf & " RunClearanceCalcs()" & vbCrLf & " GetCustomProperties()" & vbCrLf & "End Sub" & vbCrLf & "" & vbCrLf & "Public Sub RunClearanceCalcs()" & vbCrLf & " Dim LoadComponent As String" & vbCrLf & " Dim CarComponent As String" & vbCrLf & " LoadComponent = ""LOAD""" & vbCrLf & " CarComponent = ""CAR""" & vbCrLf & " Parameter(""LoadWeight"") = iProperties.MassOfComponent(LoadComponent)" & vbCrLf & " centerPt = iProperties.CenterOfGravity" & vbCrLf & " Parameter(""CCOG"") = Round(centerPt.y, 1)" & vbCrLf & " truckHalf = iProperties.Value(CarComponent, ""Custom"", ""HalfTruckCenter"")" & vbCrLf & " Parameter(""TruckReactionLeft"") = ((TruckHalf - centerPt.x) / (2 * TruckHalf)) * iProperties.Mass" & vbCrLf & " Parameter(""TruckReactionRight"") = ((TruckHalf + centerPt.x) / (2 * TruckHalf)) * iProperties.Mass" & vbCrLf & " iProperties.Value(""Custom"", ""RailCar"") = iProperties.Value(CarComponent, ""Custom"", ""CarSeries"")" & vbCrLf & " iProperties.Value(""Custom"", ""Specification"") = iProperties.Value(LoadComponent, ""Custom"", ""Specification"")" & vbCrLf & " Parameter(""LoadLimit"") = iProperties.Value(CarComponent, ""Custom"", ""LoadLimit"")" & vbCrLf & " Parameter(""LightWeight"") = iProperties.MassOfComponent(CarComponent)" & vbCrLf & " Parameter(""FixtureWeight"") = iProperties.Mass - (iProperties.MassOfComponent(LoadComponent) + Parameter(""LightWeight""))" & vbCrLf & " Parameter(""Axles"") = iProperties.Value(CarComponent, ""Custom"", ""Axles"")" & vbCrLf & " iProperties.Value(""Custom"", ""PercentDifference"") = CStr(Round((Abs(Parameter(""TruckReactionLeft"") - Parameter(""TruckReactionRight"")) / iProperties.Mass) * 100, 1)) & ""%""" & vbCrLf & " iProperties.Value(""Custom"", ""AxleLoadsLeft"") = CStr(Round((Abs(Parameter(""TruckReactionLeft"")) / Parameter(""Axles"") * 2) / 1000, 0)) & ""kip""" & vbCrLf & " iProperties.Value(""Custom"", ""AxleLoadsRight"") = CStr(Round((Abs(Parameter(""TruckReactionRight"")) / Parameter(""Axles"") * 2) / 1000, 0)) & ""kip""" & vbCrLf & "End Sub" & vbCrLf & "" & vbCrLf & "Public Sub GetCustomProperties()" & vbCrLf & " Dim LoadComponent As String" & vbCrLf & " Dim sychronize As Boolean = False" & vbCrLf & " LoadComponent = ""LOAD""" & vbCrLf & " 'for each custom iProperty in Load Component determine if car mod has them, and they are the same." & vbCrLf & " compLoad = Component.InventorComponent(LoadComponent)" & vbCrLf & " Dim propSet = compLoad.ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(""Inventor User Defined Properties"")" & vbCrLf & " Dim carPropSet = ThisDoc.Document.PropertySets.Item(""Inventor User Defined Properties"")" & vbCrLf & " For Each prop In propSet" & vbCrLf & " Dim propName As String = prop.Name" & vbCrLf & " For Each carProp In carPropSet" & vbCrLf & " If propName = ""FullTitle"" Or propName = ""NextAssembly"" Then Continue For" & vbCrLf & " If carProp.Name = propName Then" & vbCrLf & " 'do something magical" & vbCrLf & " If prop.Value <> carprop.Value Then" & vbCrLf & " If synchronize = False Then" & vbCrLf & " If MsgBox(""Sync Load Component Properties With This Document?"", MsgBoxStyle.YesNo) = vbYes Then" & vbCrLf & " synchronize = True" & vbCrLf & " Else" & vbCrLf & " Exit Sub" & vbCrLf & " End If" & vbCrLf & " End If" & vbCrLf & " If synchronize = True Then" & vbCrLf & " Try" & vbCrLf & " carProp.Value = prop.Value" & vbCrLf & " Catch" & vbCrLf & " MsgBox(""Can Not write iProperty "" & propName)" & vbCrLf & " End Try" & vbCrLf & " End If" & vbCrLf & " End If" & vbCrLf & " End If" & vbCrLf & " Next" & vbCrLf & " Next" & vbCrLf & "End Sub" Dim iLogAuto As Object 'Autodesk.iLogic.Interfaces.IiLogicAutomation iLogAuto = addin.Automation iLogAuto.CallingFromOutside = True iLogAuto.EnterDelayedRuleRunningMode() iLogAuto.AddRule(ClearanceModel, "ClearanceCalcs", strRuleClearanceCalcs) iLogAuto.ExitDelayedRuleRunningMode() iLogAuto.RulesOnEventsEnabled = True iLogAuto.CallingFromOutside = False
Solved! Go to Solution.