
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to build a 3D solid model using sweep / extrusion feature. I have collection of more than 100000 individual coordinates. I am taking two points for extrusion/ sweep at a time to to avoid self intersecting lines problem. However it's taking forever to finish building all bodies (whole model). Is there any way to speed up this process efficiently. I could not understand the use of BRep bodies. I do not need intermediary bodies to be saved. I am trying to get whole extruded model. I have few questions.
1) How to combine all bodies to make single entity?
2) How to use revolve feature that joins the empty spaces between to extrusion bodies at angle?
3)How to find segments untill the intersecting points to use sweep feature so, it doesn't require to take only two points at a time.
I am very new to scripting and making model in Fusion 360.
I would really appreciate if you could help me out in this.
Here is my code: (Any suggestion for improvement would be highly appreciated.)
//
import adsk.core, adsk.fusion, traceback
import io
def Extrudeline(spline,distance,radius,rootComp):
path = rootComp.features.createPath(spline)
# create construction plane normal to the spline
planes = rootComp.constructionPlanes
planeInput = planes.createInput()
planeInput.setByDistanceOnPath(path, adsk.core.ValueInput.createByReal(0))
plane = planes.add(planeInput)
extrudes = rootComp.features.extrudeFeatures
sketches = rootComp.sketches
sketch = sketches.add(plane)
center = plane.geometry.origin
center = sketch.modelToSketchSpace(center)
sketch.sketchCurves.sketchCircles.addByCenterRadius(center, radius)
profile = sketch.profiles[0]
#create a extrude input
distances = adsk.core.ValueInput.createByReal(distance)
extrudeInput = extrudes.createInput(profile, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
extent_distance = adsk.fusion.DistanceExtentDefinition.create(distances)
extrudeInput.setOneSideExtent(extent_distance, adsk.fusion.ExtentDirections.PositiveExtentDirection)
extrude2 = extrudes.add(extrudeInput)
return extrude2
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Get all components in the active design.
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
title = 'Import Spline csv'
if not design:
ui.messageBox('No active Fusion design', title)
return
#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
filename = '/Users/rizal/Desktop/20mm_cubeCoordinates.txt'
with io.open(filename, 'r',buffering=2000000000,encoding='utf-8-sig') as f:
data = []
line = next(f)
for line in f:
pntStrArr = line.split(',')
try:
data.append([float(pntStr) for pntStr in pntStrArr])
except:
continue
length = len(data)
length=1101
temp =0
radius =0.2
while temp<length - 1:
root = design.rootComponent
sketch = root.sketches.add(root.xYConstructionPlane)
sketch.isComputeDeferred = True
distance = ((data[temp][0]-data[temp+1][0])**2+(data[temp][1]-data[temp+1][1])**2+(data[temp][2]-data[temp+1][2])**2)**0.5
line = sketch.sketchCurves.sketchLines.addByTwoPoints(adsk.core.Point3D.create(data[temp][0], data[temp][1], data[temp][2]),adsk.core.Point3D.create(data[temp+1][0], data[temp+1][1], data[temp+1][2]))
temp += 1
extrude1 = Extrudeline(line,distance,radius,root)
sketch.isComputeDeferred = False
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.