03-12-2021
10:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-12-2021
10:34 AM
I have this rule inside an rule to add this to event triggers. But now i get a lot of errors. I'm missing something i think:
This is the full rule:
Sub Main Dim oDoc As DrawingDocument oDoc = ThisDoc.Document ' Set a reference to the active sheet Dim oSheet As Sheet oSheet = oDoc.ActiveSheet Dim oDrawingDim As DrawingDimension Dim oDrawingDims As DrawingDimensions 'Dim oDimsToBeArranged As ObjectCollection ' Iterate over all dimensions in the drawing and ' center them if they are linear or angular. ' Add them to the ObjectCollection to be arranged Dim oDrawingDimensions = oSheet.DrawingDimensions oDimsToBeArranged = ThisApplication.TransientObjects.CreateObjectCollection For Each oDrawingDim In oDrawingDimensions If TypeOf oDrawingDim Is LinearGeneralDimension Then oDrawingDim.CenterText Dim oLinDim As LinearGeneralDimension = oDrawingDim If oLinDim.DimensionType = DimensionTypeEnum.kHorizontalDimensionType Or oLinDim.DimensionType = DimensionTypeEnum.kVerticalDimensionType Then If Not (oLinDim.IsBaselineSetMember Or oLinDim.IsChainSetMember) Then oDimsToBeArranged.Add(oDrawingDim) End If End If ElseIf TypeOf oDrawingDim Is OrdinateDimension Then Dim ordDim As OrdinateDimension = oDrawingDim If Not ordDim.IsOrdinateSetMember Then oDimsToBeArranged.Add(oDrawingDim) End If End If Next If oDimsToBeArranged.Count > 0 Then oDrawingDimensions.Arrange(oDimsToBeArranged) End If Events End Sub Sub Events On Error Resume Next Dim EventPropSet As Inventor.PropertySet EventPropSet = GetiLogicEventPropSet(ThisApplication.ActiveDocument) ' To make sure that the document has an iLogic DocumentInterest, add a temporary rule Dim tempRule = iLogicVb.Automation.AddRule(ThisDoc.Document, "TemporaryRule_392856A2", "") EventPropSet.Add("file://Drawing - Center_and_Arrange_Dimensions", "BeforeDocSave", 701) iLogicVb.Automation.DeleteRule(ThisDoc.Document, tempRule.Name) 'After Open Document : AfterDocOpen : 400 'Close(Document) : DocClose : 500 'Before Save Document : BeforeDocSave : 700 'After Save Document : AfterDocSave : 800 'Any Model Parameter Change : AfterAnyParamChange : 1000 'Part Geometry Change** : PartBodyChanged : 1200 'Material Change** : AfterMaterialChange : 1400 'Drawing View Change*** : AfterDrawingViewsUpdate : 1500 'iProperty(Change) : AfterAnyiPropertyChange : 1600 'Feature Suppression Change** : AfterFeatureSuppressionChange : 2000 'Component Suppression Change* : AfterComponentSuppressionChange : 2200 'iPart / iAssembly Change Component* : AfterComponentReplace : 2400 'New Document : AfterDocNew : 2600 iLogicVb.UpdateWhenDone = True InventorVb.DocumentUpdate() End Sub Function GetiLogicEventPropSet(cDocument As Document) As Inventor.PropertySet On Error Resume Next iLogicEventPropSet = cDocument.PropertySets.Item("iLogicEventsRules") If iLogicEventPropSet Is Nothing Then iLogicEventPropSet = cDocument.PropertySets.Item("_iLogicEventsRules") End If If iLogicEventPropSet.InternalName <> "{2C540830-0723-455E-A8E2-891722EB4C3E}" Then Call iLogicEventPropSet.Delete iLogicEventPropSet = cDocument.PropertySets.Add("iLogicEventsRules", "{2C540830-0723-455E-A8E2-891722EB4C3E}") End If If iLogicEventPropSet Is Nothing Then iLogicEventPropSet = cDocument.PropertySets.Add("iLogicEventsRules", "{2C540830-0723-455E-A8E2-891722EB4C3E}") End If If iLogicEventPropSet Is Nothing Then MsgBox ("Unable to create the Event Triggers property for this file!", , "Event Triggers Not Set") Err.Raise(1) Exit Function End If On Error GoTo 0 Return iLogicEventPropSet End Function