Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I created a sketch in Fusion 360 and now I want to use this sketch in my code to create a pipe.
I have this base code:
def run(context):
_ui = None
try:
_app = adsk.core.Application.get()
_ui = _app.userInterface
design = _app.activeProduct
# Get the root component of the active design.
rootComp = design.rootComponent
# create sketch
crv = initSktCircle(rootComp)
# create pipe
initPipe(crv)
def initSktCircle(comp :adsk.fusion.Component):
skt :adsk.fusion.Sketch = comp.sketches.add(comp.xYConstructionPlane)
pnt3D = adsk.core.Point3D
crvs :adsk.fusion.SketchCurves = skt.sketchCurves
crv = crvs.sketchCircles.addByCenterRadius(pnt3D.create(-5.0,-5,0), 4.0)
return crv
def initPipe(path):
sels :adsk.core.Selections = _ui.activeSelections
sels.clear()
sels.add(path)
txtCmds = [
u'Commands.Start PrimitivePipe', # show dialog
u'Commands.SetDouble SWEEP_POP_ALONG 1.0', # input distance
u'Commands.SetDouble SectionRadius 0.5', # input radius
u'NuCommands.CommitCmd' # execute command
]
for cmd in txtCmds:
_app.executeTextCommand(cmd)
sels.clear()
Now how could I bring my sketch in the code? I tried:
crv = rootComp.sketches.item(0).sketchCurves.sketchCircles
# create pipe
initPipe(crv)
Solved! Go to Solution.