Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I use rotated sweeps as basis to draw electrical coils. This works best on lines or arcs and not good on splines.
The basis curve is done by a formular. So I get points and normaly I would draw a spline along, but in this case it is better to draw arcs along. Then I do this rotated sweeps along the arcs.
But there is a problem: Each surface has its own profile and they do not connect.
To connect them to one surface I want to use the end-edge of an arc-sweep as profile for the next arc-sweep.
In my script you see out comanded lines where I try this. But Fusion does not accept the edge as a profile.
Does someone know a solution?
import adsk.core, adsk.fusion, adsk.cam, traceback, math
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
# Get the root component of the active design.
root_comp = design.rootComponent
# Create a new sketch on the xy plane.
sketches = root_comp.sketches
xyPlane = root_comp.xYConstructionPlane
sketch = sketches.add(xyPlane)
points = adsk.core.ObjectCollection.create() # Create an object collection for the points.
windings = 10
pointsPerRound = 4 # Number of points that splines are generated.
i = -pointsPerRound*windings #Startwert, der in der Schleife runtergezählt wird
r = 0.5
h = 0
while i <= 0:
t = (math.pi/(pointsPerRound*windings))*i*2
h = 1.5+((-r)*(math.sin(t*windings)))
xCoord = (h)*(math.sin(t))
yCoord = (h)*(math.cos(t))
zCoord = ((-r)*(math.cos(t*windings)))
points.add(adsk.core.Point3D.create(xCoord,yCoord,zCoord))
i = i + 1
#Combining the points to arcs
arcs = adsk.core.ObjectCollection.create()
for j in range(0,int((windings*pointsPerRound)/2)):
arc = sketch.sketchCurves.sketchArcs.addByThreePoints(points[2*j],points[2*j+1],points[2*j+2])
arcs.add(arc)
profilStart = adsk.core.Point3D.create(points[2*j].x,points[2*j].y,points[2*j].z-0.2)
profilEnd = adsk.core.Point3D.create(points[2*j].x,points[2*j].y,points[2*j].z-0.01)
profil=sketch.sketchCurves.sketchLines.addByTwoPoints(profilStart,profilEnd)
"""
# The right way would be: define a start profile for the sweep...
if j==0:
profilStart = adsk.core.Point3D.create(points[0].x,points[0].y,points[0].z-0.2)
profilEnd = adsk.core.Point3D.create(points[0].x,points[0].y,points[0].z-0.01)
profil=sketch.sketchCurves.sketchLines.addByTwoPoints(profilStart,profilEnd)
# ..and then use the edge of the last sweep as profile for the next:
else:
itemIndex = root_comp.bRepBodies.count-1
body = root_comp.bRepBodies.item(itemIndex)
profil= body.edges.item(3) #it is not clear witch of the four items
sketch.add(profil)
"""
prof = root_comp.createOpenProfile(profil, False)
path = root_comp.features.createPath(arc, False)
sweeps = root_comp.features.sweepFeatures
sweepInput1 = sweeps.createInput(prof, path, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
sweepInput1.twistAngle = adsk.core.ValueInput.createByReal(100)
sweepInput1.isSolid = False
sweep = sweeps.add(sweepInput1)
for j in range(0,10):
arcs[j].startSketchPoint.merge(arcs[j+1].endSketchPoint)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.