Message 1 of 3
How to draw circles on a sphere with given orientation? (Tangent to sphere)

Not applicable
04-19-2020
04:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have a set of points coordinates in a .csv file (cartesian x,y,z). I also have a sphere.
I want to draw circles on that sphere whose center are my points, but I am only able to draw horizontal/vertical circles, without the good orientation.
======================
Relevant part of the code:
dlg = ui.createFileDialog()
dlg.title = 'Open CSV File'
dlg.filter = 'Comma Separated Values (*.csv);;All Files (*.*)'
if dlg.showOpen() != adsk.core.DialogResults.DialogOK :
return
filename = dlg.filename
with io.open(filename, 'r', encoding='utf-8-sig') as f:
points = adsk.core.ObjectCollection.create()
circles = adsk.core.ObjectCollection.create()
line = f.readline()
# initialize arrray data variable
data = []
while line:
pntStrArr = line.split(',')
for pntStr in pntStrArr:
try:
data.append(float(pntStr))
except:
break
if len(data) >= 3 :
point = adsk.core.Point3D.create(data[0], data[1], data[2])
root = design.rootComponent
sketch = root.sketches.add(root.xYConstructionPlane)
sketch.sketchPoints.add(point)
points.add(point)
circle = sketch.sketchCurves.sketchCircles.addByCenterRadius(point, 0.005)
circles.add(circle)
line = f.readline()
data.clear()
if points.count:
root = design.rootComponent
sketch = root.sketches.add(root.xYConstructionPlane)
sketch.sketchPoints.add(points)
sketch.sketchCurves.sketchFittedSplines.add(points)
sketch.sketchCurves.sketchCircles.addByCenterRadius(circles, 0.005)
else:
ui.messageBox('No valid points', title)