Inventor 2016: Border Zones disappear when adding border using iLogic

Inventor 2016: Border Zones disappear when adding border using iLogic

Anonymous
Not applicable
726 Views
5 Replies
Message 1 of 6

Inventor 2016: Border Zones disappear when adding border using iLogic

Anonymous
Not applicable

So this issue has been going on for some time and I am unable to find  a solution. The "Activesheet.Borer" command has known issues with turning off zone markers.  Next, I tried codes that is supposed to simulate clicking the Insert Border button. This code worked ok for some time but now it keeps giving me the "Object variable or With block variable not set" error. The code runs up to the point of deleting the old border then errors out. Attached are both sets of codes and the .dwg file.

I could really use some help figuring out how to add borders with zones in Inventor 2016. My new templates are on hold due to this issue.

Thank you.

0 Likes
Accepted solutions (1)
727 Views
5 Replies
Replies (5)
Message 2 of 6

JelteDeJong
Mentor
Mentor

this iLogic rule will change the border and title block. i did test it in the dwg you attached. i did attach your changed dwg file.

Dim borderTypes As String() = {"KAssembly", "KGang Assembly", "KGang Part", "KPart"}
Dim selectedBorderName As String
selectedBorderName = InputListBox("SELECT A BORDER TYPE", borderTypes, borderName, Title:="BORDER NAME", ListName:="List")

Dim doc As DrawingDocument = ThisApplication.ActiveDocument

For Each border As BorderDefinition In doc.BorderDefinitions
    If (border.Name.Equals(selectedBorderName, StringComparison.CurrentCultureIgnoreCase)) Then
        doc.ActiveSheet.Border.Delete()
        doc.ActiveSheet.AddBorder(border)
    End If
Next

Dim selectedTitleBlockName As String = ""
Select Case selectedBorderName
    Case "KAssembly"
        selectedTitleBlockName = "Kinze Assembly"
    Case "KGang Assembly"
        selectedTitleBlockName = "Kinze Gang Assembly"
    Case "KGang Part"
        selectedTitleBlockName = "Kinze Gang"
    Case "KPart"
        selectedTitleBlockName = "Kinze Part"
End Select

For Each titleblock As TitleBlockDefinition In doc.TitleBlockDefinitions
    If (titleblock.Name.Equals(selectedTitleBlockName, StringComparison.CurrentCultureIgnoreCase)) Then
        doc.ActiveSheet.TitleBlock.Delete()
        doc.ActiveSheet.AddTitleBlock(titleblock)
    End If
Next

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thank you very much for all your help with these codes.

 

The original problem, however, still exists in Inventor 2016. Border Zone markers disappear!

 

Raj Thapa

0 Likes
Message 4 of 6

JelteDeJong
Mentor
Mentor
Accepted solution

Hi, on my pc i get the border zones  but if i read the following posts then ther seems to be some bug.

Link1 Link2 Link3 

It seems that you need to expand the border node in your browser befor you insert it. With those post i alterd the code i posted before but because i dont seem to have this bug i cant test it for you. there for i can only hope that this works. any way let me know.

Public Sub Main()
	Dim bp = ThisApplication.ActiveDocument.BrowserPanes("DlHierarchy")
	Dim borderTypes As String() = {"KAssembly", "KGang Assembly", "KGang Part", "KPart"}
	Dim selectedBorderName As String
	selectedBorderName = InputListBox("SELECT A BORDER TYPE", borderTypes, borderName, Title:="BORDER NAME", ListName:="List")
	
	
			
	Dim doc As DrawingDocument = ThisApplication.ActiveDocument
	
	For Each border As BorderDefinition In doc.BorderDefinitions
		If (border.Name.Equals(selectedBorderName, StringComparison.CurrentCultureIgnoreCase)) Then
			Dim borderNode As BrowserNode = FindBorderNode(border.Name, bp.TopNode.BrowserNodes)
			borderNode.EnsureVisible()
			doc.ActiveSheet.Border.Delete()
			doc.ActiveSheet.AddBorder(border)
		End If
	Next
	
	Dim selectedTitleBlockName As String = ""
	Select Case selectedBorderName
		Case "KAssembly"
			selectedTitleBlockName = "Kinze Assembly"
		Case "KGang Assembly"
			selectedTitleBlockName = "Kinze Gang Assembly"
		Case "KGang Part"
			selectedTitleBlockName = "Kinze Gang"
		Case "KPart"
			selectedTitleBlockName = "Kinze Part"
	End Select
	
	For Each titleblock As TitleBlockDefinition In doc.TitleBlockDefinitions
		If (titleblock.Name.Equals(selectedTitleBlockName, StringComparison.CurrentCultureIgnoreCase)) Then
			doc.ActiveSheet.TitleBlock.Delete()
			doc.ActiveSheet.AddTitleBlock(titleblock)
		End If
	Next
End Sub

Function FindBorderNode(name As String, nodes As BrowserNodesEnumerator) As BrowserNode
    Dim foundNode As BrowserNode = Nothing
    For Each node In nodes
        If name = node.BrowserNodeDefinition.Label Then
            foundNode = node
            Exit For
        End If

        foundNode = FindBorderNode(name, node.BrowserNodes)
        If Not foundNode Is Nothing Then
            Exit For
        End If
    Next
    Return foundNode
End Function

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 6

Anonymous
Not applicable

Thank you for your code.

When I run your code with the InputListBox command active

>>

selectedBorderName = InputListBox("SELECT A BORDER TYPE", borderTypes, borderName, Title:="BORDER NAME", ListName:="List")

I get a Microsoft.NET Framework error. See image attached. After I click on Continue, the browser expands and input list box opens. When I select a border and apply, it changes the border but the zones are still missing.

If I comment out the InputListBox line, the Microsoft.NET error does not pop up.

 

I think I am going to give up on this code to change the border and just do this bit manually. 

 

 

 
 
 
0 Likes
Message 6 of 6

Anonymous
Not applicable

Thank you a million for all your help. I finally got it working. I found out that my problem was related to not having Service Pack 2 for Inventor 2016 not installed on my PC. 

It is working wonderfully now and the zones are intact and appearing as they should.

 

Again, thank you very much for helping!

 

Raj

0 Likes