Hallo,
habe ein nettes Problem. Beim Versuch die Koordinaten eines Bogens zu erhalten bekomme ich Mittelpunkt, Start- Endpunkt und Winkel des Bogens usw. - nur, woher weiß ich in welche Richtung der Bogen geht?
Also, ist der Bogen Konvex oder Konkav? Anhand der Koordinaten wäre beides möglich.
Wenn ich mir die Zwischenpunkte des Bogens ausgeben lasse, kann ich sehen in welche Richtung der Bogen läuft aber das scheint mit ziemlich kompliziert.
Also meine Bitte an die Experten - wo scheint das Licht?
Gruß
Michael
Hier mein Versuch die Koordinaten auszulesen:
Option Explicit
Global mf As Double
Public Sub CurveGeometry()
mf = 10#
' Get the active document.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
' Get the selected edge.
On Error Resume Next
Dim oEdge As Edge
Set oEdge = oPartDoc.SelectSet.Item(1)
If Err Then
MsgBox "An edge must be selected."
Exit Sub
End If
On Error GoTo 0
' Check the geometry type and print out some geometry specific information.
Select Case oEdge.GeometryType
Case kLineSegmentCurve
Dim oLineSegment As LineSegment
Set oLineSegment = oEdge.Geometry
Debug.Print "Start point: " & PointString(oLineSegment.StartPoint)
Debug.Print "End point: " & PointString(oLineSegment.EndPoint)
Case kCircleCurve
Dim oCircle As Inventor.Circle
Set oCircle = oEdge.Geometry
Debug.Print "Center point: " & PointString(oCircle.Center)
Debug.Print "Radius: " & Format(oCircle.Radius, "0.0000")
Case kCircularArcCurve
Dim dPi As Double
dPi = Atn(1) * 4
Dim oArc As Inventor.Arc3d
Set oArc = oEdge.Geometry
Debug.Print "Arc begin ### ### ###"
Dim oCurveEval As CurveEvaluator
Set oCurveEval = oEdge.Evaluator
' Get the parametric range of the curve.
Dim dMinParam As Double
Dim dMaxParam As Double
Call oCurveEval.GetParamExtents(dMinParam, dMaxParam)
Debug.Print "min: " & Str(dMinParam)
Debug.Print "max: " & Str(dMaxParam)
' Iterate 10 steps over the curve length and print the
' parameter values and corresponding model points.
Dim i As Integer
For i = 0 To 10
' Calculate the current parameter to evaluate.
Dim currentParam As Double
currentParam = dMinParam + ((dMaxParam - dMinParam) / 10) * i
' Assign the value to an array since the GetPointAtParam
' takes an array as input.
Dim adParam(0) As Double
adParam(0) = currentParam
' Get the coordinates of the parameter point in model space.
Dim adPoints(2) As Double
Call oCurveEval.GetPointAtParam(adParam, adPoints)
' Print information about this point.
Debug.Print "Parameter Nr.: " & Str(i) & ") " & Format(currentParam, "0.000") & _
" Coordinate: " & Format(adPoints(0) * mf, "0.000") & "," & _
Format(adPoints(1) * mf, "0.000") & "," & _
Format(adPoints(2) * mf, "0.000")
Next i
Debug.Print "Start point: " & PointString(oArc.StartPoint)
Debug.Print "End point: " & PointString(oArc.EndPoint)
Debug.Print "Center point: " & PointString(oArc.Center)
Debug.Print "Radius: " & Format(oArc.Radius * mf, "0.000")
Debug.Print "Sweep: " & Str(oArc.SweepAngle) 'Format(oArc.SweepAngle * (180 / dPi), "0.000000")
Debug.Print "Arc end ### ### ###"
Case Else
Debug.Print "Unsupported geometry type selected."
End Select
End Sub
' Given a point or vector return a string containing the X,Y,Z coordinates.
Private Function PointString(PointOrVector As Object) As String
PointString = Format(PointOrVector.X * mf, "0.000") & "," & _
Format(PointOrVector.Y * mf, "0.000") & "," & _
Format(PointOrVector.Z * mf, "0.000")
End Function
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP