How to get suface of the cylinder

How to get suface of the cylinder

AkusoWang
Participant Participant
352 Views
3 Replies
Message 1 of 4

How to get suface of the cylinder

AkusoWang
Participant
Participant

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)

 

king2012hl_0-1680357507652.png

 

0 Likes
353 Views
3 Replies
Replies (3)
Message 2 of 4

aliobidi
Collaborator
Collaborator

Hi , 

just change line "32" to : 

planeInput.setByOffset(selectedFace[i], adsk.core.ValueInput.createByReal(0))
0 Likes
Message 3 of 4

AkusoWang
Participant
Participant

hi, Thank you for your answer. this cant solve the problem.

0 Likes
Message 4 of 4

aliobidi
Collaborator
Collaborator

sorry for that 
you can post your problem Here   "API FORUMS"

or wait me to take a deep look later