- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have been messing with the attached code I found on the forum. I am trying to have it go through each sheet and change each balloon to a particular style. For some reason, when I run this rule, it gives me the following error:
Error in rule: Balloon Standard Update, in document: 0002-19-32793.idw
Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
My limited programming knowledge is getting in the way of me understanding where the issue lies. It seems to be in this line:
oBalloon.Style = oStyles.BalloonStyles.Item("Stylename")Any idea where it has gone wrong?
I have made sure my style name matches what is in the rule, but that does not seem to be the issue.
Here is the code I am messing with. It cam from @salariua here: https://forums.autodesk.com/t5/inventor-customization/how-to-change-balloon-style/m-p/6415051
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oStyles As DrawingStylesManager
oStyles = oDrawDoc.StylesManager
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet
'process all sheets
For Each oSheets In oDrawDoc.Sheets
' Iterate over each balloon on the sheet.
For Each oBalloon In oActiveSheet.Balloons
oBalloon.Style = oStyles.BalloonStyles.Item("Stylename")
Next
Next
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It may have just been the active sheet/container variable as oSheets throwing it off, or not declaring variables.
Make sure to check your balloon style name is correct if this doesn't work for you at first.
Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oStyles As DrawingStylesManager oStyles = oDrawDoc.StylesManager
Dim oSheet As Sheet
Dim oBalloon As Balloon
For Each oSheet In oDrawDoc.Sheets For Each oBalloon In oSheet.Balloons oBalloon.Style = oStyles.BalloonStyles.Item("Stylename") Next Next
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization
iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread
Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects
Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help
Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
oDoc = ThisDoc.Document
oNamer = "change Balloons to see qty quickly"
Dim UNDO As Transaction
UNDO = ThisApplication.TransactionManager.StartTransaction(oDoc, oNamer)
'undo in a set is important so that you dont accidently undo one by one and then when you run rule
'again it will change hald of what you undoed and the other half to what you want and create a mess
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oStyles As DrawingStylesManager
oStyles = oDrawDoc.StylesManager
Dim oSheet As Sheet
Dim oBalloon As Balloon
For Each oBalloon In ThisApplication.ActiveDocument.ActiveSheet.Balloons
'clear overrides
'oBalloon.BalloonValueSets(1).OverrideValue = ""
'oBalloon.SetBalloonType = ""
Call oBalloon.GetBalloonType(oBalloonType, oBalloonData)
If oBalloonType = KCircularWithOneEntryBalloonType Then
oBalloon.SetBalloonType(KCircularWithTwoEntriesBalloonType)
Else If oBalloonType = KCircularWithTwoEntriesBalloonType Then
oBalloon.SetBalloonType(KCircularWithOneEntryBalloonType)
End If
Next
UNDO.End
this code will change anything overridden