- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The script below generates two sketch circles and lofts between them. The product is a NURBS surface, as you can tell by the presence of a seam:
Both circles have identical normals, but they have slightly different radii and X/Y locations.
I am actually trying pretty hard to avoid seams, so I investigated this in some detail. The exact result is exquisitely dependent on the inputs. You might receive a Cylinder, a Cone, an EllipticalCone, or a NurbsSurface depending on the values.
The odd thing is that worse mismatches in values generate better geometry. You nearly always get a seamless surface unless the values vary just in the 6th or 7th decimal places (as shown in the script). Given that the normals of the circles are exactly equal, shouldn't it always be possible to receive at least an elliptical curve?
import adsk.core, adsk.fusion, adsk.cam, traceback
import adsk.core as core, adsk.fusion as fusion
from adsk.core import Vector3D, Point3D, Matrix3D
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
root = design.rootComponent
sketch = root.sketches.add(root.xYConstructionPlane)
circles = sketch.sketchCurves.sketchCircles
origins = [
(0.0438284, 0, -0.6),
(0.0438277, 0, -0.2)
]
radii = [0.1700008, 0.1700004]
xyzCoords = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
xAxis, yAxis, zAxis = (Vector3D.create(*coords) for coords in xyzCoords)
origin = Point3D.create(0, 0, 0)
def moveTransform(x, y, z):
newOrigin = Point3D.create(x, y, z)
matrix = Matrix3D.create()
matrix.setToAlignCoordinateSystems(origin, xAxis, yAxis, zAxis,
newOrigin, xAxis, yAxis, zAxis)
return matrix
def makeCircle(loc, radius):
moveMatrix = moveTransform(*loc)
circle = circles.addByCenterRadius(origin, radius)
collection = adsk.core.ObjectCollection.create()
collection.add(circle)
sketch.move(collection, moveMatrix)
return circle
def createLoftFeature(profiles):
option = fusion.ChainedCurveOptions.noChainedCurves
profilePaths = [ fusion.Path.create(curve, option) for curve in profiles ]
loftFeatures = root.features.loftFeatures
newBodyOption = fusion.FeatureOperations.NewBodyFeatureOperation
loftInput = loftFeatures.createInput(newBodyOption)
for path in profilePaths:
loftInput.loftSections.add(path)
loftInput.isSolid = False
return root.features.loftFeatures.add(loftInput)
sketchCircles = [makeCircle(loc, radius) for loc, radius in zip(origins, radii)]
loft = createLoftFeature(sketchCircles)
surface = loft.bodies[0].faces[0].geometry
ui.messageBox(f"Surface type is {str(type(surface))}")
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.