Hi VBAler,
es ist ja nicht so, daß alles schon optimal ist...
Da hatte ich doch die Idee, dass wenn ich in einer idw die Bemaßung vornehme, ich gerne Vorschläge für Toleranzen im Kontextmenü sehen möchte.
Unter http://forums.autodesk.com/autodesk/attachments/autodesk/120/21882/1/ContextMenu.txt habe ich ein Grundstruktur gefunden, auf dem ich aufbauen könnte (siehe Code 1):
Was ich schon (mühsam) herausgefunden habe, ist, dass wenn ich Linien auswähle für eine Bemaßung, ich statt des Absetzen der Maßlinie das Kontextmenü anwählen kann.
Dort steht (bei mir) an zweiter Position
"Pfeilspitzen innen" , also der Commmand DrawingDiameterDimensionArrowheadsInsideCtxC. Der Command paßt gut zur Identifikation des Kontexmenüs (siehe unten...)
Ich möchte:
1. gerne ein eigenes Makro ausführen, dass in default.ivb liegt, statt ein Command von Inventor auszuführen.
2. die Parameterliste des Bauteile auslesen, um alle Maße mit Toleranzangaben zu erhalten.
(Wenn das Bauteil aktiv WÄRE, ist das mit dem 2. Code möglich. Da ich ja in einer Zeichnung bin, weiß ich nicht, wie ich an die Parameterliste(n) der Bauteile der Zeichnung komme)
3. Das ausgewählte, nicht abgesetzte Maß auswerten kann, um aus der Paramterliste eine/die passende Toleranz zu dem Maß auszuwählen und als Button anzuzeigen.
(Bei zwei gleichen Maßen z.B. 100H7 und 100e8 müßte beides gezeigt werden, denn der Benutzer kann ja über das angewählte Kontextmenü die richtige Toleranz auswählen)
4. das eigene Makro, welches das Maß absetzt (wahrscheinlich ein mir unbekannter Command) dann aber die Toleranz gemäß der gewählten Toleranz setzt.
Soweit meine (mal wieder) hochfliegenden Visionen....
Ich würde mich riesig freuen, wenn Ihr mir Tipps geben könntet, wie ich an die Objekte komme. Die Fleißaufgabe der Parameterauswahl kann ich schon machen und wieder ins Netz stellen, schließlich wäre das Feature ein echter Gewinn! (finde ich zumindest)
Viele Frühlingsgrüße,
Stefan
Code 1:
Code:
'This sample demonstrates the addition of a control to the context menu.'************************************************************
' Copy the following into a Module.
Option Explicit
Public oClass1 As Class1
Sub AddToMenu()
Set oClass1 = New Class1
oClass1.Initialize
End Sub
'*************************************************************
' The declarations and functions below need to be copied into
' a class module whose name is "Class1". The name
' can be changed but you'll need to change the declaration in
' the calling function "AddToMenu" to use the new name.
'Option Explicit
'Private WithEvents oUserInputEvents As UserInputEvents
'Public Sub Initialize()
' Set oUserInputEvents = ThisApplication.CommandManager.UserInputEvents
'End Sub
Private Sub oUserInputEvents_OnContextMenu(ByVal SelectionDevice As SelectionDeviceEnum, ByVal AdditionalInfo As NameValueMap, ByVal CommandBar As CommandBar)
On Error Resume Next
' Check if the context menu has the 'Isometric View' command
Dim oCmdBarControl As CommandBarControl
Set oCmdBarControl = CommandBar.Controls.Item("DrawingDiameterDimensionArrowheadsInsideCtxCmd")
If Not oCmdBarControl Is Nothing Then
Dim oCtrlDef As ControlDefinition
Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomAllCmd")
' Add the "Zoom All" command before the isometric view command
Call CommandBar.Controls.AddButton(oCtrlDef, oCmdBarControl.index)
End If
End Sub
2. Code:
Code:
Public Sub ModelParameters()
' Obtain the active document, this assumes
' that a part document is active in Inventor.
Dim oPartDoc As Inventor.PartDocument
Set oPartDoc = ThisApplication.ActiveDocument ' Obtain the Parameters collection
Dim oParams As Parameters
Set oParams = oPartDoc.ComponentDefinition.Parameters
' Iterate through the Parameters collection to obtain
' information about the Parameters
Dim iNumParams As Long
' Obtain the Model Parameters collection
Dim oModelParams As ModelParameters
Set oModelParams = oParams.ModelParameters
' Iterate through the Model Parameters collection
Dim iNumModelParams As Long
Debug.Print "MODEL PARAMETER VALUES"
For iNumModelParams = 1 To oModelParams.count
If oModelParams.Item(iNumModelParams).Tolerance.ToleranceType <> kDefaultTolerance Then
' Display the Name
Debug.Print " Name:" & oModelParams.Item(iNumModelParams).Name & " = " & oModelParams.Item(iNumModelParams).Value * 10
' Display the ToleranceType
Debug.Print " ToleranceType: " & oModelParams.Item(iNumModelParams).Tolerance.ToleranceType
' Display the tolerance Tolerance.ToleranceType Property
Debug.Print " HoleTolerance: " & oModelParams.Item(iNumModelParams).Tolerance.HoleTolerance & ":" & Round(10 * oModelParams.Item(iNumModelParams).Tolerance.Upper, 3) & ":" & Round(10 * oModelParams.Item(iNumModelParams).Tolerance.Lower, 3)
End If
Next iNumModelParams
End Sub
------------------
IV2008
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP