Hallo zusammen,
erstmals danke für die Antworten.
Ich habe eine Lösung für mich gefunden.
Ich habe eine kleine VBA Routine (mit KI Unterstützung) erstellt,
die mit anklicken der Gehrungskante und der Referenzkante eine Bemaßung
senkrecht zur Referenzkante erstellt. Die Bemaßung kann dann noch mit der Mause
positioniert werden.
Hier noch die Routine für IV2026:
Option Explicit
Sub Gehrungswinkel()
Dim oDoc As DrawingDocument: Set oDoc = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry: Set oTG = ThisApplication.TransientGeometry
' 1. AUSWAHL
Dim oMiterEdge As DrawingCurveSegment
Set oMiterEdge = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Gehrungskante wählen")
If oMiterEdge Is Nothing Then Exit Sub
Dim oRefEdge As DrawingCurveSegment
Set oRefEdge = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Referenzkante wählen")
If oRefEdge Is Nothing Then Exit Sub
' 2. ANALYTISCHE BERECHNUNG (Keine API-Objekte für Schnittpunkt)
Dim oGMiter As LineSegment2d: Set oGMiter = oMiterEdge.Geometry
Dim oGRef As LineSegment2d: Set oGRef = oRefEdge.Geometry
Dim x1 As Double: x1 = oGMiter.StartPoint.X: Dim y1 As Double: y1 = oGMiter.StartPoint.Y
Dim x2 As Double: x2 = oGMiter.EndPoint.X: Dim y2 As Double: y2 = oGMiter.EndPoint.Y
Dim x3 As Double: x3 = oGRef.StartPoint.X: Dim y3 As Double: y3 = oGRef.StartPoint.Y
Dim x4 As Double: x4 = oGRef.EndPoint.X: Dim y4 As Double: y4 = oGRef.EndPoint.Y
Dim den As Double: den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
If Abs(den) < 0.000001 Then Exit Sub
Dim sX As Double: sX = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / den
Dim sY As Double: sY = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / den
Dim oSheetPoint As Point2d: Set oSheetPoint = oTG.CreatePoint2d(sX, sY)
' 3. SKIZZE UND HILFSLINIE
Dim oView As DrawingView: Set oView = oMiterEdge.Parent.Parent
Dim oSketch As DrawingSketch: Set oSketch = oView.Sketches.Add()
oSketch.Edit
Dim oSketchPoint As Point2d: Set oSketchPoint = oSketch.SheetToSketchSpace(oSheetPoint)
Dim rX As Double: rX = x4 - x3: Dim rY As Double: rY = y4 - y3
Dim nX As Double: nX = -rY: Dim nY As Double: nY = rX
Dim vLen As Double: vLen = Sqr(nX * nX + nY * nY)
nX = (nX / vLen) * 2: nY = (nY / vLen) * 2
Dim midX As Double: midX = (x1 + x2) / 2: Dim midY As Double: midY = (y1 + y2) / 2
If (nX * (midX - sX) + nY * (midY - sY)) < 0 Then
nX = -nX: nY = -nY
End If
Dim oEndP As Point2d: Set oEndP = oTG.CreatePoint2d(oSketchPoint.X + nX, oSketchPoint.Y + nY)
Dim oHelpLine As SketchLine: Set oHelpLine = oSketch.SketchLines.AddByTwoPoints(oSketchPoint, oEndP)
oHelpLine.Construction = True
Dim oProjMiter As SketchEntity: Set oProjMiter = oSketch.AddByProjectingEntity(oMiterEdge.Parent)
oSketch.ExitEdit
' 4. BEMA?UNG AUTOMATISCH PLATZIEREN (Vermeidung von Pick-Fehlern)
Dim oSheet As Sheet: Set oSheet = oDoc.ActiveSheet
Dim oIntent1 As GeometryIntent: Set oIntent1 = oSheet.CreateGeometryIntent(oProjMiter)
Dim oIntent2 As GeometryIntent: Set oIntent2 = oSheet.CreateGeometryIntent(oHelpLine)
' Wir platzieren das Maß einfach 1cm versetzt vom Schnittpunkt
' Das funktioniert ohne jede Benutzerinteraktion und ohne Fehler 438
Dim oDimPos As Point2d: Set oDimPos = oTG.CreatePoint2d(sX + (nX / 2), sY + (nY / 2))
On Error Resume Next
Dim oAngDim As AngularGeneralDimension
Set oAngDim = oSheet.DrawingDimensions.GeneralDimensions.AddAngular(oDimPos, oIntent1, oIntent2)
On Error GoTo 0
' MsgBox "Winkelbemaßung wurde am Schnittpunkt erstellt. Sie können sie jetzt manuell verschieben."
End Sub
mfg Stefan
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP