Hi,
nein, nein, nein, ...
Jetzt nochmal ganz langsam. Ich habe eine Form1 und ein Modul1. Im Modul1 sind die 4 Subs für Inventor
deklariert, und die einfache Funktion die meine Form1 zeigen soll:
Option Explicit
Implements ApplicationAddInServer
Dim oApp As Inventor.Application
Dim oCmd1 As Command
Dim oCmd2 As Command
Private Sub ApplicationAddInServer_Activate(ByVal AddInSiteObject As Inventor.ApplicationAddInSite, ByVal FirstTime As Boolean)
' Save a reference to the Application object.
Set oApp = AddInSiteObject.Application
' Create the first command.
Set oCmd1 = AddInSiteObject.CreateCommand("bittebitte", 1, True)
' Create the second command.
Set oCmd2 = AddInSiteObject.CreateCommand("Toggle 1", 2, True)
End Sub
Private Property Get ApplicationAddInServer_Automation() As Inventor.AddInAutomation
'Online Hilfe sagt dass ich hier was reinschreiben soll, sonst würde die Funktion beim compilieren entfernt
End Property
Private Sub ApplicationAddInServer_Deactivate()
' Release all references.
Set oCmd1 = Nothing
Set oCmd2 = Nothing
Set oApp = Nothing
End Sub
Private Sub ApplicationAddInServer_ExecuteCommand(ByVal CommandID As Long)
' Check to see which command was run.
Select Case CommandID
Case 1
ZeigeForm1
Case 2
' Toggle the enabled state of command 1.
If oCmd1.Enabled Then
oCmd1.Enabled = False
Else
oCmd1.Enabled = True
End If
End Select
End Sub
Private Sub ZeigeForm1()
Form1.Show 1
End Sub
Und in Form1 passiert nichts anderes als :
Private Sub Command1_Click()
InsertBox
End Sub
Ich könnte auch den Code von InsertBox in die Command_Click reinschreiben, aber hier is das unwichtig. Wenn ich die
InsertBox in den Modul1 deklariere und in Command1_Click "Modul1." reinschreibe erscheint nicht als "eingenschaft" InsertBox
( komisch, oder ? ), beim laufen stürtzt das Program da ab. Deklariere ich es inerhalb Form1, dann fehlt mir das Objekt
( vermutlich oApp ). Kann ich aus den Modul1 oApp als Parameter an die form übergeben so dass es dann in der InsertBox
verfügbar ist ? Und überhaupt ist die InsertBox so richtig:
Public Sub InsertBox()
Dim doc As Document
Set doc = oApp.ActiveDocument
Dim dte As DocumentTypeEnum
dte = doc.DocumentType
' check document type
If dte = kAssemblyDocumentObject Then
' Push the filename onto the Inventor clipboard
Call oApp.CommandManager.PostPrivateEvent(kFileNameEvent, "D:\temp\box.ipt")
' Start the Insert iFeature command
Call oApp.CommandManager.StartCommand(kPlaceComponentCommand)
Else
MsgBox "Please open an assembly document"
End If
End Sub
Eigendlich sollte ich oApp von Modul1 an die Form1 übergeben, und dann irgendwie nach den Click Ereignis an die InsertBox
übergeben. Das kliengt alles irgendwie falsch, oder ?
Naja, vielleicht seht Ihr hier etwas was ich nicht sehe, ( oder so ) .
Grundsätzlich sind ein Paar Fragen offen
1. wo deklariere ich die InsertBox so das oApp greifbar ist
2. ist die Funktion InsertBox so richtig
3. und wie übergebe ich die Parameter wenn ich eine zwischenstation, wie Form1, habe
Grüße
daywa1k3r
Das Leben ist ein kack-Spiel, aber die Grafik ist geil
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP