Zitat:
Original erstellt von sebastian_malzer:
Hallo!
Ich hab mal wieder eine Frage:
Wie kann ich ein Face auf eine Skizze projizieren? Ich habs mit "AddByProjectingEntity" versucht und damit leider keinen Erfolg gehabt.Gruß
Basti
Hallo Basti,
sieh Dir nachfolgenden Code an, damit dürfte alles klar sein.
Du benötigst nur ein Formular mit dem Namen 'frmSketch' und einen Button für die Auswahl deiner zu projizierenden Fläche
'----- Source für Modul1
Option Explicit
Public Sub Face()
If ThisApplication.ActiveDocument Is Nothing Then
MsgBox "A document must be open when using this tool."
Else
' Display the dialog.
frmSketch.Show vbModeless
End If
End Sub
'----Source für frmSketch
Option Explicit
Private WithEvents oInteraction As InteractionEvents
Private WithEvents oSelectEvents As SelectEvents
Private oPart As PartDocument
Private oFace As New Collection
Private Sub CommandButton1_Click()
Set oPart = ThisApplication.ActiveDocument
Set oInteraction = ThisApplication.CommandManager.CreateInteractionEvents
Set oSelectEvents = oInteraction.SelectEvents
oSelectEvents.ResetSelections
oSelectEvents.SingleSelectEnabled = True
oSelectEvents.AddSelectionFilter kPartFacePlanarFilter
frmSketch.Hide
oInteraction.Start
oInteraction.SelectionActive = True
oInteraction.StatusBarText = "Fläche wählen"
End Sub
' Tritt ein, sobald eine Fläche gewählt wurde
Private Sub oSelectEvents_OnSelect(ByVal JustSelectedEntities As Inventor.ObjectsEnumerator, ByVal SelectionDevice As Inventor.SelectionDeviceEnum, ByVal ModelPosition As Inventor.Point, ByVal ViewPosition As Inventor.Point2d, ByVal View As Inventor.View)
frmSketch.Show vbModeless
oInteraction.SelectionActive = False
SketchAdd
oInteraction.Stop
End Sub
' Tritt beim Abbruch ein [ESC]
Private Sub oInteraction_OnTerminate()
'MsgBox "On Terminate"
oSelectEvents.ResetSelections
oInteraction.SelectionActive = False
frmSketch.Show vbModeless
End Sub
' Fläche auf Skizze projizieren
Private Sub SketchAdd()
Dim oSetFace As Face
Dim oSketch As PlanarSketch
Dim oPartCompDef As PartComponentDefinition
Set oPartCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Set oSetFace = oSelectEvents.SelectedEntities(1)
Set oSketch = oPartCompDef.Sketches.Add(oSetFace, True)
End Sub
Schöne Grüße
Heimo
------------------
LieGrü Heijo
EVERYTHING IS DESIGNED.
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP