| | |
 | Gut zu wissen: Hilfreiche Tipps und Tricks aus der Praxis prägnant, und auf den Punkt gebracht für Autodesk Produkte |
| | |
 | NVIDIA GTC Paris und ISC High Performance-Konferenz 2025, eine Pressemitteilung
|
|
Autor
|
Thema: Flyoutmenü (1233 mal gelesen)
|
GeorgK Mitglied
  
 Beiträge: 619 Registriert: 06.06.2001
|
erstellt am: 20. Feb. 2015 09:04 <-- editieren / zitieren --> Unities abgeben:         
|
rkauskh Moderator Dipl.-Ing. (FH) Versorgungstechnik, Master Eng. IT-Security & Forensic
      

 Beiträge: 2933 Registriert: 15.11.2006 Windows 10 x64, AIP 2020-2025
|
erstellt am: 23. Feb. 2015 21:54 <-- editieren / zitieren --> Unities abgeben:          Nur für GeorgK
|
GeorgK Mitglied
  
 Beiträge: 619 Registriert: 06.06.2001
|
erstellt am: 24. Feb. 2015 12:56 <-- editieren / zitieren --> Unities abgeben:         
|
rkauskh Moderator Dipl.-Ing. (FH) Versorgungstechnik, Master Eng. IT-Security & Forensic
      

 Beiträge: 2933 Registriert: 15.11.2006 Windows 10 x64, AIP 2020-2025
|
erstellt am: 24. Feb. 2015 20:28 <-- editieren / zitieren --> Unities abgeben:          Nur für GeorgK
Hallo Ich hab nur was ähnliches finden können, aber vielleicht reicht es schon. Du mußt zuerst auf das OnContextMenu-Event lauschen.
Code: Private Sub CM_OnContextMenu(ByVal SelectionDevice As Inventor.SelectionDeviceEnum, ByVal AdditionalInfo As Inventor.NameValueMap, ByVal CommandBar As Inventor.CommandBar)
Wird das ausgelöst, ist das dritte Argument dein Kontextmenü. In das kannst du die ComboBox (hoffentlich) einfügen. Code: '*********************************************** ' Copy below code to a module Public oChangeMaterial As clsChangeMaterialPublic Sub CreateComboBox() ' Set a reference to the active document. ' This assumes that a part document is active. Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim oCommandMgr As CommandManager Set oCommandMgr = ThisApplication.CommandManager ' Set a reference to the collection of ControlDefinitions Dim oControlDefs As ControlDefinitions Set oControlDefs = oCommandMgr.ControlDefinitions On Error Resume Next ' Create a combobox definition Dim oComboBoxDef As ComboBoxDefinition Set oComboBoxDef = oControlDefs.Item("MaterialsComboBox") If oComboBoxDef Is Nothing Then Set oComboBoxDef = oControlDefs.AddComboBoxDefinition("Materials", "MaterialsComboBox", kNonShapeEditCmdType, 125, , "Materials Combo", "Materials") ' Set a reference to the materials collection. Dim oMaterials As Materials Set oMaterials = oDoc.Materials Dim oMaterial As Material For Each oMaterial In oMaterials ' Add material names to the combo box definition oComboBoxDef.AddItem (oMaterial.Name) Next ' Set a reference to the Part Standard toolbar Dim oPartFeatureToolbar As CommandBar Set oPartFeatureToolbar = ThisApplication.UserInterfaceManager.CommandBars.Item("PMxPartFeatureCmdBar") ' Add a combo box control to the toolbar Dim oComboBoxControl As CommandBarControl Set oComboBoxControl = oPartFeatureToolbar.Controls.AddComboBox(oComboBoxDef,1) oPartFeatureToolbar.Visible = True End If ' Clear current selection oComboBoxDef.ListIndex = 0 Set oChangeMaterial = New clsChangeMaterial oChangeMaterial.Initialize End Sub '************************************************************* ' The declarations and functions below need to be copied into ' a class module whose name is "clsChangeMaterial". The name ' can be changed but you'll need to change the declaration in ' the calling function "CreateComboBox" to use the new name.
Option Explicit Private WithEvents oComboBoxDef As ComboBoxDefinition Public Sub Initialize()
Dim oCommandMgr As CommandManager Set oCommandMgr = ThisApplication.CommandManager ' Set a reference to the collection of ControlDefinitions Dim oControlDefs As ControlDefinitions Set oControlDefs = oCommandMgr.ControlDefinitions ' Set a reference to the "MaterialsComboBox" combo box definition Set oComboBoxDef = oControlDefs.Item("MaterialsComboBox") End Sub Private Sub oComboBoxDef_OnSelect(ByVal Context As NameValueMap) If oComboBoxDef.ListIndex = 0 Then Exit Sub End If ' Get the selected item Dim oMaterialName As String oMaterialName = oComboBoxDef.ListItem(oComboBoxDef.ListIndex) ' Set a reference to the active part document Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim oPartCompDef As PartComponentDefinition Set oPartCompDef = oDoc.ComponentDefinition ' Get the selected material Dim oMaterial As Material Set oMaterial = oDoc.Materials.Item(oMaterialName) ' Change the part material oPartCompDef.Material = oMaterial End Sub
------------------ MfG Ralf  Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
GeorgK Mitglied
  
 Beiträge: 619 Registriert: 06.06.2001
|
erstellt am: 25. Feb. 2015 12:48 <-- editieren / zitieren --> Unities abgeben:         
|