There is no DefaultBorder object in a DrawingDocument: true or false?

There is no DefaultBorder object in a DrawingDocument: true or false?

DavidWHouse
Enthusiast Enthusiast
1,070 Views
12 Replies
Message 1 of 13

There is no DefaultBorder object in a DrawingDocument: true or false?

DavidWHouse
Enthusiast
Enthusiast

So, I just don't get it, and I can't find it.

The official documentation available to me shows both a simple method of creating a default border ("Set oBorder = oSheet.AddDefaultBorder()") and a more involved method (in "Public Sub InsertDefaultBorder()"). However, neither the Sheet.Border object, nor the DrawingDocument.BorderDefinitions object actually contain a DefaultBorder object anywhere; at least anywhere I can find. Sure, they have BorderDefinition objects, but those objects, to take just one example, do not have a BorderLabelModeEnum property, among several others. (To mention it again, see "Public Sub InsertDefaultBorder()" for more examples of DefaultBorder properties not in evidence in either Border or BorderDefinition objects.)

So, BorderDefinition <> DefaultBorder <> Border, and I cannot find any information about where the mythical BorderDefinition object ends up living, either in the DrawingDocument or in the drawing template files. Further, spelunking through the objects and properties available in those objects, there is nothing that appears to me to be (as it were) the object of my quest.

Further, while the twice-referenced standard InsertDefaultBorder sub shows a call that creates a default border, the last three properties referenced therein (BorderLineWidth, TextLabelHeight, and Font) are not properties of the DefaultBorder object, at least as far as my journey through any object defined as, shows me.

 

As well, calling the border.delete method on the "Default Border" appears to have no effect.

So what's the deal? How can one find the DefaultBorder object in a DrawingDocument (if that's where it lives), and when one finds that DefaultBorder object, where do the three apparently non-attached properties live?

 

Once I can find that object and the three associated properties, my assumption is that if nothing else, I can use the process shown  in InsertDefaultBorder() (where I am getting the property values from the object I have found instead of hard-coding them), to re-define the "Default Border" object. Is that correct?

0 Likes
Accepted solutions (2)
1,071 Views
12 Replies
Replies (12)
Message 2 of 13

HermJan.Otterman
Advisor
Advisor

did you look at the API help?

 

to place the Default Border there is an example: (VBA)

 

Public Sub InsertDefaultBorderUsingDefaults()
    ' 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
    
    ' Add the border to the sheet.
    Dim oBorder As DefaultBorder
    Set oBorder = oSheet.AddDefaultBorder()
End Sub

 It tested it (with vb.net) and it works

there should not be a border, you can only place one

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 13

DavidWHouse
Enthusiast
Enthusiast

Thanks for your reply. And yes, I did look, and the code you reference is echoed in my post:

 Set oBorder = oSheet.AddDefaultBorder()

As I said, one can create a DefaultBorder object. Having created it, where is it??

0 Likes
Message 4 of 13

MechMachineMan
Advisor
Advisor

Hi,

 

BorderDefinitions can be thought of as instructions to make a border. They exist in the DRAWING DOCUMENT as a definition. They can be used to generate a border. The default ALWAYS exists in this collection as item 1, and cannot be deleted; not through the UI nor API.

 

When a border is ADDED (using the definition) it gets applied to the SHEET, where it is stored. It is not found directly under the drawing document.

 

Take a look at the object model for inventor and you will understand things better.

 

Follow the Autodesk online help link in my signature and search for the object model there.


--------------------------------------
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 5 of 13

DavidWHouse
Enthusiast
Enthusiast

Thank you for your reply. I do understand the difference between BorderDefinition(s) and Border objects, and that the DefaultBorder object is added to the Sheet object, which I assumed that others would know is within the DrawingDocument.

And I have used the code offered and referenced and mentioned to create a "Default Border".

But the Border object which exists in a Sheet object which exists in a DrawingDocument object IS NOT A DefaultBorder OBJECT, as I mentioned.

