Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Angle between lines

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
brad.bylls
248 Views, 2 Replies

Angle between lines

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
2 REPLIES 2
Message 2 of 3
CADacombs
in reply to: brad.bylls

Try replacing geometry with worldGeometry in lines 8 and 9.

Message 3 of 3
brad.bylls
in reply to: CADacombs

Thank you @CADacombs .

Didn't even think of that.

My bad.

That worked.

Brad Bylls

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report