Ilogic Rula to eliminate the unattached balloons

Ilogic Rula to eliminate the unattached balloons

Anonymous
Not applicable
1,893 Views
14 Replies
Message 1 of 15

Ilogic Rula to eliminate the unattached balloons

Anonymous
Not applicable

Hi,

 

Anyone have a rule that i can put on ilogic to eliminate all the unattached balloons in my drawing?

 

Thanks for your time!

0 Likes
Accepted solutions (3)
1,894 Views
14 Replies
Replies (14)
Message 2 of 15

MechMachineMan
Advisor
Advisor
Accepted solution

The sample in the Programming help literally had 90% of the coding.

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-BD3B99E0-D3AB-439A-BF05-DF4A06512D8D

 

 

Sub Main()
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
        
    Dim oBalloon As Balloon
    
    For Each oBalloon In oSheet.Balloons
        If oBalloon.Attached = False
oBalloon.Delete
End if Next End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
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
Message 3 of 15

Anonymous
Not applicable

Thanks for the help!

0 Likes
Message 4 of 15

Anonymous
Not applicable

Just one more thing, there any rule we can aplly to the ilogic to expand the part list?

Because i have one program associate to inventor and he part list doens't expand all the itens!

 

thanks for the time.

0 Likes
Message 5 of 15

Anonymous
Not applicable

Just one more thing, there is any rule to expand the part list? I want one rule that i can put on ilogic to expand all the itens in the part list!

0 Likes
Message 6 of 15

MechMachineMan
Advisor
Advisor
Accepted solution

To expand parts list 1 on the active sheet:

Sub Main()
    Dim oDoc As Document
    oDoc = ThisApplication.ActiveDocument

    Dim oSheet As Sheet
    oSheet = oDoc.ActiveSheet

	If oSheet.PartsLists.Count < 1 Then: Exit Sub: End If

    Dim oPartsList As PartsList
    oPartsList = oSheet.PartsLists(1)

	Dim i As Integer
    i = 1
	
    Do
        oCurRow = oPartsList.PartsListRows.Item(i)
        
        If oCurRow.Expandable = True Then
            oCurRow.Expanded = True
        End If
		i = i+1
    Loop Until i > oPartsList.PartsListRows.Count
End Sub 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
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
0 Likes
Message 7 of 15

Anonymous
Not applicable

Perfect! Thank you!

 

Without wanting to abuse it would be possible to know if there is a rule that puts the part list in ascending order in relation to the items.

 

Thanks again for the time!

0 Likes
Message 8 of 15

MechMachineMan
Advisor
Advisor

Well, Autodesk has some very good documentation on that sort of thing in their online help files!

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-CC993480-55C0-4C1C-9B2F-E522B879E990

 

It should be pretty obvious right away which is the proper method for 'sorting' a partslist.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
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
0 Likes
Message 9 of 15

Anonymous
Not applicable

Thanks for the help! 

 

i already find what i want but still missing only one part, that i can't find how to do!

 

In the first rule that you send me you write that is onle for the active sheet, but i need to apply to all the sheets, so can you please tell me where i have to change the code?

 

Thanks again!

0 Likes
Message 10 of 15

MechMachineMan
Advisor
Advisor

Well, since the PartsList is going to need to be resorted after expanding the rows, you might as well add it into the code AFTER it's done expanding the rows.

 

It expands the rows through a loop, which should be evident - The Do-Loop construct, so you need to place the line in the code UNDERNEATH the Loop line.

 

as the PartsList on the sheet has already been assigned to a variable [which i named oPartsList], you can just use the .Sort call on that "oPartsList" object.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
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
0 Likes
Message 11 of 15

Anonymous
Not applicable

Sorry for thr trouble, but i should understand what you explain to me, but i'm not very good to create and understand the code on the rules! 

 

So it is possible that you change the code you send me and add this options of expand all the parts list in all the sheets?

 

Sorry one more time.

0 Likes
Message 12 of 15

MechMachineMan
Advisor
Advisor

I don't really believe in helping those who don't make an apparent effort to help themselves, so how about this:

 

Try modifying the code yourself first and running it. If you get errors, post back here with YOUR modified version of the code, and a screenshot of the error it pops up with and I can work through the fix with you.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
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
0 Likes
Message 13 of 15

Anonymous
Not applicable

I want to thank you for the help you gave me, and to tell you that I do not fit into the message you wanted to pass me.
Because I do not have any knowledge in ilogi part and much less in code. That's why I think I've done a good job of solving one of the codes I've asked you about.
In this part I still have not managed so well, but I believe it is a simple problem to solve here the question is that my time was limited, so I went ahead with this situation!

0 Likes
Message 14 of 15

MechMachineMan
Advisor
Advisor
Accepted solution

See the 2nd code box. Take careful note of how many lines of code I had to change (3) and maybe study the change.

 

Also, to add the sorting functionality you wanted is literally 1 line of code to add to the other script.

 

Sub Main()
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
        
    Dim oBalloon As Balloon
    
    For Each oBalloon In oSheet.Balloons
        If oBalloon.Attached = False
oBalloon.Delete
End if Next End Sub

 

modified to work on all sheets looks like:

 

Sub Main()
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    'Set oSheet = oDrawDoc.ActiveSheet

For Each oSheet in oDrawDoc.Sheets
Dim oBalloon As Balloon For Each oBalloon In oSheet.Balloons If oBalloon.Attached = False oBalloon.Delete End if Next
Next End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
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
Message 15 of 15

emanuel.c
Collaborator
Collaborator

My little adaptation for Deleting Balloons Only on Active Sheet or from ALL Sheets in Drawing

 

Sub Main()
	
	Dim oDrawDoc As DrawingDocument
	oDrawDoc = ThisApplication.ActiveDocument    
	Dim oSheet As Sheet
	Dim oBalloon As Balloon

	'True = Default to first Button / False = Default to second Button		
	Question = InputRadioBox("Select Below:", "THIS Sheet Only", "ALL Sheets in this Drawing", True, "Delete Balloons From:")
	
	If Question = True Then
		oSheet = oDrawDoc.ActiveSheet
			For Each oBalloon In oSheet.Balloons
				'If oBalloon.Attached = False
					oBalloon.Delete
				'End If
			Next
	Else
		For Each oSheet In oDrawDoc.Sheets        
			For Each oBalloon In oSheet.Balloons
				'If oBalloon.Attached = False
					oBalloon.Delete
				'End If
			Next
		Next	
	End If

End Sub

 

0 Likes