The problem is not creating such an object-- like you, I can do that easily-- but finding it after creation. None of the Border[whatever] objects that I mention above, in any of the places I mention above, are a DefaultBorder object. Not one.

But perhaps my explanation is not sufficient. Below is code derived from InsertDefaultBorder(), which as you know is part of the standard code bits supplied by Autodesk. I have modified it to clearly illustrate what I am talking about, by including an object to be passed in which is a DefaultBorder object. I would urge you to paste it into a module and fiddle with it, and you will see that, as I have said, the DefaultBorder object is not like any of the other Border[whatever] objects. Completely <>.

 

Public Sub addDefaultBorderToSheet(objDrawingFile As DrawingDocument, objBorderDefToUse As DefaultBorder)
    Dim objSheet As Sheet
Dim objBorder as Border ' ' ' ##### Check to see if any sheets exist, add one if not. ' But for the moment... Set objSheet = objDrawingFile.Sheets.Item(1) ' ' _Derive_ the values to use as input for the default border creation ' FROM THE MYTHICAL DefaultBorder OBJECT ' Dim HorizontalZoneCount As Long HorizontalZoneCount = objBorderDefToUse.HorizontalZoneCount ' Dim HorizontalZoneLabelMode As BorderLabelModeEnum HorizontalZoneLabelMode = objBorderDefToUse.HorizontalZoneLabelMode ' Dim VerticalZoneCount As Long VerticalZoneCount = objBorderDefToUse.VerticalZoneCount ' Dim VerticalZoneLabelMode As BorderLabelModeEnum VerticalZoneLabelMode = objBorderDefToUse.VerticalZoneLabelMode ' Dim LabelFromBottomRight As Boolean LabelFromBottomRight = objBorderDefToUse.LabelFromBottomRight ' Dim DelimitZonesByLines As Boolean DelimitZonesByLines = objBorderDefToUse.DelimitZonesByLines ' Dim CenterMarks As Boolean CenterMarks = objBorderDefToUse.CenterMarks ' Dim TopMargin As Double TopMargin = objBorderDefToUse.TopMargin ' Dim BottomMargin As Double BottomMargin = objBorderDefToUse.BottomMargin ' Dim LeftMargin As Double LeftMargin = objBorderDefToUse.LeftMargin ' Dim RightMargin As Double RightMargin = objBorderDefToUse.RightMargin ' Dim BorderLineWidth As Double BorderLineWidth = 0.1 ' ##### No such property in objBorderDefToUse?? ' Dim TextLabelHeight As Double TextLabelHeight = 1.5 ' ##### No property?? ' Dim Font As String Font = "Courier New" ' ##### No property?? ' ' Add the border to the sheet. Set objBorder = objSheet.AddDefaultBorder(HorizontalZoneCount, HorizontalZoneLabelMode, _ VerticalZoneCount, VerticalZoneLabelMode, _ LabelFromBottomRight, DelimitZonesByLines, _ CenterMarks, TopMargin, BottomMargin, _ LeftMargin, RightMargin, BorderLineWidth, _ TextLabelHeight, Font) End Sub

 

Unless, unlike me, you can take a DrawingDocument and derive a DefaultBorder object from somewhere inside of it, then you will not be able to elegantly run the code above because you will have to construct a DefaultBorder object by hand, by hardcoding values in the simplest instance, before you will be able to pass that object into the Sub above. And that makes no sense, at least to a programmer. I want to find it in my template, and re-create it in my drawings. Right?

Again, once created, Where Is It?

Thus, do forgive me for repeating myself:

How can one find the DefaultBorder object in a DrawingDocument (if that's where it lives), and when one finds that DefaultBorder object, where do the three apparently non-attached properties live?

 

Once I can find that object and the three associated properties, my assumption is that if nothing else, I can use the process shown  in InsertDefaultBorder() (where I am getting the property values from the object I have found instead of hard-coding them), to re-define the "Default Border" object. Is that correct?

 
0 Likes
Message 6 of 13

MechMachineMan
Advisor
Advisor
Accepted solution

I believe all of the default border stuff is hardcoded in.

 

Instead of making changes to the default border, just make a different border definition to use. That could be done by copying the default border and changing items, or just doing so from scratch.

 

At either rate, I think trying to change the default border's contents is like trying to put a screw into a board with a hammer.


--------------------------------------
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 13

HermJan.Otterman
Advisor
Advisor
Accepted solution

the Border IS the default Border

 

 

Dim oDrawDoc As DrawingDocument = Thisapplication.ActiveDocument

Dim oSheet As Sheet = oDrawDoc.ActiveSheet

Dim Border_Deafault As DefaultBorder = oSheet.Border

'Dim Border As Border = oSheet.Border

MsgBox(Border_Deafault.Name.ToString)

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 8 of 13

DavidWHouse
Enthusiast
Enthusiast

@MechMachineMan wrote:

I believe all of the default border stuff is hardcoded in.

 

Instead of making changes to the default border, just make a different border definition to use. That could be done by copying the default border and changing items, or just doing so from scratch.

 

At either rate, I think trying to change the default border's contents is like trying to put a screw into a board with a hammer.


I think what you might also mean is that, yes, there is no object provided by the API that allows one to retrieve a default border; you can only create one. That's a bit like "write only" memory.

Hardcoded, yes, apparently. Hammers and screws, yes, given the lack of any alternative. But of course it's not physics as established in the genetics of the universe; it's an API, created by programmers and open to change.

And beyond that, the problem also extends, at least as far as I can discover, to zone borders. There appears to be no zone border object. As such, for example, there is no way to examine all properties of a zone border, which the default border usually (always, I guess) is.

Appreciated. On to another difficulty.

 

d.

0 Likes
Message 9 of 13

DavidWHouse
Enthusiast
Enthusiast

@HermJan.Otterman wrote:

the Border IS the default Border

 

In one sense, yes, it is, given that the API appears to be deficient in this area and so one has no other choice. In another sense, no, definitively not; not even close.

At least according to the official docs, the DefaultBorder object has 17 properties. The Border object has 6. If your code works in VB, congratulations; I don't understand how the cast takes place from one object to the the other, but I assume you are implying that it works. It would be interesting to see whether some of the properties that are not supported by the Border object are present in the DefaultBorder object you have created. (I guess I'll have to fire up VS.)

 

All that said, in VBA, it fails:

 

Public Sub tryDefaultBorder()
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
        '
    Dim oSheet As Sheet
    oSheet = oDrawDoc.ActiveSheet
        '
    Dim Border_Default As DefaultBorder
    Border_Default = oSheet.border
        '   Dim Border As Border = oSheet.Border
    MsgBox (Border_Default.Name)
End Sub


Again, thanks for your input. I keep trying to learn.

d.

 

0 Likes
Message 10 of 13

DavidWHouse
Enthusiast
Enthusiast

Weird.

It works in VB .NET, and it fails in VBA. I have not tried it, but I imagine, given the properties I'm seeing in VS for the DefaultBorder object, that I could actually look at a zone border object as well.

Who knew. I think this is an oversight/error in the VBA API: Using VBA, there is no DefaultBorder object in a DrawingDocument, and there is no way to inspect the "Default Border" object's complete property set, whether one tries to derive that object from DrawingDocument.BorderDefinitions or from Sheet.Border.

0 Likes
Message 11 of 13

HermJan.Otterman
Advisor
Advisor

Hello David,

 

I don't use VBA for programming, only VS and ilogic.

But I do use VBA to watch the object structure.

 

these pictures are from VBA

 

1.png

 

2.png

 

from VS:

 

3.png

 

 

 

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 12 of 13

DavidWHouse
Enthusiast
Enthusiast

OK, it turns out that it's a bit nuanced.

