Angle between lines

Angle between lines

brad.bylls
Collaborator Collaborator
549 Views
2 Replies
Message 1 of 3

Angle between lines

brad.bylls
Collaborator
Collaborator

I am trying to find the angle between two lines.

The lines are in different sketches and on different planes that are perpendicular to each other.

This is the code I have been working with.

sketch2 = sketches.addWithoutEdges(plane)
recCenter = sketch2.modelToSketchSpace(endPoint)
centerPoint = lineX.endSketchPoint.worldGeometry
point1 = sketch2.modelToSketchSpace(centerPoint)
lines = sketch2.sketchCurves.sketchLines
lineEndPoint = adsk.core.Point3D.create(point1.x + .5, point1.y, point.z)
lineY = lines.addByTwoPoints(point1, lineEndPoint)
vector1: adsk.core.Vector3D = lineX.geometry.asInfiniteLine().direction
vector2: adsk.core.Vector3D = lineY.geometry.asInfiniteLine().direction
newAng = math.degrees(vector1.angleTo(vector2))
newAngStr = "%.16f" % float(newAng)

The lineX and lineY appear to be 90 degrees apart, but in Debugging I get this.

Screenshot 2024-03-30 083040.png newAng = Radians

Screenshot 2024-03-30 083055.png newAngStr = Degrees

This is the screen capture I am referring to.

LineX is created higher in the code.

The selected surface plane is what the user clicks on to create the sketch that contains lineX.

LineY is in a sketch on a construction plane perpendicular to the Selected surface plane.

Screenshot 2024-03-30 083147.png

Any and all help appreciated.

Thank you.

 

Brad Bylls
0 Likes
Accepted solutions (2)
550 Views
2 Replies
Replies (2)
Message 2 of 3

CADacombs
Enthusiast
Enthusiast
Accepted solution

Try replacing geometry with worldGeometry in lines 8 and 9.

Message 3 of 3

brad.bylls
Collaborator
Collaborator
Accepted solution

Thank you @CADacombs .

Didn't even think of that.

My bad.

That worked.

Brad Bylls
0 Likes