Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I did 6 hour to solve this problem, feel pretty frustrated. I cant find the example about it.
Could anyone help me solve this problem please!
I build first a entity and want to make the every point from list. Every time only use one point to make a sketch and extrude a hole from entity.
Problem: it show me always, that it cant find a entity to make cutting with new sketch, it seems like, that after get first point,making sketch and extrude, it cant really remove thie frist point from list, and second time it get the same point, so that cant make new cutting with the sketch anymore.
import adsk.fusion, adsk.cam, random, math, adsk.core, os, traceback
app = adsk.core.Application.get()
ui = app.userInterface
doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
design = adsk.fusion.Design.cast(app.activeProduct)
rootComp = design.rootComponent
x0 = random.uniform(10, 20)
y0 = random.uniform(10, 20)
L = random.uniform(10, 20)
sketch = rootComp.sketches.add(rootComp.xZConstructionPlane)
lines = sketch.sketchCurves.sketchLines
rec_center =adsk.core.Point3D.create(0, 0, 0)
lines.addCenterPointRectangle(rec_center, adsk.core.Point3D.create(x0, y0, 0))
prof = sketch.profiles.item(0)
extrudes = rootComp.features.extrudeFeatures
extrude_NewBody = adsk.fusion.FeatureOperations.NewBodyFeatureOperation
extrude_Cut =adsk.fusion.FeatureOperations.CutFeatureOperation
distance = adsk.core.ValueInput.createByReal(L)
extrudeInput = extrudes.addSimple(prof, distance, extrude_NewBody)
face1_end = extrudeInput.endFaces.item(0)
sketch3 = rootComp.sketches.add(rootComp.xZConstructionPlane)
sketchPoints = sketch3.sketchPoints
pt_List = []
for i in range(5):
pt_List.append(sketchPoints.add(adsk.core.Point3D.create(6, 0, 0)))
pt_List.append(sketchPoints.add(adsk.core.Point3D.create(4, 2, 0)))
pt_List.append(sketchPoints.add(adsk.core.Point3D.create(2, 0, 0)))
pt_List.append(sketchPoints.add(adsk.core.Point3D.create(0, 4, 0)))
pt_List.append(sketchPoints.add(adsk.core.Point3D.create(4, 0, 0)))
for i in range(5):
pt = random.sample(pt_List, 1)[0]
pt_List.remove(pt)
for curve in sketch3.sketchCurves:
if curve.geometry.center.isEqualTo(pt.geometry):
pt = random.sample(pt_List, 1)[0]
pt_List.remove(pt)
break
circle = sketch3.sketchCurves.sketchCircles
circle.addByCenterRadius(pt.geometry, 0.5)
prof = sketch3.profiles.item(0)
extrudes = rootComp.features.extrudeFeatures
extrudeInput = extrudes.createInput(prof, extrude_Cut)
extrudeInput.setDistanceExtent(True, adsk.core.ValueInput.createByReal(L))
extrudes.add(extrudeInput)
Thank you!
Solved! Go to Solution.