You can get a DefaultBorder object from a DrawingDocument (in VBA!), but only if at least one Sheet object therein already has a DefaultBorder object. If it does not have one, it will not accept a new DefaultBorder object using AddDefaultBorder()! (AddBorder(), when fed a DefaultBorder object, appears to work.)

That is, even one of the standard "Insert default border' VBA code examples provided by Autodesk ("InsertDefaultBorder") will fail where it is run using a sheet which does not already have a zone-type border.

At least in VBA. It works in VB NET.

Yeah, but maybe this is not clear. So far I'm not having much luck getting my point across. So try this, HermJan, using the empty drawing document that I will try to attach to this post:

 

 

Public Sub tryThisHey()
    Dim objDrawingDocument As DrawingDocument
    Set objDrawingDocument = ThisApplication.ActiveDocument
        '
    Dim objSheet As Sheet
    Set objSheet = objDrawingDocument.ActiveSheet
        '
    Dim objDefaultBorder As DefaultBorder
    Set objDefaultBorder = objSheet.border ' Works here, but _only_ if the sheet has a 'zoned' border
        '
    If Not objDefaultBorder Is Nothing Then
        objDefaultBorder.Delete
    End If
        '    Grab a 'simple' border from the definitions and put it in the sheet object
    Call objSheet.AddBorder(objDrawingDocument.BorderDefinitions.Item("Simple Border"))
        '
    Dim objOrdinaryBorder As border
    Set objOrdinaryBorder = objSheet.border ' Examine the border object: it is NOT a DefaultBorder object
        '
    Set objDefaultBorder = objSheet.border ' Fails! ("Type mismatch") Whereas, it worked just above!
End Sub

 

0 Likes
Message 13 of 13

DavidWHouse
Enthusiast
Enthusiast

My mistake. The code provided fails because the ordinary border is not deleted before a call to create a new default border, not because there is a more fundamental problem. 

 

That is a tyro error, but my confusion was fueled by the fact that the code provided in the API help file (addDefaultBorderToSheet), on which I was relying, is wrong, (at least as it concerns the object model for AI 2018). That code, at its bottom, says:

 

    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)

 

I have boldfaced the last thee parameters. As I stated in my first post, none of those parameters is available in a DefaultBorder object. At that time, I did not know why. The reason is that they neither exist in the object, and the call as written above will fail, because it is flatly wrong.

 

Note that the API says that the AddDefaultBorder method (when all optional parameters are used) should actually look like this:

 

 

 

    Set oBorder = oSheet.AddDefaultBorder(HorizontalZoneCount, HorizontalZoneLabelMode,  _
                                          VerticalZoneCount, VerticalZoneLabelMode,  _
                                          LabelFromBottomRight, DelimitByLines,  _
                                          Centermarks, TopMargin, BottomMargin,  _
                                          LeftMargin, RightMargin, TextStyle,  _
                                          TextLayer, LineLayer)

 

 

That is, the last three call parameters are entirely different. The API is correct, and the code is wrong. Confusingly, the API says that all the call parameters are of type Variant, whereas the code offers a completely different set of variable types, even for what are apparently the same variables. I have not looked at this, but I think the code may be right about the variable types, and the API may be wrong. More confusion.

 

In any case, again, I was wrong: When the correct parameters are used, the AddDefaultBorder method works. It just does not work if you use the code provided by Autodesk in the API help file.

 

As well, given that all of the BorderDefinition objects are for ordinary, not zoned borders, I was correct in saying that one cannot derive a DefaultBorder object from any BorderDefinition object, not even from the [hardcoded] "Default Border" found in that collection.

 

However, if you want a DefaultBorder object with the default parameters, you can get one by working on a sheet that does not have a border, and calling the AddDefaultBorder method on it, but without using any arguments. (All arguments thereto are optional.) Thus, for example, you can create a new sheet (newly created sheets have no borders), put a default border on it, then work with that object to query, obtain, and/or modify any of its parameters.

 

I hope this clears the matter up once and for all.

 

 

0 Likes