Das ist der Code aus VB.NET des AddIn's ich möchte damit eine Form (Schriftfeld1) aufrufen:
Imports Inventor
Imports System.Runtime.InteropServices
Namespace Schriftfeld
<ProgId("Schriftfeld.StandardAddInServer"), _
GuidAttribute("DB5A79C7-64BC-481B-B06C-1131B17CB13B")> _
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
Private WithEvents oButtonDef As ButtonDefinition
#Region "Data Members"
Dim InventorApplication As Inventor.Application
#End Region
#Region "ApplicationAddInServer Members"
Public Sub Activate(ByVal AddInSiteObject As Inventor.ApplicationAddInSite, ByVal FirstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate
'the Activate method is called by Inventor when it loads the addin
'the AddInSiteObject provides access to the Inventor Application object
'the FirstTime flag indicates if the addin is loaded for the first time
'initialize AddIn members
InventorApplication = AddInSiteObject.Application
oButtonDef = InventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition("Schriftfeld1", "SchriftfeldCmdIntName1", CommandTypesEnum.kQueryOnlyCmdType, "{DB5A79C7-64BC-481B-B06C-1131B17CB13B}", "Schriftfeld einfügen/bearbeiten", "Schriftfeld einfügen/bearbeiten")
oButtonDef.Enabled = True
' TODO: Add ApplicationAddInServer.Activate implementation
'e.g. event initialization, command creation etc.
If FirstTime = True Then
Dim ocommandbar As CommandBar
ocommandbar = InventorApplication.UserInterfaceManager.CommandBars.Add("ZeichnungSchriftfeld1", "ZeichnungIntName1", , "{DB5A79C7-64BC-481B-B06C-1131B17CB13B}")
ocommandbar.Controls.AddButton(oButtonDef)
ocommandbar.PanelBar.CommandBarList.Add(oButtonDef)
ocommandbar.Visible = True
End If
End Sub
Public Sub Deactivate() Implements Inventor.ApplicationAddInServer.Deactivate
'the Deactivate method is called by Inventor when the AddIn is unloaded
'the AddIn will be unloaded either manually by the user or
'when the Inventor session is terminated
' TODO: Add ApplicationAddInServer.Deactivate implementation
'e.g. command deletion
'release objects
Marshal.ReleaseComObject(InventorApplication)
oButtonDef.Delete()
oButtonDef = Nothing
InventorApplication.UserInterfaceManager.CommandBars.Item("Zeichnung").Delete()
InventorApplication = Nothing
System.GC.WaitForPendingFinalizers()
System.GC.Collect()
InventorApplication = Nothing
End Sub
Public ReadOnly Property Automation() As Object Implements Inventor.ApplicationAddInServer.Automation
'if you want to return an interface to another client of this addin,
'implement that interface in a class and return that class object
'through this property
Get
Return Nothing
End Get
End Property
Public Sub ExecuteCommand(ByVal CommandID As Integer) Implements Inventor.ApplicationAddInServer.ExecuteCommand
'this method was used to notify when an AddIn command was executed
'the CommandID parameter identifies the command that was executed
'Note:this method is now obsolete, you should use the new
'ControlDefinition objects to implement commands, they have
'their own event sinks to notify when the command is executed
End Sub
#End Region
#Region "COM Registration"
' Registers this class as an Add-In for Autodesk Inventor.
' This function is called when the assembly is registered for COM.
<System.Runtime.InteropServices.ComRegisterFunction()> _
Public Shared Sub RegisterFunction(ByVal t As Type)
'call the method in the AddInRegistration class to register the AddIn
AddInRegistration.RegisterInventorAddIn(t)
End Sub
' Unregisters this class as an Add-In for Autodesk Inventor.
' This function is called when the assembly is unregistered.
<System.Runtime.InteropServices.ComUnregisterFunction()> _
Public Shared Sub UnregisterFunction(ByVal t As Type)
'call the method in the AddInRegistration class to unregister the AddIn
AddInRegistration.UnregisterInventorAddIn(t)
End Sub
#End Region
Private Sub oButtonDef_OnExecute(ByVal context As Inventor.NameValueMap) Handles oButtonDef.OnExecute
If InventorApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
'MsgBox("test")
Schriftfeld1.ActiveForm.Show()
End Sub
End Class
End Namespace
Hoff dass das mehr bringt?
Die Reg Datei ist die Selbe wie von den VB Beispielen von IV nur ich hab die ID's und die Beschreibung ausgebessert!
Danke
mfg Bernhard
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP