Message 1 of 4
How to get suface of the cylinder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hallo, I want to use "Line : 25" to get surface of cylinder zo dig hole on the cylinder entity, but it got the tangent plane of cyliner surface.
Thank you!
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(20, 10)
L = random.uniform(10, 20)
sketch = rootComp.sketches.add(rootComp.xZConstructionPlane)
center = adsk.core.Point3D.create(x0/2, -y0/2, 0)
circle = sketch.sketchCurves.sketchCircles.addByCenterRadius(center, x0)
prof = sketch.profiles.item(0)
extrudes = rootComp.features.extrudeFeatures
distance_1 = adsk.core.ValueInput.createByReal(L)
extrudeInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
extrudeInput.setDistanceExtent(False, adsk.core.ValueInput.createByReal(random.uniform(L, L+5)))
extrude = extrudes.add(extrudeInput)
body_1 =extrude.bodies.item(0)
faces = body_1.faces
selectedFace=[faces.item(0),faces.item(1),faces.item(2)]
for i in range(1,3):
x1 = random.uniform(-x0, x0)
y1 = random.uniform(-y0, y0)
planeInput = rootComp.constructionPlanes.createInput()
planeInput.setByOffset(selectedFace[i-1], adsk.core.ValueInput.createByReal(0))
newPlane = rootComp.constructionPlanes.add(planeInput)
sketch2 = rootComp.sketches.add(newPlane)
lines = sketch2.sketchCurves.sketchLines
recLines = lines.addTwoPointRectangle(adsk.core.Point3D.create(x1, y1, 0), adsk.core.Point3D.create(x1/5, y1/5, 0))
prof:adsk.fusion.Profile = sketch2.profiles.item(0)
extrudes = rootComp.features.extrudeFeatures
distance_2 = adsk.core.ValueInput.createByReal(3)
distance_Cut = adsk.core.ValueInput.createByReal(-3)
extrudeInput = extrudes.addSimple(prof, distance_Cut, adsk.fusion.FeatureOperations.CutFeatureOperation)