Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everybody,
Can someone find where is my error in this code I got an invalid profile but running in manual mode works well!!!
import adsk.core, adsk.fusion, math, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
rootComp = design.rootComponent
_id = 1
_od = 2
_T = 0.01
_f = 0.03
sketches = rootComp.sketches
center = adsk.core.Point3D.create(0, 0, 0)
xyPlane = rootComp.xYConstructionPlane
xzPlane = rootComp.xZConstructionPlane
headSketch = sketches.add(xzPlane)
point1 = adsk.core.Point3D.create(center.x + (_id/2), -center.z, center.y)
point2 = adsk.core.Point3D.create(center.x + (_id/2) + (_T /math.sin(math.pi/3) ) , -center.z , center.y )
point3 = adsk.core.Point3D.create(center.x + (_od/2), -center.z , center.y)
point4 = adsk.core.Point3D.create(center.x + (_od/2) - _T , -center.z , center.y)
arc1 = headSketch.sketchCurves.sketchArcs.addByCenterStartSweep(point1, point3, -math.pi/3)
line1 = headSketch.sketchCurves.sketchLines.addByTwoPoints(arc1.startSketchPoint,point1)
arc2 = headSketch.sketchCurves.sketchArcs.addByCenterStartSweep(point2, point4, -math.pi/3)
line2 = headSketch.sketchCurves.sketchLines.addByTwoPoints(arc2.startSketchPoint,point2)
headSketch.sketchCurves.sketchLines.addByTwoPoints(point1,point2)
headSketch.sketchCurves.sketchLines.addByTwoPoints(point3,point4)
farc1 = headSketch.sketchCurves.sketchArcs.addFillet(line1, line1.startSketchPoint.geometry, arc1, arc1.startSketchPoint.geometry, _f)
farc2 = headSketch.sketchCurves.sketchArcs.addFillet(line2, line2.startSketchPoint.geometry, arc2, arc2.startSketchPoint.geometry, _f)
prof = headSketch.profiles.item(0)
axis_p1 = adsk.core.Point3D.create(center.x , -center.z, center.y)
axis_p2 = adsk.core.Point3D.create(center.x , -center.z - 1 , center.y)
lines = headSketch.sketchCurves.sketchLines
axis_line = lines.addByTwoPoints(axis_p1,axis_p2)
revolves = rootComp.features.revolveFeatures
revInput1 = revolves.createInput(prof, axis_line, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
revAngle = adsk.core.ValueInput.createByReal( 2 * math.pi)
revInput1.setAngleExtent(False,revAngle)
revBody = revolves.add(revInput1)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
I get this error
while selecting the profile again works perfectly
What am I missing here????
Solved! Go to Solution.