trying to duplicate/copy-paste sketch via api/script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
insimple words i need to just copy and paste a sketch in same component
the code im using is given below
i dont understand whats my mistake and have started to think maybe the way i'm trying todo is not currect
your simple input on best way to dupilcate/copy-paste a sketch with the flexibility to transform new sketch will give me results to my 2 days of brain stroming thanks
added a screen shot showing 'asdf' sketch is having a simple circle which need to be duplicated in another sketch of the same component
please feel free to be creative copy-paste in same or different component doesnt matter or even different file
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Get active design
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
sketch = adsk.fusion.Sketch
transform = adsk.core.Matrix3D
objcol = adsk.fusion.Sketch
# Get root component in this design
rootComp = design.rootComponent
# Get the first sub component
occs = rootComp.occurrences
subComp1 = occs.item(0).component
sketchInSubComp1 = subComp1.sketches.item(0)
ui.messageBox(str(sketchInSubComp1.name))
# create a new/copy sketch
compSketchProp = subComp1.sketches
xyPlane = subComp1.xYConstructionPlane #only selects the xy constructionplane
#createSketchSubComp2 = subComp1.sketches.add(xyPlane)
copysketchs = sketch.copy(subComp1,transform.copy,xyPlane)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))