- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How To Add a UserControl Or Userform to a DockableWindow in Inventor?
I have this sample but i would like to add labels; textboxes; etc to the Dockablewindow.
Dim oUserInterfaceMgr As UserInterfaceManager
oUserInterfaceMgr = ThisApplication.UserInterfaceManager
' Create a new dockable window
Dim oWindow As DockableWindow
oWindow = oUserInterfaceMgr.DockableWindows.Add("SampleClientId", "TestWindowInternalName", "Test Window")
' Get the hwnd of the dialog to be added as a child
' CHANGE THIS VALUE!
Dim hwnd As Long
hwnd = 4851096
' Add the dialog as a child to the dockable window
oWindow.AddChild(hwnd) Her I would like to add a UserControl or Userfrom!!!!!
' Don't allow docking to top and bottom
oWindow.DisabledDockingStates = DockingStateEnum.kDockTop And DockingStateEnum.kDockBottom
' Make the window visible
oWindow.Visible = TrueDoes anyone have a sample for this?
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Try this:
Private Sub AddToUserInterface()
Dim addInCLS As GuidAttribute
addInCLS = CType(System.Attribute.GetCustomAttribute(GetType(StandardAddInServer), GetType(GuidAttribute)), GuidAttribute)
addInCLSIDString = "{" & addInCLS.Value & "}"
Dim uiMgr As UserInterfaceManager = g_inventorApplication.UserInterfaceManager
Dim myDockableWindow As DockableWindow = uiMgr.DockableWindows.Add(addInCLSIDString, "MyWindow", "My Add-in Dock")
myDockableWindow.Visible = True
myDockableWindow.DockingState = DockingStateEnum.kDockRight
myDockableWindow.AddChild(CreateChildDialog())
myDockableWindow.DockingState = DockingStateEnum.kDockRight
myDockableWindow.Visible = True
End Sub
Public Function CreateChildDialog() As Long
If Not oForm Is Nothing Then
oForm.Dispose()
oForm = Nothing
End If
oForm = New projektcntr
oForm.Show()
Return oForm.Handle.ToInt64()
End Function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Thanks for the code.
Do you know if it is possible to add a Usercontrol (VB.net) to the DockableWindow too?
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i do not remember but you can add userform and turn off frames, maximalize, minimalize buttons and all and it will look like control. Mine look like this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Think that the UserControls are not modeless (showdialog), that is why it is not funcioning!
Thanks for your help!
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Any idea how to update the form with properties and values form the active document?
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
when i do that i receive en error.
could you send an example for me?
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Private Sub m_AppEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, _
ByVal BeforeOrAfter As Inventor.EventTimingEnum, _
ByVal Context As Inventor.NameValueMap, _
ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_AppEvents.OnActivateDocument
If BeforeOrAfter <> EventTimingEnum.kAfter Then
Exit Sub
End If
Dim odoc As Inventor.Document
odoc = g_inventorApplication.ActiveEditDocument
Dim eDocumentType As DocumentTypeEnum = odoc.DocumentType
Dim chb As CheckBox
Dim sDocumentType As String = "Unknown"
Select Case eDocumentType
Case DocumentTypeEnum.kAssemblyDocumentObject
For Each a As Control In oform.GroupBox1.Controls
If TypeOf a Is Windows.Forms.TextBox Then
a.Text = Nothing
End If
Next
Dim odef As AssemblyComponentDefinition = odoc.componentdefinition
Dim occ As ComponentOccurrence
For Each occ In odef.Occurrences
If TypeOf occ.Definition Is AssemblyComponentDefinition Then
' oForm.ComboBox1.Items.Add(occ.Name)
End If
Next
oform.TextBox1.Text = odef.Parameters.UserParameters.Item("height").Value * 10
oform.TextBox2.Text = odef.Parameters.UserParameters.Item("width").Value * 10
oform.TextBox3.Text = odef.Parameters.UserParameters.Item("depth").Value * 10
oform.TextBox4.Text = odef.Parameters.UserParameters.Item("front_bolt_qty").Value
oform.TextBox5.Text = odef.Parameters.UserParameters.Item("front_bolt_distance").Value * 10
oform.TextBox6.Text = odef.Parameters.UserParameters.Item("top_bottom_bolt_qty").Value
oform.TextBox7.Text = odef.Parameters.UserParameters.Item("top_bottom_bolt_distance").Value * 10
oform.GroupBox1.Text = odoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value
For idx = 1 To oform.GroupBox1.Controls.Count
chb = oform.GroupBox1.Controls.Item(idx)
If odoc.PropertySets.Item("Inventor User Defined Properties").Item(oform.GroupBox1.Controls.Item(idx).Text).Value = "1" Then
chb.Checked = 1
Else
chb.Checked = 0
End If
Next
' sDocumentType = "Assembly Document"
' oForm.ComboBox1.Items.Clear()
' oForm.TextBox1.Text = ""
Case DocumentTypeEnum.kPartDocumentObject
sDocumentType = "Part Document"
Dim opdef As PartComponentDefinition = odoc.componentdefinition
For Each a As Control In oform.GroupBox1.Controls
If TypeOf a Is Windows.Forms.TextBox Then
a.Text = Nothing
End If
Next
oform.GroupBox1.Text = odoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value
For idx = 1 To oform.GroupBox1.Controls.Count
chb = oform.GroupBox1.Controls.Item(idx)
If odoc.PropertySets.Item("Inventor User Defined Properties").Item(oform.GroupBox1.Controls.Item(idx).Text).Value = "1" Then
chb.Checked = 1
Else
chb.Checked = 0
End If
Next
oform.TextBox1.Text = opdef.Parameters.UserParameters.Item("height").Value * 10
oform.TextBox2.Text = opdef.Parameters.UserParameters.Item("width").Value * 10
oform.TextBox3.Text = opdef.Parameters.UserParameters.Item("depth").Value * 10
oform.TextBox4.Text = opdef.Parameters.UserParameters.Item("front_bolt_qty").Value
oform.TextBox5.Text = opdef.Parameters.UserParameters.Item("front_bolt_distance").Value * 10
oform.TextBox6.Text = opdef.Parameters.UserParameters.Item("top_bottom_bolt_qty").Value
oform.TextBox7.Text = opdef.Parameters.UserParameters.Item("top_bottom_bolt_distance").Value * 10
End Select
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How to prevent the userform from scaling weird.
I am missing the buttons and the other controls on it because is scaled wierd...
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
@bradeneuropeArthur wrote:Think that the UserControls are not modeless (showdialog), that is why it is not funcioning!
You can use UserControl also.
Following app which I made uses UserControl instead of Form. (See the video on the page)
https://apps.autodesk.com/INVNTOR/en/Detail/Index?id=2638190254159513577&appLang=en&os=Win64
Keep mind that the dockable window with user control may have trouble about control keys such as 'Enter' or 'Tab'.
Dockable window with user control is not catching enter key press?
I wrote the difference between Form and UserControl in the above thread.
=====
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @HideoYamada @marcin_otręba ,
Any idea how to be sure that the userform or the usercontrol scales to the Dockable window?
At the moment the Userform scales weird (to large) and does not fit the Dockable Window size.
I have set the userform to a fix height and now the buttons are visible, but is this the correct way of preventing the UserForm or UserControl from scaling?
What are the correct dimensions (Weight and Width) for the UserFrom or UserControl?
Thank you for the support on this,
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
@bradeneuropeArthur wrote:Any idea how to be sure that the userform or the usercontrol scales to the Dockable window?
Are you saying that the content of your dockable window isn't resized when the dockable window is resized?
Try change the border style of userform or usercontrol to none.
=====
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
you can use dockablewindow.width and height to set up your form width and height onload, also you can use dockablewindow.SetMinimumSize functionality, i assume that in your form you have correct anchors and settings for its content.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The UserForm or UserControl becomes to large in the Dockable window and the bottons are out of the field, you understand?
I need to take a look at the Anchors!!! @marcin_otręba
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
At what moment do you add the oForm to the DockableWindow?
- on ActivateDocument?
- on initialize the add in?
Can't get this to work since I cannot update the created form on activate document!
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
The UserForm or UserControl becomes to large in the Dockable window and the bottons are out of the field, you understand?I need to take a look at the Anchors!!! @marcin_otręba
Yes i understand! also it would be nice if you could attach some scren showing your situation.
I always try to design my forms in size wchich they will appear. Also content should be achored to side in wchich dockable window will be docked.
At what moment do you add the oForm to the DockableWindow?
I have it is couple of my addins and it is added :
1. on custom button click
2. as i showed in my first answer - on addtouserinterface:
Private Sub AddToUserInterface()
Dim addInCLS As GuidAttribute
addInCLS = CType(System.Attribute.GetCustomAttribute(GetType(StandardAddInServer), GetType(GuidAttribute)), GuidAttribute)
addInCLSIDString = "{" & addInCLS.Value & "}"
Dim uiMgr As UserInterfaceManager = g_inventorApplication.UserInterfaceManager
Dim myDockableWindow As DockableWindow = uiMgr.DockableWindows.Add(addInCLSIDString, "MyWindow", "My Add-in Dock")
myDockableWindow.Visible = True
myDockableWindow.DockingState = DockingStateEnum.kDockRight
myDockableWindow.AddChild(CreateChildDialog())
myDockableWindow.DockingState = DockingStateEnum.kDockRight
myDockableWindow.Visible = True
End Sub3.on assembly doc activate.
Can't get this to work since I cannot update the created form on activate document! - what do you mean?
if you dont want to shear on forum you can write me message or something, also if you could describe what you want to acomplish, i think i have alot of experience with dockable windows and i propably did it already. I use them almost on all possible document events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you @marcin_otręba
I got it working.
- Step one is to declare the Userform as a Public new form to the StandardAddInServer:
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
' Inventor application object.
Private m_inventorApplication As Inventor.Application
Private m_ClientID As String
Public m_Form As StartFormulier
- Then on the document event I am the first time adding the userform to the DockableWindow:
Private Sub m_AppEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_AppEvents.OnActivateDocument If BeforeOrAfter = EventTimingEnum.kAfter Then m_Form.Show() Dim docw As DockableWindow Try docw = m_inventorApplication.UserInterfaceManager.DockableWindows.Add("1234xyz", "1234yyz", "My Dockabel Window") docw.AddChild(m_Form.Handle.ToInt64) Catch ex As Exception End TryNow I am able to access the m_form as I need.
m_Form.Text = DocumentObject.DisplayName
m_form.....Etc Etc
The form is used to display and edit the Company mandatory I-properties.
Any better suggestions from your side to accomplish this?
Regards
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I did something like that, i used onactivatedocument(here i used ActiveEditDocument) and onpreselectevents - here i run code if selected entity was comp occurrence and count was =1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
A "fine tuning" question.
How to prevent the shown UserForm from being shortly visible in the inventor screen when the DockableWindow is created.
The Userform is very short visible before it is added to the Dockable window.
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !