VBA Command manager not excecuting

VBA Command manager not excecuting

nicholas_provo
Contributor Contributor
632 Views
4 Replies
Message 1 of 5

VBA Command manager not excecuting

nicholas_provo
Contributor
Contributor

Hey guys

 

I'm trying to add automatically bend tables to the flat patterns of metal sheets following this code below.

I also want the right BEND ID's on the drawing view. To do that you need to select the table and the view which needs the ID's and then force trough the command manager to add the ID's to the drawing.

 

Got it from the following topic:

https://forums.autodesk.com/t5/inventor-customization/bend-tags-to-view-add-tags-to-view/td-p/513977...

 

The function does everything correclty;

*it places the bend table, with the correct columns

*it also selects the table

*it also selects the right view to add the BEND ID to

But when I excecute the command "DrawingTableSelectBendViewCtxCmd" nothing happens.

I even checked the command with the EventWatcher program and it checks out.

Anyone have a clue what is going wrong? Working currently with INV2018.3

 

Many thanks!

 

 

Function Add_BendTable(ByRef oDrawingView As DrawingView, ByRef oModel As Document, ByRef oSheet As Sheet, ByRef oDrawingDoc As DrawingDocument)

Dim oPoint As Point2d
Dim oBendTable As CustomTable
Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(15, 15) ' ISO View (or current view)

If oModel.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
MsgBox ("A sheet metal document must be open.")
Exit Function
End If

Dim strColumns(1 To 4) As String
strColumns(1) = "BEND ID"
strColumns(2) = "BEND DIRECTION"
strColumns(3) = "BEND ANGLE"
strColumns(4) = "BEND RADIUS"

On Error GoTo ExitFunction
Set oBendTable = oSheet.CustomTables.AddBendTable(oModel.FullDocumentName, oPoint, "Bend Table", strColumns)

Dim oCtrlDef As ControlDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("DrawingTableSelectBendViewCtxCmd")

oDrawingDoc.SelectSet.Clear
oDrawingDoc.SelectSet.Select oBendTable
oDrawingDoc.SelectSet.Select oDrawingView
oCtrlDef.Execute

ExitFunction:

End Function

 

 

0 Likes
633 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor

Could you upload the complete code you are using?

 

The code where you declare:

oDrawingView As DrawingView

oModel As Document,

oSheet As Sheet,

oDrawingDoc As DrawingDocument

 

Regards,

 

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

nicholas_provo
Contributor
Contributor

Arthur

 

I exported the VBA code for you and added inventor Test files, should work stand alone.

I added into the attachment.

 

If you want to run the code stand alone on a unfolded sheet metal use this:

Just make a command button on a new forum sheet.

 

Thanks!

 

Private Sub CommandButton1_Click()


Dim oDrawingDoc As DrawingDocument
Set oDrawingDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
Set oSheet = oDrawingDoc.ActiveSheet

Dim oDrawingView As DrawingView
Set oDrawingView = oSheet.DrawingViews.Item(1)

Dim oModel As PartDocument
Set oModel = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument

Dim oPoint As Point2d
Dim oBendTable As CustomTable
Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(15, 15) ' ISO View (or current view)

If oModel.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
MsgBox ("A sheet metal document must be open.")
Exit Sub
End If

Dim strColumns(1 To 4) As String
strColumns(1) = "BEND ID"
strColumns(2) = "BEND DIRECTION"
strColumns(3) = "BEND ANGLE"
strColumns(4) = "BEND RADIUS"

'On Error GoTo Exitsub1
Set oBendTable = oSheet.CustomTables.AddBendTable(oModel.FullDocumentName, oPoint, "Bend Table", strColumns)

Dim oCtrlDef As ControlDefinition
Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("DrawingTableSelectBendViewCtxCmd")

oDrawingDoc.SelectSet.Clear
oDrawingDoc.SelectSet.Select oBendTable
oDrawingDoc.SelectSet.Select oDrawingView
oCtrlDef.Execute

'Exitsub1:


End Sub

 
0 Likes
Message 4 of 5

bradeneuropeArthur
Mentor
Mentor

This is my result!

 

Sheetmetal.PNG

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

nicholas_provo
Contributor
Contributor

Arthur

 

Correct, it's the same what is happening to me. But not quite yet the result we want.

You have to excute this on the 'Flat Pattern' of the metal sheet.

 

The result of the code should that the 'Bend ID' will be shown. On the flat pattern.

If you do it manually, you can create the same bend table:
Annotate/Table/General Table. You can see that Bend ID Displaying on the flat pattern.

 

When you use the code, it will force the same thing, but nothing happens with the bend ID.

The code below will select both views and force the Bend ID to be displayed on the flat pattern.

But when executing "DrawingTableSelectBendViewCtxCmd" nothing will happen.

"DrawingTableSelectBendViewCtxCmd" is the command code when you manually select the views, press right mouse button and select "Add Tags to View"

 

Dim oCtrlDef As ControlDefinition
Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("DrawingTableSelectBendViewCtxCmd")
oDrawingDoc.SelectSet.Clear
oDrawingDoc.SelectSet.Select oBendTable
oDrawingDoc.SelectSet.Select oSheet.DrawingViews.Item(1)
Call oCtrlDef.Execute

 

I'll attach 2 screenshots with the results.

 

 

 

grt
Nicholas

 

 

0 Likes