Error: Object Variable or With block variable not set

Error: Object Variable or With block variable not set

Anonymous
Not applicable
1,085 Views
4 Replies
Message 1 of 5

Error: Object Variable or With block variable not set

Anonymous
Not applicable

Please help. With this iLogic rule run as external rule, I am intermittently getting the error: Object Variable or With block variable not set with the codes below:

Sub Main()
Dim oDoc As Document
oDoc = ThisDoc.Document

Dim BORDERNAME as String
BORDERNAME=Parameter("KINZEBORDER") 
    Dim cd
    cd = ThisApplication.CommandManager.ControlDefinitions("DrawingBorderInsertNoDlgCtxCmd")
    
    Dim bp
    bp = ThisApplication.ActiveDocument.BrowserPanes("DlHierarchy")
    
    Dim node
    node = FindBorderNode(BORDERNAME, bp.TopNode.BrowserNodes)
    
    If Not ThisDoc.Document.ActiveSheet.Border Is Nothing Then
    ThisDoc.Document.ActiveSheet.Border.Delete
    End If
    
    node.DoSelect
    cd.Execute2 (True)
End Sub

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
 
0 Likes
1,086 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor

Hi,

 

What is the value of "

BORDERNAME=Parameter("KINZEBORDER") 

"

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 5

JelteDeJong
Mentor
Mentor

Hi, when i tryed your script it made inventor crash. Also i see a couple of things i dont understand. Anyway i think you try to set a border by a parameter. You could try this script.

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oBorder As Border = oSheet.Border
oBorder.Delete()
Dim borderName As String = KINZEBORDER

If (borderName = "Default Border") Then
    oSheet.AddDefaultBorder()
Else
    Dim oBorderDef As BorderDefinition = oDrawDoc.BorderDefinitions.Item(borderName)
    oSheet.AddBorder(oBorderDef)
End If

in this script i expect the default border is called "Default Border". That could be different in your language. if so you need to set it correct in the script.

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

Message 4 of 5

Anonymous
Not applicable

Thank you for your reply.

 

The value of 

BORDERNAME=Parameter("KINZEBORDER") 

is a multi value parameter with values of "KASSEMBLY", "KPART", "KGANGPART" AND "KGANGASSEMBLY".

I'm sorry it crashed your inventor session. I am using Inventor 2016. This code was given to me by Autodesk Help to work around the problem of using the  ActiveSheet.Border = Parameter ("KINZEBORDER") code which was setting border zones to value =0 and not displaying. This code was to simulate actually hitting the browser button to delete existing border and add the desired border. 

I will try your suggestion and let you know how it works.


Raj

0 Likes
Message 5 of 5

Anonymous
Not applicable

Unfortunately, the code provided by Jelte De Jong works but has the problem with border zones turning off. This is the same issue as using the "ActiveSheet.Border="NameofBorder"". Zones disappear when the border is placed into the drawing sheet.

 

With the codes for expanding the browser node and simulating the click even gives "Object variable or With block variable not set" error constantly.

 

0 Likes