Adding Borders Using iLogic causes the Zones to Disappear

Adding Borders Using iLogic causes the Zones to Disappear

Anonymous
Not applicable
1,234 Views
5 Replies
Message 1 of 6

Adding Borders Using iLogic causes the Zones to Disappear

Anonymous
Not applicable

I have written some iLogic Code to help us reduce the number of templates that we use.

 

In the attached file “Latest Format.dwg” you find a rule “SHEET SIZE”

 

The rule does the following for Sheets 1 & 2:

 

  1. Kicks up an Input box to choose the desired drawing sheet size.
  2. After selecting the sheet size the rule changes the sheet size, puts in the correct border, title block & selects the correct style.

 

The rule runs great except for the border zones.

 

I created the new borders by defining “New Zone Borders” and I did verify that the zones were populated before I ran the rule.

 

If I manually add the borders all the zones are populated, but when it is done through the rule they disappear and there is no way, that I can find, to repopulate them or to get the zones to come in populated.

 

Can anyone provide some assistance in resolving this issue?

0 Likes
1,235 Views
5 Replies
Replies (5)
Message 2 of 6

frederic.vandenplas
Collaborator
Collaborator

Hi,

 

i've tried this in vba with the same result as you experience.

I did found an api sample (although not correct and needs modification depending on which version you use)

that creates a zone border

Border Insert API Sample 
Description 
This sample illustrates inserting a default border.
Code Samples 
VBA Sample Code 
Public Sub InsertDefaultBorder()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    ' Check to see if the sheet already has a border and delete it if it does.
    If Not oSheet.Border Is Nothing Then
        oSheet.Border.Delete
    End If
    
    ' Define the values to use as input for the border creation.
    Dim HorizontalZoneCount As Long
    HorizontalZoneCount = 15
    
    Dim HorizontalZoneLabelMode As BorderLabelModeEnum
    HorizontalZoneLabelMode = kBorderLabelModeNumeric
    
    Dim VerticalZoneCount As Long
    VerticalZoneCount = 10
    
    Dim VerticalZoneLabelMode As BorderLabelModeEnum
    VerticalZoneLabelMode = kBorderLabelModeAlphabetical
    
    Dim LabelFromBottomRight As Boolean
    LabelFromBottomRight = False
    
    Dim DelimitByLines As Boolean
    DelimitByLines = False
    
    Dim CenterMarks As Boolean
    CenterMarks = False
    
    Dim TopMargin As Double
    TopMargin = 5
    
    Dim BottomMargin As Double
    BottomMargin = 3
    
    Dim LeftMargin As Double
    LeftMargin = 1
    
    Dim RightMargin As Double
    RightMargin = 2
    
    Dim BorderLineWidth As Double
    BorderLineWidth = 0.1
    
    Dim TextLabelHeight As Double
    TextLabelHeight = 1.5
    
    Dim Font As String
    Font = "Courier New"
    
    ' Add the border to the sheet.  This sets all of the values, but any of them
    ' can be left out and it will default to an appropriate value.
    Dim oBorder As DefaultBorder
    Set oBorder = oSheet.AddDefaultBorder(HorizontalZoneCount, HorizontalZoneLabelMode, _
                                          VerticalZoneCount, VerticalZoneLabelMode, _
                                          LabelFromBottomRight, DelimitByLines, _
                                          CenterMarks, TopMargin, BottomMargin, _
                                          LeftMargin, RightMargin, BorderLineWidth, _
                                          TextLabelHeight, Font)
End Sub
 
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 3 of 6

Anonymous
Not applicable

Frederic,

 

I did try the code as is, and you are correct to state that the code needs to be modified.

I did do some further research and found that this issue I am having is nothing new and actually has been going on for years.

Yesterday I decided to make my own custom borders, since we are going to only use 4  and they are very simple and fast to make.

I was able to give this a try late yesterday afternoon and it worked very well.

 

Thank you for your quick response!

 

My next task is to go to the idea station to see if anyone has noted this issue, if so I will give it Kudos to bump it up on the list.

If not I will add it to the site..

0 Likes
Message 4 of 6

freesbee
Collaborator
Collaborator

...yes, the issue is known to Autodesk since 4 years already: it's not iLogic specific. It has to do with the AddBorder() method that is not working as it should. AddBorder() is there since Inventor 5.3 and somehow still unchanged.

http://forums.autodesk.com/t5/inventor-customization/sheet-size-ilogic-problem/td-p/3736628

Curious to see if a fix will ever come...

Massimo Frison
CAD R&D // PDM Admin · Hekuma GmbH
0 Likes
Message 5 of 6

tasnad.peter_pureco
Participant
Participant

Hi Jason,

 

I think there is some kind of bug inventor: you have to expand the border node in the browser at least once in a session (before running your code), and the zone border will be displayed correctly.

 

I put this code into my rule:

 

 

Dim node
node = FindBorderNode("Zone Border - A3", bp.TopNode.BrowserNodes)
node.EnsureVisible()
Function FindBorderNode(name, nodes)
	Dim node
	For Each node In nodes
    	If name = node.BrowserNodeDefinition.Label Then
        	FindBorderNode = node
        	Exit Function
    	End If
    
    	FindBorderNode = FindBorderNode(name, node.BrowserNodes)
    	If Not FindBorderNode Is Nothing Then
        	Exit Function
    	End If
	Next
End Function

 

Replace the "Zone Border - A3" any of your border name.

 

I do not like the expanded node, so I put this code to the end of the rule:

 

Dim oTopNode As BrowserNode
oTopNode = drawingDoc.BrowserPanes.ActivePane.TopNode
Dim oNode As BrowserNode

For Each oNode In oTopNode.BrowserNodes
' If the node is visible and expanded, collapse it.
If oNode.Visible = True And oNode.Expanded = True Then
oNode.Expanded = False
End If
Next

 

Best wishes,

Péter

0 Likes
Message 6 of 6

adam.nagy
Autodesk Support
Autodesk Support

Just adding a note in this thread as well that the AddBorder() for a Zone Border issue seems to have been fixed for Inventor 2017.



Adam Nagy
Autodesk Platform Services